poller

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

poller package contains the implementation of status poller for monitoring a set of resources on the remote server and posting their updates in a channel

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	NewPoller(dynamic.Interface, meta.RESTMapper) StatusPoller
}

type DefaultBuilder

type DefaultBuilder struct{}

func (*DefaultBuilder) NewPoller

func (b *DefaultBuilder) NewPoller(client dynamic.Interface, mapper meta.RESTMapper) StatusPoller

type Informer

type Informer struct {
	// contains filtered or unexported fields
}

func (*Informer) AddEventHandler

func (*Informer) Run

func (i *Informer) Run()

func (*Informer) SetWatchErrorHandler

func (i *Informer) SetWatchErrorHandler(handler cache.WatchErrorHandler) error

func (*Informer) Stop

func (i *Informer) Stop()

type InformerBuilder

type InformerBuilder struct {
	Client       dynamic.Interface
	Mapper       meta.RESTMapper
	ResyncPeriod time.Duration
	Indexers     cache.Indexers
}

InformerBuilder can be used for setting up a series of new informers reusing the same configurations

func NewInfromerBuilder

func NewInfromerBuilder(client dynamic.Interface, mapper meta.RESTMapper, resync time.Duration) *InformerBuilder

NewInfromerBuilder return a new informer builder configured with client and resync period

func (*InformerBuilder) NewInformer

func (b *InformerBuilder) NewInformer(ctx context.Context, resource InformerResource) (*Informer, error)

NewInformer return a new SharedInformer configured for resource or an error if the resource group/kind cannot be looked up to the remote server

type InformerMultiplexer

type InformerMultiplexer struct {
	InformerBuilder InformerBuilder
	Resources       []InformerResource
	ObjectToObserve []resource.ObjectMetadata
	// contains filtered or unexported fields
}

InformerMultiplexer can be used to manage multiple informer better than a working group. With InformerMultiplexer we can stop and restart informer based on the responses to better manage the calls made to the remote api

func (*InformerMultiplexer) Run

func (im *InformerMultiplexer) Run(ctx context.Context) <-chan event.Event

Run will start the multiplexer for the set Resources and ObjectToObserve, it will return a channel where all the obkect statuses will be reported

func (*InformerMultiplexer) Stop

func (im *InformerMultiplexer) Stop()

Stop will mark the multiplexer context as done and stop new informer to be added, the channel will remain open until all currently started informer will send their last message

type InformerResource

type InformerResource struct {
	GroupKind schema.GroupKind
	Namespace string
}

InformerResource encapsulate the needed information from a resource for instatiating an informer

type Multiplexer

type Multiplexer[T any] struct {
	// contains filtered or unexported fields
}

func NewMultiplexer

func NewMultiplexer[T any](doneCh <-chan struct{}) *Multiplexer[T]

func (*Multiplexer[T]) AddChannel

func (m *Multiplexer[T]) AddChannel(ch <-chan T) error

func (*Multiplexer[T]) MultiplexedChannel

func (m *Multiplexer[T]) MultiplexedChannel() <-chan T

type Result

type Result struct {
	Status  Status
	Message string
}

func StatusCheck

func StatusCheck(object *unstructured.Unstructured) (*Result, error)

StatusCheck will perform a series of checks to find if objects has some properties set on its status that can be extrapolated to find what its current status in the cluster is. The checks are:

  • presence of deletion timestamp
  • comparing current and observed generations
  • specific checks for core native k8s kinds
  • presence of particular conditions types

type Status

type Status int
const (
	StatusInProgress Status = iota
	StatusFailed
	StatusTerminating
	StatusCurrent
)

func (Status) String

func (i Status) String() string

type StatusPoller

type StatusPoller interface {
	// Start will start polling the remote api-server for getting updates to the passed resources
	Start(context.Context, []*unstructured.Unstructured) <-chan event.Event
}

func NewDefaultStatusPoller

func NewDefaultStatusPoller(client dynamic.Interface, mapper meta.RESTMapper) StatusPoller

NewDefaultStatusPoller return a default implementation of StatusPoller that will connect to the remote api-server and elaborate the current status of the requested resources

Directories

Path Synopsis
fake package is used to abstract the StatusPoller and return predictable outcomes.
fake package is used to abstract the StatusPoller and return predictable outcomes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL