fxevent

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 7 Imported by: 277

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 messages 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 Decorated added in v1.17.0

type Decorated struct {
	// DecoratorName is the name of the decorator function that was
	// provided to Fx.
	DecoratorName string

	// ModuleName is the name of the module in which the value was added to.
	ModuleName string

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

	// Err is non-nil if we failed to run this decorator.
	Err error
}

Decorated is emitted when a decorator is executed in Fx.

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

	// ModuleName is the name of the module in which the value was added to.
	ModuleName 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 succeeded or failed.

type Invoking

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

	// ModuleName is the name of the module in which the value was added to.
	ModuleName 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 executed.

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 executed.

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

	// ModuleName is the name of the module in which the constructor was
	// provided to.
	ModuleName string

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

	// Private denotes whether the provided constructor is a [Private] constructor.
	Private bool
}

Provided is emitted when a constructor is provided to Fx.

type Replaced added in v1.18.0

type Replaced struct {
	// OutputTypeNames is a list of names of types that were replaced.
	OutputTypeNames []string

	// ModuleName is the name of the module in which the value was added to.
	ModuleName string

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

Replaced is emitted when a value replaces a type in 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 succeeded 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 {
	// TypeName is the name of the type of value that was added.
	TypeName string

	// ModuleName is the name of the module in which the value was added to.
	ModuleName 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
	// contains filtered or unexported fields
}

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.

func (*ZapLogger) UseErrorLevel added in v1.19.0

func (l *ZapLogger) UseErrorLevel(level zapcore.Level)

UseErrorLevel sets the level of error logs emitted by Fx to level.

func (*ZapLogger) UseLogLevel added in v1.19.0

func (l *ZapLogger) UseLogLevel(level zapcore.Level)

UseLogLevel sets the level of non-error logs emitted by Fx to level.

Jump to

Keyboard shortcuts

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