fxevent

package
Version: v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NopLogger = nopLogger{}

NopLogger is an Fx event logger that ignores all messages.

Functions

This section is empty.

Types

type ConsoleLogger

type ConsoleLogger struct {
	W io.Writer
}

ConsoleLogger is an Fx event logger that attempts to write human-readable mesasges to the console.

Use this during development.

func (*ConsoleLogger) LogEvent

func (l *ConsoleLogger) LogEvent(event Event)

LogEvent logs the given event to the provided Zap logger.

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event defines an event emitted by fx.

type Invoked

type Invoked struct {
	// Functionname is the name of the function that was invoked.
	FunctionName string

	// Err is non-nil if the function failed to execute.
	Err error

	// Trace records information about where the fx.Invoke call was made.
	// Note that this is NOT a stack trace of the error itself.
	Trace string
}

Invoked is emitted after we invoke a function specified with fx.Invoke, whether it succeded or failed.

type Invoking

type Invoking struct {
	// FunctionName is the name of the function that will be invoked.
	FunctionName string
}

Invoking is emitted before we invoke a function specified with fx.Invoke.

type Logger

type Logger interface {
	// LogEvent is called when a logging event is emitted.
	LogEvent(Event)
}

Logger defines interface used for logging.

type LoggerInitialized

type LoggerInitialized struct {
	// ConstructorName is the name of the constructor that builds this
	// logger.
	ConstructorName string

	// Err is non-nil if the logger failed to build.
	Err error
}

LoggerInitialized is emitted when a logger supplied with fx.WithLogger is instantiated, or if it fails to instantiate.

type OnStartExecuted

type OnStartExecuted struct {
	// FunctionName is the name of the function that was executed.
	FunctionName string

	// CallerName is the name of the function that scheduled the hook for
	// execution.
	CallerName string

	// Method specifies the kind of the hook. This is one of "OnStart" and
	// "OnStop".
	Method string

	// Runtime specifies how long it took to run this hook.
	Runtime time.Duration

	// Err is non-nil if the hook failed to execute.
	Err error
}

OnStartExecuted is emitted after an OnStart hook has been executed.

type OnStartExecuting

type OnStartExecuting struct {
	// FunctionName is the name of the function that will be executed.
	FunctionName string

	// CallerName is the name of the function that scheduled the hook for
	// execution.
	CallerName string
}

OnStartExecuting is emitted before an OnStart hook is exeucted.

type OnStopExecuted

type OnStopExecuted struct {
	// FunctionName is the name of the function that was executed.
	FunctionName string

	// CallerName is the name of the function that scheduled the hook for
	// execution.
	CallerName string

	// Runtime specifies how long it took to run this hook.
	Runtime time.Duration

	// Err is non-nil if the hook failed to execute.
	Err error
}

OnStopExecuted is emitted after an OnStop hook has been executed.

type OnStopExecuting

type OnStopExecuting struct {
	// FunctionName is the name of the function that will be executed.
	FunctionName string

	// CallerName is the name of the function that scheduled the hook for
	// execution.
	CallerName string
}

OnStopExecuting is emitted before an OnStop hook is exeucted.

type Provided

type Provided struct {
	// ConstructorName is the name of the constructor that was provided to
	// Fx.
	ConstructorName string

	// OutputTypeNames is a list of names of types that are produced by
	// this constructor.
	OutputTypeNames []string

	// Err is non-nil if we failed to provide this constructor.
	Err error
}

Provided is emitted when a constructor is provided to Fx.

type RolledBack

type RolledBack struct {
	// Err is non-nil if the rollback failed.
	Err error
}

RolledBack is emitted after a service has been rolled back, whether it succeded or not.

type RollingBack

type RollingBack struct {
	// StartErr is the error that caused this rollback.
	StartErr error
}

RollingBack is emitted when the application failed to start up due to an error, and is being rolled back.

type Started

type Started struct {
	// Err is non-nil if the application failed to start successfully.
	Err error
}

Started is emitted when an application is started successfully and/or it errored.

type Stopped

type Stopped struct {
	// Err is non-nil if errors were encountered during shutdown.
	Err error
}

Stopped is emitted when the application has finished shutting down, whether successfully or not.

type Stopping

type Stopping struct {
	// Signal is the signal that caused this shutdown.
	Signal os.Signal
}

Stopping is emitted when the application receives a signal to shut down after starting. This may happen with fx.Shutdowner or by sending a signal to the application on the command line.

type Supplied

type Supplied struct {
	// Name of the type of value that was added.
	TypeName string

	// Err is non-nil if we failed to supply the value.
	Err error
}

Supplied is emitted after a value is added with fx.Supply.

type ZapLogger

type ZapLogger struct {
	Logger *zap.Logger
}

ZapLogger is an Fx event logger that logs events to Zap.

func (*ZapLogger) LogEvent

func (l *ZapLogger) LogEvent(event Event)

LogEvent logs the given event to the provided Zap logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL