Documentation
¶
Index ¶
- func BindConfig(prefix string, value any) any
- func Config[T any](prefix string, value T) any
- func Logger(name ...string) any
- func LogrLogger(name ...string) any
- func Meter(name string, opts ...metric.MeterOption) any
- func SugaredLogger(name ...string) any
- func Tracer(name string, opts ...trace.TracerOption) any
- type HealthCheck
- type HealthChecks
- type Sprout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindConfig ¶
BindConfig is an on-demand version of Config. It will read configuration from the environment and bind them to the specified struct.
func Config ¶
Config will read configuration from the environment and provide the specified type to the application.
Example:
type Config struct {
Host string `env:"HOST" envDefault:"localhost"`
Port int `env:"PORT" envDefault:"8080"`
}
sprout.New("my-service", "1.0.0").With(
fx.Provide(sprout.Config("HTTP", Config{})),
fx.Invoke(func(config Config) {
// ...
}),
).Run()
func Logger ¶
Logger creates a function that can be used to create a logger with a name. Can be used with fx.Decorate or fx.Provide.
It is mostly used when creating a module, to supply a logger with a name that is specific to the module.
Example:
var Module = fx.Module(
"example",
fx.Decorate(sprout.Logger("name", "of", "logger")),
fx.Invoke(func(logger *zap.Logger) {
// ...
}),
)
func LogrLogger ¶ added in v0.2.0
LogrLogger creates a function that can be used to create a logr logger with a name. Can be used with fx.Decorate or fx.Provide.
It is mostly used when creating a module, to supply a logr logger with a name that is specific to the module.
Example:
var Module = fx.Module(
"example",
fx.Decorate(sprout.LogrLogger("name", "of", "logger")),
fx.Invoke(func(logger logr.Logger) {
// ...
}),
)
func Meter ¶
func Meter(name string, opts ...metric.MeterOption) any
Meter returns a function that can be used with fx.Provide to make a meter available to the application.
func SugaredLogger ¶ added in v0.2.0
SugaredLogger creates a function that can be used to create a sugared logger with a name. Can be used with fx.Decorate or fx.Provide.
It is mostly used when creating a module, to supply a sugared logger with a name that is specific to the module.
Example:
var Module = fx.Module(
"example",
fx.Decorate(sprout.SugaredLogger("name", "of", "logger")),
fx.Invoke(func(logger *zap.SugaredLogger) {
// ...
}),
)