Documentation
¶
Index ¶
- type FN
- type PermanentError
- type Routine
- func (r *Routine) Close()
- func (r *Routine) HealthCheck(ctx context.Context) error
- func (r *Routine) OnPermanentError(fn func(error))
- func (r *Routine) Start(ctx context.Context) *Routine
- func (r *Routine) WithConstantBackOff(seconds int) *Routine
- func (r *Routine) WithLogger(logger *slog.Logger) *Routine
- func (r *Routine) WithMaxConsecutiveErrors(n int) *Routine
- func (r *Routine) WithMetrics() *Routine
- func (r *Routine) WithSignal(channels ...<-chan struct{}) *Routine
- func (r *Routine) WithStartupJitter(d time.Duration) *Routine
- func (r *Routine) WithTicker(duration time.Duration) *Routine
- func (r *Routine) WithTimeout(d time.Duration) *Routine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PermanentError ¶
type PermanentError struct{ Err error }
PermanentError is a permanent error that will cause a routine to immediately panic.
func NewPermanentError ¶
func NewPermanentError(message string, args ...any) *PermanentError
NewPermanentError instantiates and returns a new permanent error.
func (*PermanentError) Error ¶
func (e *PermanentError) Error() string
Error immplements the error interface.
func (*PermanentError) Is ¶
func (e *PermanentError) Is(err error) bool
Is is used used by errors.Is() to match correctly.
type Routine ¶
type Routine struct {
// contains filtered or unexported fields
}
Routine is a wrapper around some function that needs to be executed in a loop in a go routine.
func (*Routine) Close ¶
func (r *Routine) Close()
Close closes this routine. It is a blocking call guaranteeing that the routine has exited its loop by the time it returns.
func (*Routine) HealthCheck ¶
Checks the health of this routine.
func (*Routine) OnPermanentError ¶
func (*Routine) WithConstantBackOff ¶
WithConstantBackOff adds a constant backoff everytime a non permanent error is encountered.
func (*Routine) WithMaxConsecutiveErrors ¶
WithMaxConsecutiveErrors sets a max consecutive error threshold which, if exceeded, kills the routine.
func (*Routine) WithSignal ¶
WithSignal allows a signal to trigger a run of the routine function.
func (*Routine) WithStartupJitter ¶
WithStartupJitter adds a random delay before each execution to spread load.