runman

package
v0.0.0-...-93b1e75 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package runman provides manager that can run a bunch of Runner interface implementations concurrently. When one of the runners finishes, all other ones will be canceled via context. You can also cancel them all prematurely by canceling passed context.

Typical usage:

runman.New(runner1, runner2, runner3).Run(ctx)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager structure used to manage a list of runners. Note that it implements Runner interface too, so in theory you can feed one manager instance into another.

func New

func New(runners ...Runner) *Manager

New function creates new manager instance with a list of provided runners.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run method runs all runners in separate goroutines. When one of them finishes, all other will be canceled. When provided context cancels, all runners are canceled too. It returns only when everything finishes.

type Runner

type Runner interface {
	Run(ctx context.Context)
}

Runner interface, implementations of which are managed by Manager structure.

Jump to

Keyboard shortcuts

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