keyed

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constructor

type Constructor func(key string) Routine

Constructor returns a function to start for the given key. If nil is returned, skips starting that routine.

type Keyed

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

Keyed manages a set of goroutines with associated Keys.

func NewKeyed

func NewKeyed(ctorCb Constructor) *Keyed

NewKeyed constructs a new Keyed execution manager. Note: routines won't start until SetContext is called.

func (*Keyed) SetContext

func (k *Keyed) SetContext(ctx context.Context, restart bool)

SetContext updates the root context, restarting all running routines. if restart is true, all errored routines also restart

func (*Keyed) SyncKeys

func (k *Keyed) SyncKeys(keys []string, restart bool)

SyncKeys synchronizes the list of running routines with the given list. If restart=true, restarts any failed routines in the list.

type Routine

type Routine func(ctx context.Context) error

Routine is a function called as a goroutine. If nil is returned, exits cleanly permanently. If an error is returned, can be restarted later.

Jump to

Keyboard shortcuts

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