worker

package
v0.0.0-...-2d73068 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LockOwner the contant to specify the name of the lock owner in the context
	LockOwner string = "lock_owner"
)

Variables

This section is empty.

Functions

func GetLockOwner

func GetLockOwner(ctx context.Context) string

GetLockOwner return the owner to use when acquiring a lock. returns empty string if the given context did not contain any *string* value for the `lock_owner` key.

Types

type BaseWorker

type BaseWorker struct {
	Ctx   context.Context
	App   application.Application
	Name  string // name of the lock (eg: "user_deactivation_notification"), to use when claiming a lock
	Owner string // owner of the lock (eg, the name of the Pod), to use when claiming a lock
	Do    func() // the function to run the business code at each cycle of the worker
	Opts  []pglock.ClientOption
	// contains filtered or unexported fields
}

BaseWorker the base worker

func (*BaseWorker) IsStopped

func (w *BaseWorker) IsStopped() bool

IsStopped return true if the worker is not in a `running` state, false otherwise.

func (*BaseWorker) Start

func (w *BaseWorker) Start(freq time.Duration)

Start starts the worker with the given timer

func (*BaseWorker) Stop

func (w *BaseWorker) Stop()

Stop stops the worker

type Worker

type Worker interface {
	Start(freq time.Duration)
	Stop()
	IsStopped() bool
}

Worker the interface for the workers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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