ger

package module
v0.0.0-...-02f7309 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: MIT Imports: 7 Imported by: 0

README

ger

Documentation

Overview

Package ger provides OTP-like supervisors.

Index

Constants

View Source
const (
	// ErrRestart means the task must be restarted.
	ErrRestart cError = iota + 1 // restart me

	// ErrAllCanceled means that all supervised tasks are canceled.
	ErrAllCanceled // all tasks are canceled

	// ErrStopped means that the current task is stopped.
	ErrStopped // task is stopped

	// ErrSupervisorIsNotRunning means that you trying to wait on non-running supervisor.
	ErrSupervisorIsNotRunning // supervisor is not running
)

Variables

This section is empty.

Functions

func AllForOne

func AllForOne(ctx context.Context, tasks ...Task) error

AllForOne runs provided tasks with all-for-one strategy. IF any of the tasks fails with ErrRestart, then all tasks will be restarted.

func OneForOne

func OneForOne(ctx context.Context, tasks ...Task) error

OneForOne runs provided tasks with one-for-one strategy. If any of the tasks fails, then only this task will be restarted.

func OneForRest

func OneForRest(ctx context.Context, tasks ...Task) error

OneForRest runst provided tasks with one-for-rest strategy. If any of the tasks fails, then all tasks, passed in the function after the failed one, will be restarted.

Types

type Task

type Task func(ctx context.Context) error

Task is a interruptable function. This package functions expects task to return following errors to sygnal task lifecycle:

  • ErrStopped
  • ErrRestart

func NoCtx

func NoCtx(t func() error) Task

NoCtx creates a task from an error returning function.

func NoError

func NoError(t func(ctx context.Context)) Task

NoError creates a task from a context consuming function.

func Proc

func Proc(t func()) Task

Proc creates a task from a procedure-like function.

Jump to

Keyboard shortcuts

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