task

package
v1.1.41 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abort added in v1.1.41

func Abort()

Abort aborts the process by sending a SIGABRT signal

func IsCancelled added in v0.1.9

func IsCancelled(ctx context.Context) bool

IsCancelled returns true if the context is cancelled, false otherwise, without blocking

func IsRunnable added in v1.1.40

func IsRunnable(obj interface{}) bool

IsRunnable returns true if the object implements the Runnable interface

func NewCancellableContext added in v0.1.10

func NewCancellableContext(timeout time.Duration) (ctx context.Context, cancel context.CancelFunc)

NewCancellableContext creates a cancellable context that handles interrupt events timeout is the time after which the process will exit if not terminated after the context is cancelled

func NewCancellableContextWithLog added in v1.1.23

func NewCancellableContextWithLog(maxCancelTimeout time.Duration, logLevel string, fields logrus.Fields) (ctx context.Context, cancel context.CancelFunc, log *logrus.Entry)

NewCancellableContextWithLog returns a cancellable context that handles interrupt signal. maxCancelTimeout is the timeout after which the process is exited if not already terminated logLevel : logrus log levels

func Sleep

func Sleep(ctx context.Context, duration time.Duration) (wasInterrupted bool)

Sleep is an interruptible time.Sleep version It returns true if it was interrupted by context cancellation, false otherwise

Types

type Runnable

type Runnable interface {
	Run(ctx context.Context, params ...interface{}) error
}

Runnable implements a Run function

type Runner added in v0.1.11

type Runner interface {
	Start(ctx context.Context, runnable Runnable, params ...interface{}) *Task
	WaitUntilAllDone()
}

type RunnerRepository added in v0.1.11

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

func NewRunnerRepository added in v0.1.11

func NewRunnerRepository() *RunnerRepository

func (*RunnerRepository) Start added in v0.1.11

func (repo *RunnerRepository) Start(ctx context.Context, runnable Runnable, params ...interface{}) *Task

func (*RunnerRepository) WaitUntilAllDone added in v0.1.11

func (repo *RunnerRepository) WaitUntilAllDone()

type SignalHandler

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

SignalHandler allows to cancel a cancellable context on os interrupt signal reception

func (*SignalHandler) Run

func (sh *SignalHandler) Run(ctx context.Context, params ...interface{}) error

Run takes a context and a context.CancelFunc as second parameter. if the third parameter is a time.Duration, the program forces exit after that timeout Wned the process receives an interrupt signal, the cancel function is called. Run is non blocking, it creates a goroutine to catch interrupt signal

type Task added in v0.1.11

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

Jump to

Keyboard shortcuts

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