Documentation
¶
Overview ¶
Package converger is a facility for reporting the converged state.
Index ¶
- type Coordinator
- func (obj *Coordinator) AddStateFn(name string, stateFn func(bool) error) error
- func (obj *Coordinator) IsConverged() bool
- func (obj *Coordinator) Pause() error
- func (obj *Coordinator) Ready()
- func (obj *Coordinator) Register() *UID
- func (obj *Coordinator) RemoveStateFn(name string) error
- func (obj *Coordinator) Resume()
- func (obj *Coordinator) Run(startPaused bool)
- func (obj *Coordinator) Shutdown()
- func (obj *Coordinator) Status() map[*UID]bool
- func (obj *Coordinator) Timeout() int
- func (obj *Coordinator) Unregister(uid *UID)
- type UID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator is the central converger engine.
func (*Coordinator) AddStateFn ¶
func (obj *Coordinator) AddStateFn(name string, stateFn func(bool) error) error
AddStateFn adds a state function to be run on change of converged state.
func (*Coordinator) IsConverged ¶
func (obj *Coordinator) IsConverged() bool
IsConverged returns true if *every* registered uid has converged. If there are no registered UID's, then this will return true.
func (*Coordinator) Pause ¶
func (obj *Coordinator) Pause() error
Pause pauses the coordinator. It should not be called on an already paused coordinator. It will block until the coordinator pauses with an acknowledgment, or until an exit is requested. If the latter happens it will error. It is NOT thread-safe with the Resume() method so only call either one at a time.
func (*Coordinator) Ready ¶
func (obj *Coordinator) Ready()
Ready blocks until the Run loop has started up. This is useful so that we don't run Shutdown before we've even started up properly.
func (*Coordinator) Register ¶
func (obj *Coordinator) Register() *UID
Register creates a new UID which can be used to report converged state. You must Unregister each UID before Shutdown will be able to finish running.
func (*Coordinator) RemoveStateFn ¶
func (obj *Coordinator) RemoveStateFn(name string) error
RemoveStateFn removes a state function from running on change of converged state.
func (*Coordinator) Resume ¶
func (obj *Coordinator) Resume()
Resume unpauses the coordinator. It can be safely called on a brand-new coordinator that has just started running without incident. It is NOT thread-safe with the Pause() method, so only call either one at a time.
func (*Coordinator) Run ¶
func (obj *Coordinator) Run(startPaused bool)
Run starts the main loop for the converger coordinator. It is commonly run from a go routine. It blocks until the Shutdown method is run to close it. NOTE: when we have very short timeouts, if we start before all the resources have joined the map, then it might appear as if we converged before we did!
func (*Coordinator) Shutdown ¶
func (obj *Coordinator) Shutdown()
Shutdown sends a signal to the Run loop that it should exit. This blocks until it does.
func (*Coordinator) Status ¶
func (obj *Coordinator) Status() map[*UID]bool
Status returns a map of the converged status of each UID.
func (*Coordinator) Timeout ¶
func (obj *Coordinator) Timeout() int
Timeout returns the timeout in seconds that converger was created with. This is useful to avoid passing in the timeout value separately when you're already passing in the Coordinator struct.
func (*Coordinator) Unregister ¶
func (obj *Coordinator) Unregister(uid *UID)
Unregister removes the UID from the converger coordinator. If you supply an invalid or unregistered uid to this function, it will panic. An unregistered UID is no longer part of the convergence checking.
type UID ¶
type UID struct {
// contains filtered or unexported fields
}
UID represents one of the probes for the converger coordinator. It is created by calling the Register method of the Coordinator struct. It should be freed after use with Unregister.
func (*UID) ConvergedTimer ¶
ConvergedTimer adds a timeout to a select call and blocks until then. TODO: this means we could eventually have per resource converged timeouts
func (*UID) IsConverged ¶
IsConverged reports whether this UID is converged or not.
func (*UID) SetConverged ¶
SetConverged sets the convergence state of this UID. This is used by the running timer if one is started. The timer will overwrite any value set by this method.
func (*UID) StartTimer ¶
StartTimer runs a timer that sets us as converged on timeout. It also returns a handle to the StopTimer function which should be run before exit.
func (*UID) Unregister ¶
func (obj *UID) Unregister()
Unregister removes this UID from the converger coordinator. An unregistered UID is no longer part of the convergence checking.