worker

package module
v0.0.0-...-777856d Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2017 License: BSD-3-Clause Imports: 4 Imported by: 3

README

maturity build status code coverage GoDoc

worker

The worker package implements a service to process work concurrently.

Documentation

Overview

Package worker implements a service to process work concurrently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

Types

type ExecuteConfig

type ExecuteConfig struct {

	// Actions represents the function executed by worker goroutines. The given
	// context is the context provided to the call to Service.Execute.
	Actions []func(ctx context.Context) error
	// CancelOnError defines whether to signal cancelation of worker goroutines in
	// case one worker of the pool throws an error.
	CancelOnError bool
	// Errors is the channel used to put all occured errors into, if any. When
	// this is provided manually the caller have to make sure the errors channel
	// is buffered according to the number of provided actions.
	Errors chan error
	// NumWorkers represents the number of workers to be registered to run
	// concurrently within the pool.
	NumWorkers int
}

ExecuteConfig represents the configuration used to execute a new worker pool.

type Service

type Service interface {
	// Execute processes all configured actions concurrently. The call to Execute
	// blocks until all goroutines within the worker pool have finished their
	// work.
	Execute(ctx context.Context, config ExecuteConfig) error
	// ExecuteConfig provides a default configuration for Execute.
	ExecuteConfig() ExecuteConfig
}

Service represents a service to process work concurrently.

func NewService

func NewService(config ServiceConfig) (Service, error)

NewService creates a new configured worker service.

type ServiceConfig

type ServiceConfig struct {
}

ServiceConfig represents the configuration used to create a new worker service.

func DefaultServiceConfig

func DefaultServiceConfig() ServiceConfig

DefaultServiceConfig provides a default configuration to create a new worker service by best effort.

Jump to

Keyboard shortcuts

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