Documentation ¶
Overview ¶
Package monitor provides the main controller for the flipper package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group monitors a group of resources and actions on them if necessary.
type HealthKeeper ¶
type HealthKeeper struct {
// contains filtered or unexported fields
}
HealthKeeper keeps track of the health of the resources in a group and generates actions to keep them healthy. It is responsible for monitoring the health of the resources.
func NewHealthKeeper ¶
func NewHealthKeeper( cfg cfgmodel.GroupConfig, logger *slog.Logger, provider resource.Provider, notifier notification.Notifier, ) *HealthKeeper
NewHealthKeeper creates a new healthkeeper for a group.
func (*HealthKeeper) Start ¶
func (h *HealthKeeper) Start( ctx context.Context, resourceChanges <-chan ResourceUpdate, actionChan chan<- HealthKeeperAction, )
Start monitoring the given resources, stopping anything it was watching before. This function blocks until the context is cancelled. It will send actions to the actionChan when it detects that an action is required to keep the resources healthy. The caller is responsible for closing the actionChan.
type HealthKeeperAction ¶
type HealthKeeperAction struct { // ResourcesSequence is the sequence number of the resources when the action was generated. ResourcesSequence uint64 State plan.State Plan plan.Plan }
HealthKeeperAction is an action that the healthkeeper requests to be executed.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor watches resources. It supports watching multiple groups of resources in parallel.
type ResourceUpdate ¶
type ResourceUpdate struct { // Sequence is the sequence number of the update, it can be used to detect stale updates. Sequence uint64 // Resources is the current state of the resources. Resources resource.Group Changeset resource.GroupChangeset }
ResourceUpdate contains the current resources and the changeset since the last update.
type ResourcesWatcher ¶
ResourcesWatcher watches for changes of the resources in a resource group itself. It polls the resources from the provider and sends updates over a channel.
func NewResourcesWatcher ¶
func NewResourcesWatcher(cfg cfgmodel.GroupConfig, logger *slog.Logger, provider resource.Provider) *ResourcesWatcher
NewResourcesWatcher creates a new resource watcher for a group.
func (*ResourcesWatcher) Start ¶
func (w *ResourcesWatcher) Start(ctx context.Context, onChange chan<- ResourceUpdate, onError chan<- error)
Start watching the resources and send updates to the onChange channel. If an error occurs, it is sent to the onError channel. The context can be used to stop the watcher. This function blocks until the context is canceled.
func (*ResourcesWatcher) Update ¶
func (w *ResourcesWatcher) Update(ctx context.Context) (resource.Group, resource.GroupChangeset, error)
Update the resources by polling the provider. This updates the internal state and returns the resources and changeset from the last call to Update.