daemon

package
v0.0.0-...-4402e7d Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(configs ...Config)

func Par

func Par(funcs ...func())

Types

type Component

type Component interface {
	// Stop the component.  The implementation of this component
	// should be synchronous: When it returns, all resources of
	// the component should have been released, and any activity
	// associated with the component has ceased.  The component
	// supervisor may call this function at most once.
	Stop()
}

A component is simply something that can be stopped

func NullStartFunc

func NullStartFunc(ErrorSink) Component

func StopFunc

func StopFunc(f func()) Component

Because Component only has a single method, it's convenient to have a way to dress up a stop function as a Component. This also takes care of ensuring that the stop function is only called once.

type Config

type Config interface {
	Populate(*Dependencies)
	Prepare() (StartFunc, error)
}

type Dependencies

type Dependencies struct {
	*flag.FlagSet
	// contains filtered or unexported fields
}

func (*Dependencies) Dependency

func (deps *Dependencies) Dependency(slot DependencySlot)

type DependencyConfig

type DependencyConfig interface {
	Populate(*Dependencies)
	MakeValue() (interface{}, StartFunc, error)
}

type DependencyKey

type DependencyKey interface {
	MakeConfig() DependencyConfig
}

type DependencySlot

type DependencySlot interface {
	Key() DependencyKey
	Assign(value interface{})
}

type ErrorSink

type ErrorSink chan error

func NewErrorSink

func NewErrorSink() ErrorSink

func (ErrorSink) Post

func (sink ErrorSink) Post(err error)

Post an error. Posting a nil error is a no-op, for convenience.

type StartFunc

type StartFunc func(ErrorSink) Component

A StartFunc starts a component

func Aggregate

func Aggregate(startFuncs ...StartFunc) StartFunc

func Reset

func Reset(reset <-chan struct{}, startFunc StartFunc) StartFunc

func Restart

func Restart(interval time.Duration, start StartFunc) StartFunc

Supervise a component, restarting it upon errors

func SimpleComponent

func SimpleComponent(f func(stop <-chan struct{}, errs ErrorSink)) StartFunc

func Ticker

func Ticker(interval time.Duration, tick func(errs ErrorSink)) StartFunc

Jump to

Keyboard shortcuts

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