asyncworker

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DuplicateWorkPolicyOverride = "override"
	DuplicateWorkPolicyDiscard  = "discard"
)
View Source
const WorkNameSeperator = "/"

WorkNameSeperator is used to assemble standard work-name and we have assumptions below, for work-name 'a/b/c': - 'a' and 'b' are specified identifiers for objects/triggers(etc.) on the action - 'c' is a general identifier for actions

Variables

This section is empty.

Functions

func EmitAsyncedMetrics added in v0.4.0

func EmitAsyncedMetrics(ctx context.Context, tags ...metrics.MetricTag) error

EmitAsyncedMetrics emit metrics through metricEmitter and metricName parsed from context

func EmitCustomizedAsyncedMetrics added in v0.4.1

func EmitCustomizedAsyncedMetrics(ctx context.Context, metricName string, metricValue int64, tags ...metrics.MetricTag) error

EmitAsyncedMetrics emit metrics through metricEmitter parsed from context and provided metricName & metricValue & tags

Types

type AsyncLimitedWorkers added in v0.5.4

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

func NewAsyncLimitedWorkers added in v0.5.4

func NewAsyncLimitedWorkers(name string, limit int, emitter metrics.MetricEmitter) *AsyncLimitedWorkers

func (*AsyncLimitedWorkers) AddWork added in v0.5.4

func (alw *AsyncLimitedWorkers) AddWork(work *Work, policy DuplicateWorkPolicy) error

func (*AsyncLimitedWorkers) Start added in v0.5.4

func (alw *AsyncLimitedWorkers) Start(stopCh <-chan struct{}) error

type AsyncWorkers

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

func NewAsyncWorkers

func NewAsyncWorkers(name string, emitter metrics.MetricEmitter) *AsyncWorkers

func (*AsyncWorkers) AddWork

func (aws *AsyncWorkers) AddWork(workName string, work *Work, policy DuplicateWorkPolicy) error

func (*AsyncWorkers) Start

func (aws *AsyncWorkers) Start(stopCh <-chan struct{}) error

func (*AsyncWorkers) WorkExists added in v0.4.1

func (aws *AsyncWorkers) WorkExists(workName string) bool

type DuplicateWorkPolicy added in v0.4.1

type DuplicateWorkPolicy string

type Work

type Work struct {
	Name string
	UID  types.UID
	// Fn is the function to handle the work,
	// its first param must be of type context.Context,
	// it's allowed to have any number of other parameters of any type,
	// and can have only one return value with error type,
	// its prototype likes func(ctx context.Context, i int, s string, ...) error
	Fn interface{}
	// Params are parameters of the fn
	Params []interface{}
	// DeliverAt is the time at which the work is delivered
	DeliveredAt time.Time
}

Work contains details to handle by workers

Jump to

Keyboard shortcuts

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