Documentation ¶
Index ¶
- Variables
- func StopWhenError[I any](ctx context.Context, in I, err error) error
- type AfterFunc
- type BeforeFunc
- type Out
- type Runner
- func (r *Runner[I, O]) AfterFunc(f AfterFunc[I, O]) *Runner[I, O]
- func (r *Runner[I, O]) BeforeFunc(f BeforeFunc[I, O]) *Runner[I, O]
- func (r *Runner[I, O]) Fail() bool
- func (r *Runner[I, O]) InFrom(w ...Out[I]) *Runner[I, O]
- func (r *Runner[I, O]) Metrics() (send, ok, fail uint32)
- func (r *Runner[I, O]) Send(in I) error
- func (r *Runner[I, O]) SetDeadline(t time.Time) *Runner[I, O]
- func (r *Runner[I, O]) SetOut(c chan O) error
- func (r *Runner[I, O]) SetWorkerTimeout(duration time.Duration) *Runner[I, O]
- func (r *Runner[I, O]) Start() error
- func (r *Runner[I, O]) Stop() *Runner[I, O]
- func (r *Runner[I, O]) Wait() *Runner[I, O]
- type WorkFunc
Constants ¶
This section is empty.
Variables ¶
var ErrInputClosed = errors.New("input closed")
var ErrOutAlready = errors.New("out already set")
Functions ¶
Types ¶
type Runner ¶
type Runner[I, O any] struct { // contains filtered or unexported fields }
func NewRunner ¶
func NewRunner[I, O any](ctx context.Context, w WorkFunc[I, O], maxWorkers, buffer int64) *Runner[I, O]
NewRunner Factory function for a new Runner. The Runner will handle running the workers logic.
func (*Runner[I, O]) AfterFunc ¶
AfterFunc Function to be run after worker has stopped. It can be used for logging and error management. input can be retreive with context value:
ctx.Value(workers.InputKey{})
⚠️ If an error is returned it stop Runner execution.
func (*Runner[I, O]) BeforeFunc ¶
func (r *Runner[I, O]) BeforeFunc(f BeforeFunc[I, O]) *Runner[I, O]
BeforeFunc Function to be run before worker starts processing.
func (*Runner[I, O]) Send ¶
Send Send an object to the worker for processing if context is not Done.
func (*Runner[I, O]) SetDeadline ¶
SetDeadline allows a time to be set when the Runner should stop. ⚠️ Should only be called before Start
func (*Runner[I, O]) SetOut ¶
SetOut Allows the setting of a workers out channel, if not already set.
func (*Runner[I, O]) SetWorkerTimeout ¶
SetWorkerTimeout allows a time duration to be set when the workers should stop. ⚠️ Should only be called before Start