Documentation ¶
Index ¶
- type CallbackFn
- type DoFn
- type Messenger
- func (m *Messenger) DoAsync(ctx context.Context, f DoFn) <-chan CallbackFn
- func (m *Messenger) DoBlocking(ctx context.Context, f DoFn) error
- func (m *Messenger) NowAndPeriodically(d time.Duration, f PeriodicFn, l *zerolog.Logger)
- func (m *Messenger) Periodically(d time.Duration, f PeriodicFn, l *zerolog.Logger)
- type PeriodicFn
- type Queue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackFn ¶
type CallbackFn func() error
CallbackFn is a callback function signature.
Since Go does not (yet) have generics, it allows encapsulating references to specific types in the caller.
type Messenger ¶
type Messenger struct {
// contains filtered or unexported fields
}
Messenger is held by clients who wish to execute something asynchronously.
func (*Messenger) DoAsync ¶
func (m *Messenger) DoAsync(ctx context.Context, f DoFn) <-chan CallbackFn
DoAsync executes the DoFn asynchronously, returning a channel which will have the callback function provided upon completion.
If the Messenger is already closed, a callback function returning an error is given.
func (*Messenger) DoBlocking ¶
DoBlocking executes the function in the Queue queue, blocks until a callback is received, then executes the callback and returns any errors.
func (*Messenger) NowAndPeriodically ¶
func (*Messenger) Periodically ¶
type PeriodicFn ¶
Periodic functions are ran intermittently, and errors returned from them result in logged error messages.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue gracefully facilitates fan-in message passing.
func (*Queue) Messenger ¶
Messenger obtains a new handle for clients to add work to the async queue.
If the Queue pool is already closed, nil is returned.