fx

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Component klogga.ComponentName = "fx"
View Source
const RunnersGroupName = "runners"

Variables

View Source
var RunnersGroupAttribute = fmt.Sprintf(`group:"%s"`, RunnersGroupName)

Functions

func Full

func Full() fx.Option

Full Set up the default logging for the app registering logging and the klogga factory, that later can be reconfigured with more loggers

func Module

func Module(tf klogga.TracerProvider) fx.Option

Module send fx logs to standard tracer

func RegisterRunners

func RegisterRunners(r RunnersGroup, lc fx.Lifecycle)

func RegisterRunnersWithErrors

func RegisterRunnersWithErrors(r RunnersGroup, tf klogga.TracerProvider, lc fx.Lifecycle, s fx.Shutdowner)

RegisterRunnersWithErrors experimental watch for runner errors via channel

func ToHook

func ToHook(r Runner) fx.Hook

func ToHookWithCtx

func ToHookWithCtx(r Runner, onStopped context.CancelFunc) fx.Hook

Types

type Runner

type Runner interface {
	// Start starts the runner, start process can timeout by context
	// runner is responsible for creating goroutines etc
	// should not block and exit when startup is done
	Start(ctx context.Context) error

	// Stop stops the runner, the stop process can timeout by contest
	Stop(ctx context.Context) error
}

Runner simplifies registration of components that should start and stop

type RunnerErr

type RunnerErr interface {
	Error() <-chan error
}

type RunnersGroup

type RunnersGroup struct {
	fx.In
	Runners []Runner `group:"runners"`
}

func (RunnersGroup) Register

func (rr RunnersGroup) Register(lc fx.Lifecycle)

func (RunnersGroup) RegisterWithErrors

func (rr RunnersGroup) RegisterWithErrors(tf klogga.TracerProvider, lc fx.Lifecycle, s fx.Shutdowner)

Jump to

Keyboard shortcuts

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