scheduler

package
v0.0.0-...-367748d Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scheduler is providing the `Scheduler` interface that should be implemented for any scheduler that would want to plug in `autodiscovery`. It also define the `Controller` which dispatches all instructions from `autodiscovery` to all the registered schedulers.

Controller The goal of controller is to transform Autodiscovery to a reconciling controller. Basically the idea is to decouple entirely providers/listeners/resolvers process from the Check scheduling process.

This Controller component will also serialize (in terms of ordering) the Schedule/Unschedule events and concentrate all the logic to processNextWorkItem, retry on Unschedule failures, etc.

ConfigState/ConfigStateStore The ConfigStateStore is a simple in-memory store that keeps track of the desired state of the configs. It is used to keep track of the desired state of the configs sent from applyChanges

Package scheduler provides the `Scheduler` interface that should be implemented for any scheduler that wants to plug in `autodiscovery`. It also defines the `Controller` which dispatches all instructions from `autodiscovery` to all the registered schedulers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigState

type ConfigState int8

ConfigState represents the state of the config: scheduled or unscheduled

const (
	// Scheduled config should be scheduled or is scheduled
	Scheduled ConfigState = 1 << iota
	// Unscheduled config is unscheduled or should be unscheduled
	Unscheduled
)

type ConfigStateData

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

ConfigStateData contains desiredState which is the eventually desired state of the config (to be scheduled or unscheduled)

type ConfigStateStore

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

ConfigStateStore is in charge of storing 1. the scheduled integration.Config 2. desired state of the config to be scheduled/unscheduled compared to existing desiredState + currentState: for example, a new config has been called with [schedule, unschedule, schedule], the config will be scheduled, but only one schedule should be executed

func NewConfigStateStore

func NewConfigStateStore() *ConfigStateStore

NewConfigStateStore creates a new NewConfigStateStore

func (*ConfigStateStore) Cleanup

func (store *ConfigStateStore) Cleanup(configDigest Digest)

Cleanup if config desired states is Unscheduled, we remove it after it has been unscheduled by controller during this cleanup operation, the store is locked to avoid race condition from updateDesiredState

func (*ConfigStateStore) GetConfigState

func (store *ConfigStateStore) GetConfigState(configDigest Digest) (ConfigStateData, bool)

GetConfigState returns the config state

func (*ConfigStateStore) List

func (store *ConfigStateStore) List() []ConfigStateData

List returns the list of all configs states

func (*ConfigStateStore) UpdateDesiredState

func (store *ConfigStateStore) UpdateDesiredState(changes integration.ConfigChanges) []Digest

UpdateDesiredState update the desiredState of the config immediately

type Controller

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

Controller is a scheduler dispatching to all its registered schedulers

func NewController

func NewController() *Controller

NewController inits a scheduler controller

func (*Controller) ApplyChanges

func (ms *Controller) ApplyChanges(changes integration.ConfigChanges)

ApplyChanges add configDigests to the workqueue

func (*Controller) Deregister

func (ms *Controller) Deregister(name string)

Deregister a scheduler in the schedulerController to dispatch to

func (*Controller) Register

func (ms *Controller) Register(name string, s Scheduler, replayConfigs bool)

Register a new scheduler to receive configurations. Previously scheduled configurations that have not subsequently been unscheduled can be replayed with the replayConfigs flag. This replay occurs immediately, before the Register call returns.

func (*Controller) Stop

func (ms *Controller) Stop()

Stop handles clean stop of registered schedulers

type Digest

type Digest uint64

Digest is the unique identifier of the config

type Scheduler

type Scheduler interface {
	// Schedule zero or more new configurations.
	Schedule([]integration.Config)

	// Unschedule zero or more configurations that were previously scheduled.
	Unschedule([]integration.Config)

	// Stop the scheduler.  This method is called from the Controller's Stop
	// method.  Note that currently-scheduled configs are _not_ unscheduled when
	// the Controller stops.
	Stop()
}

Scheduler is the interface that should be implemented if you want to schedule and unschedule integrations. Values implementing this interface can be passed to the Controller's Register method (or AutoConf.AddScheduler).

type TaskStatus

type TaskStatus int8

TaskStatus represents the status of the schedule task: success, failed or config not found

Jump to

Keyboard shortcuts

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