Documentation
¶
Overview ¶
Package poller is a dedicated task that handles regular polling actions.
It does not start a loop, just handles the ticker and restart channels. You will have to get those with Start and GetRestart and use them in a loop. This job is generally done by the dock.StartApplet action, so you better use it or copy and extend it to your needs.
Display and user information related to the result of the check must be made using some return callback at the end of the check task.
Display and user information related to the check action itself, like displaying an activity emblem during the check, should be done using the PreCheck and PostCheck callbacks.
The goal is to keep each part separated and dedicated to one task. If we split each role and keep it agnostic of others, we can have easier debuging and evolution of our applets:
- The poller send timing events.
- The check task pull its data and send the results on a OnResult callback.
- The OnResult callback sorts the data and dispatch it to the renderers or alert interfaces.
- Renderer interfaces displays to the user informations or alerts the way he prefers.
Index ¶
- func NewNil(add func(call func()) cdtype.AppPoller) cdtype.AppPoller
- type Poller
- func (poller *Poller) Action()
- func (poller *Poller) Add(callCheck func()) cdtype.AppPoller
- func (poller *Poller) Exists() bool
- func (poller *Poller) GetInterval() int
- func (poller *Poller) Plop() bool
- func (poller *Poller) Restart()
- func (poller *Poller) SetChanRestart(c chan string, name string)
- func (poller *Poller) SetInterval(delay ...int) int
- func (poller *Poller) SetPostCheck(onFinished func())
- func (poller *Poller) SetPreCheck(onStarted func())
- func (poller *Poller) Start()
- func (poller *Poller) Stop()
- func (poller *Poller) Wait() <-chan time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller is a dedicated task that handles regular polling actions.
func (*Poller) Action ¶
func (poller *Poller) Action()
Action launch the check action. Triggers PreCheck, OnCheck and PostCheck callbacks in this order.
func (*Poller) GetInterval ¶
GetInterval return the configured delay for the poller.
func (*Poller) Plop ¶
Plop increase the counter and launch the action if it reached the interval. The counter is also reset if the action is launched. Safe to use on nil poller.
func (*Poller) Restart ¶
func (poller *Poller) Restart()
Restart resets the counter and launch Action in a goroutine. Safe to use on nil poller.
func (*Poller) SetChanRestart ¶
SetChanRestart set settings for the poller restart event.
func (*Poller) SetInterval ¶
SetInterval sets the polling interval time, in seconds. You can add a default value as a second argument to be sure you will have a valid value (> 0).
func (*Poller) SetPostCheck ¶
func (poller *Poller) SetPostCheck(onFinished func())
SetPostCheck callback actions to launch after the polling job.
func (*Poller) SetPreCheck ¶
func (poller *Poller) SetPreCheck(onStarted func())
SetPreCheck callback actions to launch before the polling job.