worker

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ticker

type Ticker struct {
	// contains filtered or unexported fields
}

Ticker is a worker that runs periodically

func NewTicker

func NewTicker(logger log.Logger, opts ...TickerOption) *Ticker

NewTicker creates a new worker that does an action periodically

func (*Ticker) GetID

func (wt *Ticker) GetID() string

GetID fetch identifier of a worker

func (*Ticker) Run

func (wt *Ticker) Run(ctx context.Context, cancelChan chan struct{}, handlerFn func(ctx context.Context, runningAt time.Time) error)

Run starts worker that handle a task periodically

type TickerOption

type TickerOption func(*Ticker)

TickerOption is an option to customize worker ticker creation

func WithTickerDuration

func WithTickerDuration(pollDuration time.Duration) TickerOption

WithTickerDuration sets created handler with the specified poll duration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL