Documentation
¶
Index ¶
- Variables
- type Configuration
- type DefaultStore
- func (cs *DefaultStore) Clear()
- func (cs *DefaultStore) Exists(key string) bool
- func (cs *DefaultStore) Get(key string) *Watcher
- func (cs *DefaultStore) GetAll() []*Watcher
- func (cs *DefaultStore) Put(key string, value *Watcher) error
- func (cs *DefaultStore) Remove(key string) *Watcher
- func (cs *DefaultStore) Size() uint32
- type Scheduler
- func (sch *Scheduler) GetPolicy(policyName string) policy.Policy
- func (sch *Scheduler) HasScheduled(policyName string) bool
- func (sch *Scheduler) IsRunning() bool
- func (sch *Scheduler) PolicyCount() uint32
- func (sch *Scheduler) Schedule(scheduledPolicy policy.Policy) error
- func (sch *Scheduler) Start()
- func (sch *Scheduler) Stop()
- func (sch *Scheduler) UnSchedule(policyName string) error
- type StatItem
- type StatSummary
- type Store
- type Watcher
Constants ¶
This section is empty.
Variables ¶
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) Exists ¶
func (cs *DefaultStore) Exists(key string) bool
Exists is used to check whether or not the key exists in store.
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) HasScheduled ¶
HasScheduled is to check whether the given policy has been scheduled or not.
func (*Scheduler) PolicyCount ¶
PolicyCount returns the count of currently scheduled policies in the scheduler.
func (*Scheduler) UnSchedule ¶
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 ¶
NewWatcher is used as a constructor.