Documentation
¶
Index ¶
- Constants
- func InitGlobalSupervisor(super *Supervisor)
- func ObjectKinds() []string
- func Register(o Object)
- type Controller
- type MetaSpec
- type Object
- type ObjectCategory
- type Pipeline
- type RunningCategory
- type RunningObject
- type Spec
- type Status
- type Supervisor
- func (s *Supervisor) Close(wg *sync.WaitGroup)
- func (s *Supervisor) Cluster() cluster.Cluster
- func (s *Supervisor) FirstHandleDone() chan struct{}
- func (s *Supervisor) GetRunningObject(name string, category ObjectCategory) (ro *RunningObject, exists bool)
- func (s *Supervisor) Options() *option.Options
- func (s *Supervisor) WalkRunningObjects(walkFn WalkFunc, category ObjectCategory)
- type TrafficGate
- type WalkFunc
Constants ¶
const ( // CategoryAll is just for filter of search. CategoryAll ObjectCategory = "" // CategorySystemController is the category of system controller. CategorySystemController = "SystemController" // CategoryBusinessController is the category of business controller. CategoryBusinessController = "BusinessController" // CategoryPipeline is the category of pipeline. CategoryPipeline = "Pipeline" // CategoryTrafficGate is the category of traffic gate. CategoryTrafficGate = "TrafficGate" )
Variables ¶
This section is empty.
Functions ¶
func InitGlobalSupervisor ¶
func InitGlobalSupervisor(super *Supervisor)
InitGlobalSupervisor initializes global supervisor. FIXME: Prune Global stuff after sending super to filters.
Types ¶
type Controller ¶
type Controller interface { Object }
Controller is the object in category of Controller.
type MetaSpec ¶
type MetaSpec struct { Name string `yaml:"name" jsonschema:"required,format=urlname"` Kind string `yaml:"kind" jsonschema:"required"` }
MetaSpec is metadata for all specs.
type Object ¶
type Object interface { // Category returns the object category of itself. Category() ObjectCategory // Kind returns the unique kind name to represent itself. Kind() string // DefaultSpec returns the default spec. // It must return a pointer to point a struct. DefaultSpec() interface{} // Init initializes the Obejct. Init(superSpec *Spec, super *Supervisor) // Inherit also initializes the Object. // But it needs to handle the lifecycle of the previous generation. // So it's own responsibility for the object to inherit and clean the previous generation stuff. // The supervisor won't call Close for the previous generation. Inherit(superSpec *Spec, previousGeneration Object, super *Supervisor) // Status returns its runtime status. Status() *Status // Close closes itself. It is called by deleting. // Supervisor won't call Close for previous generation in Update. Close() }
Object is the common interface for all objects whose lifecycle supervisor handles.
type ObjectCategory ¶
type ObjectCategory string
ObjectCategory is the type to classify all objects.
type RunningCategory ¶
type RunningCategory struct {
// contains filtered or unexported fields
}
RunningCategory is the bucket to gather running objects in the same category.
type RunningObject ¶
type RunningObject struct {
// contains filtered or unexported fields
}
RunningObject is the running object.
func (*RunningObject) Instance ¶
func (ro *RunningObject) Instance() Object
Instance returns the instance of the object.
func (*RunningObject) Spec ¶
func (ro *RunningObject) Spec() *Spec
Spec returns the spec of the object.
type Spec ¶
type Spec struct {
// contains filtered or unexported fields
}
Spec is the universal spec for all objects.
func (*Spec) ObjectSpec ¶
func (s *Spec) ObjectSpec() interface{}
ObjectSpec returns the object spec.
func (*Spec) YAMLConfig ¶
YAMLConfig returns the config in yaml format.
type Status ¶
type Status struct { // If the ObjectStatus contains field `timestamp`, // it will be covered by the top-level Timestamp here. ObjectStatus interface{} // Timestamp is the global unix timestamp, the object // needs not to set it on its own. Timestamp int64 }
Status is the universal status for all objects.
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor manages all objects.
var Global *Supervisor
Global is the global supervisor.
func MustNew ¶
func MustNew(opt *option.Options, cls cluster.Cluster) *Supervisor
MustNew creates a Supervisor.
func (*Supervisor) Cluster ¶
func (s *Supervisor) Cluster() cluster.Cluster
Cluster return the cluster applied to supervisor.
func (*Supervisor) FirstHandleDone ¶
func (s *Supervisor) FirstHandleDone() chan struct{}
FirstHandleDone returns the firstHandleDone channel, which will be closed after creating all objects at first time.
func (*Supervisor) GetRunningObject ¶
func (s *Supervisor) GetRunningObject(name string, category ObjectCategory) (ro *RunningObject, exists bool)
GetRunningObject returns the running object with the existing flag. If the category is empty string, GetRunningObject will try to find the running object in every category.
func (*Supervisor) Options ¶
func (s *Supervisor) Options() *option.Options
Options returns the options applied to supervisor.
func (*Supervisor) WalkRunningObjects ¶
func (s *Supervisor) WalkRunningObjects(walkFn WalkFunc, category ObjectCategory)
WalkRunningObjects walks every running object until walkFn returns false.
type TrafficGate ¶
type TrafficGate interface { Object }
TrafficGate is the object in category of TrafficGate.
type WalkFunc ¶
type WalkFunc func(runningObject *RunningObject) bool
WalkFunc is the type of the function called for each running object visited by WalkRunningObjects.