Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultWatchList = &WatchList{}
DefaultWatchList is the default instance of WatchList
Functions ¶
This section is empty.
Types ¶
type BasicParam ¶
type BasicParam struct { // ID of the related policy PolicyID int64 // Whether delete remote replicated images if local ones are deleted OnDeletion bool }
BasicParam contains the general parameters for all triggers
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is used to cache the enabled triggers with specified capacity. If exceed the capacity, cached items will be adjusted with the following rules: The item with least usage frequency will be replaced; If multiple items with same usage frequency, the oldest one will be replaced.
type CacheItem ¶
type CacheItem struct {
// contains filtered or unexported fields
}
CacheItem is the data stored in the cache. It contains trigger and heap item references.
type ImmediateParam ¶
type ImmediateParam struct { // Basic parameters BasicParam // Namepaces Namespaces []string }
ImmediateParam defines the parameter of immediate trigger
func (ImmediateParam) Parse ¶
func (ip ImmediateParam) Parse(param string) error
Parse is the implementation of same method in TriggerParam interface NOTES: No need to implement this method for 'Immediate' trigger as it does not have any parameters with json format.
type ImmediateTrigger ¶
type ImmediateTrigger struct {
// contains filtered or unexported fields
}
ImmediateTrigger will setup watcher at the image pushing action to fire replication event at pushing happening time.
func NewImmediateTrigger ¶
func NewImmediateTrigger(params ImmediateParam) *ImmediateTrigger
NewImmediateTrigger is constructor of ImmediateTrigger
func (*ImmediateTrigger) Kind ¶
func (st *ImmediateTrigger) Kind() string
Kind is the implementation of same method defined in Trigger interface
func (*ImmediateTrigger) Setup ¶
func (st *ImmediateTrigger) Setup() error
Setup is the implementation of same method defined in Trigger interface
func (*ImmediateTrigger) Unset ¶
func (st *ImmediateTrigger) Unset() error
Unset is the implementation of same method defined in Trigger interface
type Interface ¶
type Interface interface { // Kind indicates what type of the trigger is. Kind() string // Setup/enable the trigger; if failed, an error would be returned. Setup() error // Remove/disable the trigger; if failed, an error would be returned. Unset() error }
Interface is certain mechanism to know when fire the replication operation.
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item keeps more metadata of the triggers which are stored in the heap.
type Manager ¶
type Manager struct { }
Manager provides unified methods to manage the triggers of policies; Cache the enabled triggers, setup/unset the trigger based on the parameters with json format.
func NewManager ¶
NewManager is the constructor of trigger manager. capacity is the max number of trigger references manager can keep in memory
func (*Manager) SetupTrigger ¶
func (m *Manager) SetupTrigger(policy *models.ReplicationPolicy) error
SetupTrigger will create the new trigger based on the provided policy. If failed, an error will be returned.
func (*Manager) UnsetTrigger ¶
func (m *Manager) UnsetTrigger(policy *models.ReplicationPolicy) error
UnsetTrigger will disable the trigger which is not cached in the trigger cache.
type MetaQueue ¶
type MetaQueue []*Item
MetaQueue implements heap.Interface and holds items which are metadata of trigger
type Parameter ¶
type Parameter interface { // Decode parameter with json style to the owner struct // If failed, an error will be returned Parse(param string) error }
Parameter defines operation of doing initialization from parameter json text
type ScheduleParam ¶
type ScheduleParam struct { // Basic parameters BasicParam // Daily or weekly Type string // Optional, only used when type is 'weekly' Weekday int8 // The time offset with the UTC 00:00 in seconds Offtime int64 }
ScheduleParam defines the parameter of schedule trigger
func (ScheduleParam) Parse ¶
func (stp ScheduleParam) Parse(param string) error
Parse is the implementation of same method in TriggerParam interface
type ScheduleTrigger ¶
type ScheduleTrigger struct {
// contains filtered or unexported fields
}
ScheduleTrigger will schedule a alternate policy to provide 'daily' and 'weekly' trigger ways.
func NewScheduleTrigger ¶
func NewScheduleTrigger(params ScheduleParam) *ScheduleTrigger
NewScheduleTrigger is constructor of ScheduleTrigger
func (*ScheduleTrigger) Kind ¶
func (st *ScheduleTrigger) Kind() string
Kind is the implementation of same method defined in Trigger interface
func (*ScheduleTrigger) Setup ¶
func (st *ScheduleTrigger) Setup() error
Setup is the implementation of same method defined in Trigger interface
func (*ScheduleTrigger) Unset ¶
func (st *ScheduleTrigger) Unset() error
Unset is the implementation of same method defined in Trigger interface
type WatchItem ¶
type WatchItem struct { // ID of policy PolicyID int64 // Corresponding namespace Namespace string // For deletion event OnDeletion bool // For pushing event OnPush bool }
WatchItem keeps the related data for evaluation in WatchList.
type WatchList ¶
type WatchList struct{}
WatchList contains the items which should be evaluated for replication when image pushing or deleting happens.