Documentation ¶
Index ¶
- Variables
- func All(ctx context.Context, funcs ...Func) error
- func CancelOnFirstError(ctx context.Context, funcs ...Func) error
- func CancelOnFirstErrorWait(ctx context.Context, funcs ...Func) error
- func CancelOnFirstFinish(ctx context.Context, funcs ...Func) error
- func CancelOnFirstFinishWait(ctx context.Context, funcs ...Func) error
- func NewErrorList(errs ...error) error
- func NewErrorListByChan(ch <-chan error) error
- func NewMetrics(registerer prometheus.Registerer, namespace string, subsystem string, fn Func) func(ctx context.Context) error
- func Run(ctx context.Context, funcs ...Func) <-chan error
- func Sequential(ctx context.Context, funcs ...Func) (err error)
- type AddFire
- type BackgroundRunner
- type Backoff
- type ConcurrentRunner
- type Done
- type Fire
- type Func
- func CatchPanic(fn Func) Func
- func Delayed(fn Func, duration time.Duration) Func
- func LogErrors(fn Func) Func
- func Retry(backoff Backoff, fn Func) Func
- func RetryWaiter(backoff Backoff, waiter Waiter, fn Func) Func
- func SkipErrors(fn Func) Func
- func SkipErrorsAndReport(fn Func, hasCaptureErrorAndWait HasCaptureErrorAndWait, tags map[string]string) Func
- func Triggered(fn Func, trigger <-chan struct{}) Func
- type HasCaptureErrorAndWait
- type MultiTrigger
- type ParallelSkipper
- type Runnable
- type Trigger
- type Waiter
- type WaiterFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultWaiter = NewWaiter()
Functions ¶
func CancelOnFirstError ¶
CancelOnFirstError executes all given functions. When a function encounters an error all remaining functions will be canceled.
func CancelOnFirstErrorWait ¶
CancelOnFirstErrorWait executes all given functions. When a function encounters an error all remaining functions will be canceled.
func CancelOnFirstFinish ¶
CancelOnFirstFinish executes all given functions. After the first function finishes, any remaining functions will be canceled.
func CancelOnFirstFinishWait ¶
CancelOnFirstFinishWait executes all given functions. After the first function finishes, any remaining functions will be canceled.
func NewErrorList ¶
NewErrorList create a ErrorList with the given errors.
func NewErrorListByChan ¶
NewErrorListByChan create a ErrorList with the given error channel.
func NewMetrics ¶
func NewMetrics( registerer prometheus.Registerer, namespace string, subsystem string, fn Func, ) func(ctx context.Context) error
NewMetrics create prometheus metrics for the given Func.
Types ¶
type AddFire ¶
type AddFire interface { // Add returns a new fire for trigger Add() Fire }
AddFire allow add a new trigger
type BackgroundRunner ¶ added in v1.4.0
func NewBackgroundRunner ¶ added in v1.4.0
func NewBackgroundRunner(ctx context.Context) BackgroundRunner
type Backoff ¶
type Backoff struct { // Initial delay to wait on retry Delay time.Duration `json:"delay"` // Factor initial delay is multipled on retries Factor float64 `json:"factor"` // Retries how often to retry Retries int `json:"retries"` // IsRetryAble allow the check if error is retryable IsRetryAble func(error) bool `json:"-"` }
Backoff settings for retry
type ConcurrentRunner ¶
type ConcurrentRunner interface { Add(ctx context.Context, fn Func) Run(ctx context.Context) error io.Closer }
ConcurrentRunner allow run N tasks concurrent
func NewConcurrentRunner ¶
func NewConcurrentRunner(maxConcurrent int) ConcurrentRunner
NewConcurrentRunner returns ConcurrentRunner with the given concurrent limit
type Done ¶
type Done interface {
// Done chan gets a element if trigger was fired
Done() <-chan struct{}
}
Done check for a trigger
type Fire ¶
type Fire interface {
// Fire trigger als Dons ch to get a element
Fire()
}
Fire a trigger
type Func ¶
Func interface for all run utils.
func RetryWaiter ¶ added in v1.5.0
RetryWaiter allow use of custom Waiter
func SkipErrors ¶
SkipErrors runs the given Func and returns always nil.
func SkipErrorsAndReport ¶
func SkipErrorsAndReport( fn Func, hasCaptureErrorAndWait HasCaptureErrorAndWait, tags map[string]string, ) Func
SkipErrorsAndReport runs the given Func, report errors to sentry and returns always nil.
type HasCaptureErrorAndWait ¶
type HasCaptureErrorAndWait interface {
CaptureErrorAndWait(err error, tags map[string]string, interfaces ...raven.Interface) string
}
HasCaptureErrorAndWait is compatibel with sentry.Client
type MultiTrigger ¶
MultiTrigger combines Done and AddFire
type ParallelSkipper ¶
ParallelSkipper prevent execution of the given function at the same time.
func NewParallelSkipper ¶
func NewParallelSkipper() ParallelSkipper
NewParallelSkipper return a new instance of ParallelSkipper.