Documentation ¶
Index ¶
- func Abort()
- func IsCancelled(ctx context.Context) bool
- func IsRunnable(obj interface{}) bool
- func NewCancellableContext(timeout time.Duration) (ctx context.Context, cancel context.CancelFunc)
- func NewCancellableContextWithLog(maxCancelTimeout time.Duration, logLevel string, fields logrus.Fields) (ctx context.Context, cancel context.CancelFunc, log *logrus.Entry)
- func Sleep(ctx context.Context, duration time.Duration) (wasInterrupted bool)
- type Runnable
- type Runner
- type RunnerRepository
- type SignalHandler
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCancelled ¶ added in v0.1.9
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
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
Types ¶
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