worker

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 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 WithID added in v0.5.3

func WithID(id string) TickerOption

WithID sets worker id

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