fx

package module
v1.0.0-beta4 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2017 License: MIT Imports: 11 Imported by: 5,261

README

UberFx Service Framework

GoDoc Coverage Status Build Status Report Card

UberFx is a flexible, modularized framework for building robust and performant services. It takes care of the boilerplate code and lets you focus on your application logic.

Status

Beta. Expect minor API changes and bug fixes. See our changelog for more.

Compatibility

UberFx is compatible with Go 1.7 and above.

License

MIT

Documentation

Index

Constants

View Source
const Version = "1.0.0-beta4"

Version is exported for runtime compatibility checks

Variables

View Source
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
)

Functions

This section is empty.

Types

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 {
	Append(Hook)
}

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

Directories

Path Synopsis
docs module
internal
e2e Module
tools module

Jump to

Keyboard shortcuts

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