sync

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNopLifecycle added in v1.8.0

func NewNopLifecycle() transport.Lifecycle

NewNopLifecycle returns a new one-time no-op lifecycle

Types

type ErrorWaiter

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

ErrorWaiter is similar to a WaitGroup except it allows collecting failures from subtasks.

func (*ErrorWaiter) Submit

func (ew *ErrorWaiter) Submit(f func() error)

Submit submits a task for execution on the ErrorWaiter.

The function returns immediately.

func (*ErrorWaiter) Wait

func (ew *ErrorWaiter) Wait() []error

Wait waits until all submitted tasks have finished and returns a list of all errors that occurred during task execution in no particular order.

type LifecycleOnce added in v1.0.0

type LifecycleOnce interface {
	Start(func() error) error
	Stop(func() error) error
	LifecycleState() LifecycleState
	IsRunning() bool
	WhenRunning(context.Context) error
}

LifecycleOnce is a helper for implementing transport.Lifecycles with similar behavior.

func Once added in v1.4.0

func Once() LifecycleOnce

Once returns a lifecycle controller.

  1. The observable lifecycle state must only go forward from birth to death.
  2. Start() must block until the state is >= Running
  3. Stop() must block until the state is >= Stopped
  4. Stop() must pre-empt Start() if it occurs first
  5. Start() and Stop() may be backed by a do actual work function, and that function must be called at most once.

type LifecycleState added in v1.0.0

type LifecycleState int

LifecycleState represents `states` that a lifecycle object can be in.

const (
	// Idle indicates the Lifecycle hasn't been operated on yet.
	Idle LifecycleState = iota

	// Starting indicates that the Lifecycle has begun it's "start" command
	// but hasn't finished yet.
	Starting

	// Running indicates that the Lifecycle has finished starting and is
	// available.
	Running

	// Stopping indicates that the Lifecycle 'stop' method has been called
	// but hasn't finished yet.
	Stopping

	// Stopped indicates that the Lifecycle has been stopped.
	Stopped

	// Errored indicates that the Lifecycle experienced an error and we can't
	// reasonably determine what state the lifecycle is in.
	Errored
)

func (LifecycleState) String added in v1.4.0

func (i LifecycleState) String() string

Jump to

Keyboard shortcuts

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