Back to

Package fx

v1.0.0 (beta4)
Latest Go to latest
Published: Jun 12, 2017 | License: MIT | Module:


Package Files


const Version = "1.0.0-beta4"

Version is exported for runtime compatibility checks


var (
	// DefaultStartTimeout will be used to start app in Run
	DefaultStartTimeout = 15 * time.Second

	// DefaultStopTimeout will be used to stop app in Run
	DefaultStopTimeout = 5 * time.Second

type App

type App struct {
	// contains filtered or unexported fields

App models a modular application

func New

func New(opts ...Option) *App

New creates a new modular application

func (App) Done

func (App) Done() <-chan os.Signal

Done allows blocking on SIGINT or SIGTERM

func (*App) Provide

func (s *App) Provide(constructors ...interface{})

Provide constructors into the D.I. Container, their types will be available to all other constructors, and called lazily at startup

func (*App) Run

func (s *App) Run(funcs ...interface{})

Run starts the app, blocks for SIGINT or SIGTERM, then gracefully stops

func (*App) Start

func (s *App) Start(ctx context.Context, funcs ...interface{}) error

Start the app by explicitly invoking all the user-provided constructors.

See dig.Invoke for moreinformation.

func (*App) Stop

func (s *App) Stop(ctx context.Context) error

Stop the app

type Hook

type Hook struct {
	OnStart func() error
	OnStop  func() error
	// contains filtered or unexported fields

Hook is a pair of Start and Stop funcs that get executed as part of Lifecycle start and stop.

type Lifecycle

type Lifecycle interface {

Lifecycle enables appending Events, OnStart and OnStop func pairs, to be executed on Service start and stop

type Option

type Option func(*App)

Option allows App to be customized

type TestLifecycle

type TestLifecycle struct {
	// contains filtered or unexported fields

TestLifecycle makes testing funcs that rely on Lifecycle possible be exposing a Start and Stop func which can be called manually in the context of a unit test.

func NewTestLifecycle

func NewTestLifecycle() *TestLifecycle

NewTestLifecycle creates a new test lifecycle

func (TestLifecycle) Append

func (l TestLifecycle) Append(hook Hook)

func (*TestLifecycle) Start

func (l *TestLifecycle) Start() error

Start the lifecycle

func (*TestLifecycle) Stop

func (l *TestLifecycle) Stop() error

Stop the lifecycle

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier