task

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundTask

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

BackgroundTask a process that works in configured iteration to execute job handling in the background

func NewBackgroundTask

func NewBackgroundTask(TaskName string, GracefulShutdownCallback func(), opts ...Option) *BackgroundTask

NewBackgroundTask a new instance

func (*BackgroundTask) GetName

func (t *BackgroundTask) GetName() string

GetName of the task

func (*BackgroundTask) GetSeverity

func (t *BackgroundTask) GetSeverity() background.ProcessSeverity

GetSeverity of the task

func (*BackgroundTask) IsPendingToShutdown

func (t *BackgroundTask) IsPendingToShutdown() bool

IsPendingToShutdown a worker

func (*BackgroundTask) IsProcessingJob

func (t *BackgroundTask) IsProcessingJob() bool

IsProcessingJob in worker cycle handling

func (*BackgroundTask) OnStart

func (t *BackgroundTask) OnStart(ctx context.Context) error

OnStart event to be called when main loop will be started

func (*BackgroundTask) OnStop

func (t *BackgroundTask) OnStop(ctx context.Context) error

OnStop event to be called when main loop will be started

type Option

type Option func(c *BackgroundTask)

Option for task execution, timeouts, handler, tick interval etc.

func SetExecInterval

func SetExecInterval(interval time.Duration) Option

SetExecInterval how often task must be executed

func SetHandler

func SetHandler(handler func() error) Option

SetHandler of the task (logic that will be performed)

func SetProcessingTimeout

func SetProcessingTimeout(interval time.Duration) Option

SetProcessingTimeout for task handling

func SetSeverity

func SetSeverity(s background.ProcessSeverity) Option

SetSeverity of how important for the application to run this task

Jump to

Keyboard shortcuts

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