Documentation
¶
Index ¶
- func ContextValues(parent context.Context) context.Context
- func Manager(options *ManagerOptions) *managerBuilder
- func Periodic(opts PeriodicOptions, runnable Runnable) *periodic
- func Run(runner Runnable)
- func RunFunc(fn RunnableFunc)
- func RunGroup(runners ...Runnable)
- func SetLogger(l Logger)
- type CloserOptions
- type Logger
- type ManagerOptions
- type PanicError
- type PeriodicOptions
- type RecoverRunner
- type RestartOption
- type Runnable
- func Closer(object io.Closer, opts *CloserOptions) Runnable
- func Func(fn RunnableFunc) Runnable
- func HTTPServer(server ServerWithShutdown) Runnable
- func Recover(runnable Runnable) Runnable
- func Restart(runnable Runnable, opts ...RestartOption) Runnable
- func Signal(runnable Runnable, signals ...os.Signal) Runnable
- type RunnableError
- type RunnableFunc
- type ServerWithShutdown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextValues ¶ added in v0.10.0
ContextValues returns a new context.Context with the values from the parent, without propagating the cancellation. Useful when you want to protect an operation that should not be cancelled. Often used with context.WithTimeout() or context.WithDeadline().
func Manager ¶ added in v0.4.0
func Manager(options *ManagerOptions) *managerBuilder
Manager returns a runnable that execute runnables in go routines. Runnables can declare a dependency on another runnable. Dependencies are started first and stopped last.
func Periodic ¶ added in v0.1.0
func Periodic(opts PeriodicOptions, runnable Runnable) *periodic
Periodic returns a runnable that will periodically run the runnable passed in argument.
func Run ¶ added in v0.4.0
func Run(runner Runnable)
Run runs a single runnable, and listen to SIGTERM/SIGINT
func RunFunc ¶ added in v0.5.0
func RunFunc(fn RunnableFunc)
RunFunc runs a runnable function, and listen to SIGTERM/SIGINT
Types ¶
type CloserOptions ¶ added in v0.4.0
CloserOptions configures the behavior of a Closer runnable.
type ManagerOptions ¶ added in v0.4.0
ManagerOptions configures the behavior of a Manager.
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
func (*PanicError) Error ¶
func (e *PanicError) Error() string
func (*PanicError) Unwrap ¶
func (e *PanicError) Unwrap() error
type PeriodicOptions ¶ added in v0.1.0
PeriodicOptions configures the behavior of a Periodic runnable.
type RecoverRunner ¶
type RecoverRunner struct {
// contains filtered or unexported fields
}
type RestartOption ¶ added in v0.6.0
type RestartOption func(*restartConfig)
func RestartCrashDelayFn ¶ added in v0.6.0
func RestartCrashDelayFn(fn func(int) time.Duration) RestartOption
RestartCrashDelayFn sets the function that determine the backoff delay after a crash.
func RestartCrashLimit ¶ added in v0.6.0
func RestartCrashLimit(times int) RestartOption
RestartCrashLimit sets a limit on the number restart after a crash.
func RestartDelay ¶ added in v0.6.0
func RestartDelay(times time.Duration) RestartOption
RestartDelay sets the time waited before restarting the runnable after a successful execution.
func RestartLimit ¶ added in v0.6.0
func RestartLimit(times int) RestartOption
RestartLimit sets a limit on the number of restart after successful execution.
type Runnable ¶
Runnable is the contract for anything that runs with a Go context, respects the concellation contract, and expects the caller to handle errors.
func Closer ¶ added in v0.4.0
func Closer(object io.Closer, opts *CloserOptions) Runnable
Closer returns a runnable that will close what is passed in argument.
func Func ¶ added in v0.5.0
func Func(fn RunnableFunc) Runnable
func HTTPServer ¶ added in v0.3.0
func HTTPServer(server ServerWithShutdown) Runnable
HTTPServer returns a runnable that runs a ServerWithShutdown (like *http.Server).
func Recover ¶
Recover returns a runnable that recovers when a runnable panics and return an error to represent this panic.
func Restart ¶
func Restart(runnable Runnable, opts ...RestartOption) Runnable
Restart returns a runnable that runs a runnable and restarts it when it fails, with some conditions.
type RunnableError ¶ added in v0.4.0
type RunnableError struct {
// contains filtered or unexported fields
}
func (*RunnableError) Error ¶ added in v0.4.0
func (e *RunnableError) Error() string
func (*RunnableError) Unwrap ¶ added in v0.4.0
func (e *RunnableError) Unwrap() error