scheduler

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultScheduler = NewScheduler(nil)

DefaultScheduler is a default scheduler.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	QueueSize uint8
}

Configuration defines configuration of Scheduler.

type DefaultStore

type DefaultStore struct {
	//Support sync locking
	*sync.RWMutex
	// contains filtered or unexported fields
}

DefaultStore implements Store interface to keep the scheduled policies. Not support concurrent sync.

func NewDefaultStore

func NewDefaultStore() *DefaultStore

NewDefaultStore is used to create a new store and return the pointer reference.

func (*DefaultStore) Clear

func (cs *DefaultStore) Clear()

Clear all the items in store.

func (*DefaultStore) Exists

func (cs *DefaultStore) Exists(key string) bool

Exists is used to check whether or not the key exists in store.

func (*DefaultStore) Get

func (cs *DefaultStore) Get(key string) *Watcher

Get policy via key.

func (*DefaultStore) GetAll

func (cs *DefaultStore) GetAll() []*Watcher

GetAll to get all the items of store.

func (*DefaultStore) Put

func (cs *DefaultStore) Put(key string, value *Watcher) error

Put a policy into store.

func (*DefaultStore) Remove

func (cs *DefaultStore) Remove(key string) *Watcher

Remove is to delete the specified policy.

func (*DefaultStore) Size

func (cs *DefaultStore) Size() uint32

Size return the total count of items in store.

type Scheduler

type Scheduler struct {
	//Mutex for sync controling.
	*sync.RWMutex
	// contains filtered or unexported fields
}

Scheduler is designed for scheduling policies.

func NewScheduler

func NewScheduler(config *Configuration) *Scheduler

NewScheduler is constructor for creating a scheduler.

func (*Scheduler) GetPolicy

func (sch *Scheduler) GetPolicy(policyName string) policy.Policy

GetPolicy is used to get related policy reference by its name.

func (*Scheduler) HasScheduled

func (sch *Scheduler) HasScheduled(policyName string) bool

HasScheduled is to check whether the given policy has been scheduled or not.

func (*Scheduler) IsRunning

func (sch *Scheduler) IsRunning() bool

IsRunning to indicate whether the scheduler is running.

func (*Scheduler) PolicyCount

func (sch *Scheduler) PolicyCount() uint32

PolicyCount returns the count of currently scheduled policies in the scheduler.

func (*Scheduler) Schedule

func (sch *Scheduler) Schedule(scheduledPolicy policy.Policy) error

Schedule and enable the policy.

func (*Scheduler) Start

func (sch *Scheduler) Start()

Start the scheduler damon.

func (*Scheduler) Stop

func (sch *Scheduler) Stop()

Stop the scheduler damon.

func (*Scheduler) UnSchedule

func (sch *Scheduler) UnSchedule(policyName string) error

UnSchedule the specified policy from the enabled policies list.

type StatItem

type StatItem struct {
	//Metrics catalog
	Type string

	//The stat value
	Value uint32

	//Attach some other info
	Attachment interface{}
}

StatItem is defined for the stat metrics.

type StatSummary

type StatSummary struct {
	//Count of scheduled policy
	PolicyCount uint32

	//Total count of tasks
	Tasks uint32

	//Count of successfully complete tasks
	CompletedTasks uint32

	//Count of tasks with errors
	TasksWithError uint32
}

StatSummary is used to collect some metrics of scheduler.

type Store

type Store interface {
	//Put a new policy in.
	Put(key string, value *Watcher) error

	//Get the corresponding policy with the key.
	Get(key string) *Watcher

	//Exists is to check if the key existing in the store.
	Exists(key string) bool

	//Remove the specified policy and return its reference.
	Remove(key string) *Watcher

	//Size return the total count of items in store.
	Size() uint32

	//GetAll is to get all the items in the store.
	GetAll() []*Watcher

	//Clear store.
	Clear()
}

Store define the basic operations for storing and managing policy watcher.

type Watcher

type Watcher struct {
	//Locker to sync related operations.
	*sync.RWMutex
	// contains filtered or unexported fields
}

Watcher is an asynchronous runner to provide an evaluation environment for the policy.

func NewWatcher

func NewWatcher(p policy.Policy, st chan *StatItem, done chan *Watcher) *Watcher

NewWatcher is used as a constructor.

func (*Watcher) IsRunning

func (wc *Watcher) IsRunning() bool

IsRunning to indicate if the watcher is still running.

func (*Watcher) Start

func (wc *Watcher) Start()

Start the running.

func (*Watcher) Stop

func (wc *Watcher) Stop()

Stop the running.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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