Documentation ¶
Index ¶
- Constants
- Variables
- func AsCoreExtraInfo(name string, value string) fx.Option
- func RootDir(skip int) string
- func Sanitize(str string) string
- func Split(str string) []string
- type Bootstrapper
- func (b *Bootstrapper) BootstrapApp(options ...fx.Option) *fx.App
- func (b *Bootstrapper) BootstrapTestApp(tb testing.TB, options ...fx.Option) *fxtest.App
- func (b *Bootstrapper) RunApp(options ...fx.Option)
- func (b *Bootstrapper) RunTestApp(tb testing.TB, options ...fx.Option)
- func (b *Bootstrapper) WithContext(ctx context.Context) *Bootstrapper
- func (b *Bootstrapper) WithOptions(options ...fx.Option) *Bootstrapper
- type Core
- type DashboardRenderer
- type FxCoreDashboardTheme
- type FxCoreModuleInfo
- type FxCoreModuleInfoParam
- type FxCoreParam
- type FxExtraInfo
- type FxModuleInfo
- type FxModuleInfoRegistry
- type FxModuleInfoRegistryParam
Constants ¶
const ( ModuleName = "core" DefaultAddress = ":8081" DefaultMetricsPath = "/metrics" DefaultHealthCheckStartupPath = "/healthz" DefaultHealthCheckLivenessPath = "/livez" DefaultHealthCheckReadinessPath = "/readyz" DefaultDebugConfigPath = "/debug/config" DefaultDebugPProfPath = "/debug/pprof" DefaultDebugBuildPath = "/debug/build" DefaultDebugRoutesPath = "/debug/routes" DefaultDebugStatsPath = "/debug/stats" DefaultDebugModulesPath = "/debug/modules" ThemeLight = "light" ThemeDark = "dark" )
Variables ¶
var FxCoreModule = fx.Module( ModuleName, fxgenerate.FxGenerateModule, fxconfig.FxConfigModule, fxlog.FxLogModule, fxtrace.FxTraceModule, fxmetrics.FxMetricsModule, fxhealthcheck.FxHealthcheckModule, fx.Provide( NewFxModuleInfoRegistry, NewFxCore, fx.Annotate( NewFxCoreModuleInfo, fx.As(new(interface{})), fx.ResultTags(`group:"core-module-infos"`), ), ), fx.Invoke(func(logger *log.Logger, core *Core) { logger.Debug().Msg("starting core") }), )
FxCoreModule is the Fx core module.
Functions ¶
func AsCoreExtraInfo ¶ added in v1.2.0
AsCoreExtraInfo registers extra information in the core.
Types ¶
type Bootstrapper ¶
type Bootstrapper struct {
// contains filtered or unexported fields
}
Bootstrapper is the application bootstrapper, that can load a list fx.Option and run your application.
func NewBootstrapper ¶
func NewBootstrapper() *Bootstrapper
NewBootstrapper returns a new Bootstrapper.
func (*Bootstrapper) BootstrapApp ¶
func (b *Bootstrapper) BootstrapApp(options ...fx.Option) *fx.App
BootstrapApp boostrap the application, accepting optional bootstrap options.
func (*Bootstrapper) BootstrapTestApp ¶
BootstrapTestApp boostrap the application in test mode, accepting a testing context and optional bootstrap options.
func (*Bootstrapper) RunApp ¶
func (b *Bootstrapper) RunApp(options ...fx.Option)
RunApp runs the application, accepting optional runtime options.
func (*Bootstrapper) RunTestApp ¶
func (b *Bootstrapper) RunTestApp(tb testing.TB, options ...fx.Option)
RunTestApp runs the application in test mode, accepting a testing context and optional runtime options.
func (*Bootstrapper) WithContext ¶
func (b *Bootstrapper) WithContext(ctx context.Context) *Bootstrapper
WithContext is used to pass a parent context.Context.
func (*Bootstrapper) WithOptions ¶
func (b *Bootstrapper) WithOptions(options ...fx.Option) *Bootstrapper
WithOptions is used to pass a list of fx.Option.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is the core component, holding the core config, health checker and http server.
func NewCore ¶
func NewCore(config *config.Config, checker *healthcheck.Checker, httpServer *echo.Echo) *Core
NewCore returns a new Core.
func (*Core) Checker ¶
func (c *Core) Checker() *healthcheck.Checker
Checker returns the core health checker.
func (*Core) HttpServer ¶
func (c *Core) HttpServer() *echo.Echo
HttpServer returns the core http server.
type DashboardRenderer ¶
type DashboardRenderer struct {
// contains filtered or unexported fields
}
DashboardRenderer is the core dashboard template renderer, based on template.Template.
func NewDashboardRenderer ¶
func NewDashboardRenderer(fs embed.FS, tpl string) *DashboardRenderer
NewDashboardRenderer returns a new DashboardRenderer.
type FxCoreDashboardTheme ¶
type FxCoreDashboardTheme struct {
Theme string `form:"theme" json:"theme"`
}
FxCoreDashboardTheme is the theme for the core dashboard.
type FxCoreModuleInfo ¶
type FxCoreModuleInfo struct { AppName string AppEnv string AppDebug bool AppVersion string LogLevel string LogOutput string TraceProcessor string TraceSampler string ExtraInfos map[string]string }
FxCoreModuleInfo is a module info collector for the core.
func NewFxCoreModuleInfo ¶
func NewFxCoreModuleInfo(p FxCoreModuleInfoParam) *FxCoreModuleInfo
NewFxCoreModuleInfo returns a new FxCoreModuleInfo.
func (*FxCoreModuleInfo) Data ¶
func (i *FxCoreModuleInfo) Data() map[string]interface{}
Data return the data of the module info.
func (*FxCoreModuleInfo) Name ¶
func (i *FxCoreModuleInfo) Name() string
Name return the name of the module info.
type FxCoreModuleInfoParam ¶ added in v1.2.0
type FxCoreModuleInfoParam struct { fx.In Config *config.Config ExtraInfos []FxExtraInfo `group:"core-extra-infos"` }
FxCoreModuleInfoParam allows injection of the required dependencies in NewFxCoreModuleInfo.
type FxCoreParam ¶
type FxCoreParam struct { fx.In Context context.Context LifeCycle fx.Lifecycle Generator uuid.UuidGenerator TracerProvider oteltrace.TracerProvider Checker *healthcheck.Checker Config *config.Config Logger *log.Logger Registry *FxModuleInfoRegistry MetricsRegistry *prometheus.Registry }
FxCoreParam allows injection of the required dependencies in NewFxCore.
type FxExtraInfo ¶ added in v1.2.0
FxExtraInfo is the struct used by modules or apps to provide their extra info to the core.
func NewFxExtraInfo ¶ added in v1.2.0
func NewFxExtraInfo(name string, value string) FxExtraInfo
NewFxExtraInfo returns a new FxExtraInfo.
type FxModuleInfo ¶
FxModuleInfo is the interface to implement by modules to provide their info to the core.
type FxModuleInfoRegistry ¶
type FxModuleInfoRegistry struct {
// contains filtered or unexported fields
}
FxModuleInfoRegistry is the registry collecting info about registered modules.
func NewFxModuleInfoRegistry ¶
func NewFxModuleInfoRegistry(p FxModuleInfoRegistryParam) *FxModuleInfoRegistry
NewFxModuleInfoRegistry returns a new FxModuleInfoRegistry.
func (*FxModuleInfoRegistry) All ¶
func (r *FxModuleInfoRegistry) All() map[string]FxModuleInfo
All returns a map of all registered FxModuleInfo.
func (*FxModuleInfoRegistry) Find ¶
func (r *FxModuleInfoRegistry) Find(name string) (FxModuleInfo, error)
Find returns a FxModuleInfo by name.
func (*FxModuleInfoRegistry) Names ¶
func (r *FxModuleInfoRegistry) Names() []string
type FxModuleInfoRegistryParam ¶
FxModuleInfoRegistryParam allows injection of the required dependencies in NewFxModuleInfoRegistry.