goroutinemap

package
v1.3.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package goroutinemap implements a data structure for managing go routines by name. It prevents the creation of new go routines if an existing go routine with the same name exists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists returns true if an error returned from NewGoRoutine indicates that operation with the same name already exists.

func IsExponentialBackoff

func IsExponentialBackoff(err error) bool

IsExponentialBackoff returns true if an error returned from NewGoRoutine() indicates that the previous operation for given name failed less then durationBeforeRetry.

Types

type GoRoutineMap

type GoRoutineMap interface {
	// Run adds operationName to the list of running operations and spawns a new
	// go routine to execute the operation. If an operation with the same name
	// already exists, an error is returned. Once the operation is complete, the
	// go routine is terminated and the operationName is removed from the list
	// of executing operations allowing a new operation to be started with the
	// same name without error.
	Run(operationName string, operationFunc func() error) error

	// Wait blocks until all operations are completed. This is typically
	// necessary during tests - the test should wait until all operations finish
	// and evaluate results after that.
	Wait()
}

GoRoutineMap defines the supported set of operations.

func NewGoRoutineMap

func NewGoRoutineMap(exponentialBackOffOnError bool) GoRoutineMap

NewGoRoutineMap returns a new instance of GoRoutineMap.

Jump to

Keyboard shortcuts

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