Documentation
¶
Index ¶
- Constants
- type Interval
- func (i *Interval) Action() func() error
- func (i *Interval) Delay() time.Duration
- func (i *Interval) Errors() chan error
- func (i Interval) Interval() time.Duration
- func (i *Interval) Latch() *Latch
- func (i *Interval) Start()
- func (i *Interval) Stop()
- func (i *Interval) WithAction(action func() error) *Interval
- func (i *Interval) WithDelay(d time.Duration) *Interval
- func (i *Interval) WithErrors(errors chan error) *Interval
- type Latch
- func (l *Latch) IsRunning() bool
- func (l *Latch) IsStarting() bool
- func (l *Latch) IsStopped() bool
- func (l *Latch) IsStopping() bool
- func (l *Latch) NotifyStarted() <-chan struct{}
- func (l *Latch) NotifyStop() <-chan struct{}
- func (l *Latch) NotifyStopped() <-chan struct{}
- func (l *Latch) Started()
- func (l *Latch) Starting()
- func (l *Latch) Stop()
- func (l *Latch) Stopped()
- type QueueWorker
- func (qw *QueueWorker) Enqueue(obj interface{})
- func (qw *QueueWorker) ErrorCollector() chan error
- func (qw *QueueWorker) Latch() *Latch
- func (qw *QueueWorker) MaxWork() int
- func (qw *QueueWorker) Start()
- func (qw *QueueWorker) Stop()
- func (qw *QueueWorker) WithErrorCollector(errors chan error) *QueueWorker
- func (qw *QueueWorker) WithMaxWork(maxWork int) *QueueWorker
Constants ¶
const (
// DefaultQueueWorkerMaxWork is the maximum number of work items before queueing blocks.
DefaultQueueWorkerMaxWork = 1 << 10
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
Interval is a managed goroutine that does things.
func NewInterval ¶
NewInterval returns a new worker that runs an action on an interval.
func (*Interval) WithAction ¶
WithAction sets the interval action.
func (*Interval) WithErrors ¶
WithErrors returns the error channel.
type Latch ¶
type Latch struct {
// contains filtered or unexported fields
}
Latch is a helper to coordinate killing goroutines. The lifecycle is generally as follows. 0 - stopped 1 - signal started 2 - running / started N-2 - signal stop N-1 - stopping goto 0
func (*Latch) IsStarting ¶
IsStarting indicates the latch is waiting to be scheduled.
func (*Latch) IsStopping ¶
IsStopping returns if the latch is waiting to finish stopping.
func (*Latch) NotifyStarted ¶
func (l *Latch) NotifyStarted() <-chan struct{}
NotifyStarted returns the started signal. It is used to coordinate the transition from starting -> started.
func (*Latch) NotifyStop ¶
func (l *Latch) NotifyStop() <-chan struct{}
NotifyStop returns the should stop signal. It is used to trigger the transition from running -> stopping -> stopped.
func (*Latch) NotifyStopped ¶
func (l *Latch) NotifyStopped() <-chan struct{}
NotifyStopped returns the stopped signal. It is used to coordinate the transition from stopping -> stopped.
func (*Latch) Started ¶
func (l *Latch) Started()
Started signals that the latch is started and has entered the `IsRunning` state.
func (*Latch) Starting ¶
func (l *Latch) Starting()
Starting signals the latch is starting. This is typically done before you kick off a goroutine.
type QueueWorker ¶
type QueueWorker struct {
// contains filtered or unexported fields
}
QueueWorker is a worker that is pushed work over a channel.
func NewQueue ¶
func NewQueue(action func(interface{}) error) *QueueWorker
NewQueue returns a new queue worker.
func (*QueueWorker) Enqueue ¶
func (qw *QueueWorker) Enqueue(obj interface{})
Enqueue adds an item to the work queue.
func (*QueueWorker) ErrorCollector ¶
func (qw *QueueWorker) ErrorCollector() chan error
ErrorCollector returns a channel to read action errors from.
func (*QueueWorker) MaxWork ¶
func (qw *QueueWorker) MaxWork() int
MaxWork returns the maximum work.
func (*QueueWorker) WithErrorCollector ¶
func (qw *QueueWorker) WithErrorCollector(errors chan error) *QueueWorker
WithErrorCollector returns the error channel.
func (*QueueWorker) WithMaxWork ¶
func (qw *QueueWorker) WithMaxWork(maxWork int) *QueueWorker
WithMaxWork sets the worker max work.