Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - type App
 - func (a *App) AdditionalConfigs() map[string]*configuration.Configuration
 - func (a *App) AdditionalFlagSets() map[string]*flag.FlagSet
 - func (a *App) Config() *configuration.Configuration
 - func (a *App) Daemon() daemon.Daemon
 - func (a *App) FlagSet() *flag.FlagSet
 - func (a *App) ForEachCoreComponent(f CoreComponentForEachFunc)
 - func (n *App) ForEachPlugin(f PluginForEachFunc)
 - func (a *App) Info() *AppInfo
 - func (a *App) IsPluginSkipped(plugin *Plugin) bool
 - func (a *App) LogDebug(args ...interface{})
 - func (a *App) LogDebugf(template string, args ...interface{})
 - func (a *App) LogError(args ...interface{})
 - func (a *App) LogErrorAndExit(args ...interface{})
 - func (a *App) LogErrorf(template string, args ...interface{})
 - func (a *App) LogErrorfAndExit(template string, args ...interface{})
 - func (a *App) LogFatalAndExit(args ...interface{})
 - func (a *App) LogFatalfAndExit(template string, args ...interface{})
 - func (a *App) LogInfo(args ...interface{})
 - func (a *App) LogInfof(template string, args ...interface{})
 - func (a *App) LogPanic(args ...interface{})
 - func (a *App) LogPanicf(template string, args ...interface{})
 - func (a *App) LogWarn(args ...interface{})
 - func (a *App) LogWarnf(template string, args ...interface{})
 - func (a *App) Parameters() *ParametersApp
 - func (a *App) Run()
 - func (a *App) Shutdown()
 - func (a *App) Start()
 
- type AppInfo
 - type AppOption
 - func WithCoreComponents(coreComponents ...*CoreComponent) AppOption
 - func WithDaemon(d daemon.Daemon) AppOption
 - func WithInitComponent(initComponent *InitComponent) AppOption
 - func WithPlugins(plugins ...*Plugin) AppOption
 - func WithUsageText(usageText string) AppOption
 - func WithVersionCheck(owner string, repository string) AppOption
 
- type AppOptions
 - type Callback
 - type Component
 - func (c *Component) Daemon() daemon.Daemon
 - func (c *Component) Identifier() string
 - func (c *Component) LogDebug(args ...interface{})
 - func (c *Component) LogDebugf(template string, args ...interface{})
 - func (c *Component) LogError(args ...interface{})
 - func (c *Component) LogErrorAndExit(args ...interface{})
 - func (c *Component) LogErrorf(template string, args ...interface{})
 - func (c *Component) LogErrorfAndExit(template string, args ...interface{})
 - func (c *Component) LogFatalAndExit(args ...interface{})
 - func (c *Component) LogFatalfAndExit(template string, args ...interface{})
 - func (c *Component) LogInfo(args ...interface{})
 - func (c *Component) LogInfof(template string, args ...interface{})
 - func (c *Component) LogPanic(args ...interface{})
 - func (c *Component) LogPanicf(template string, args ...interface{})
 - func (c *Component) LogWarn(args ...interface{})
 - func (c *Component) LogWarnf(template string, args ...interface{})
 - func (c *Component) Logger() *logger.Logger
 
- type ComponentParams
 - type ConfigurationSet
 - type ConfigurationSets
 - type CoreComponent
 - type CoreComponentForEachFunc
 - type InitComponent
 - type InitConfig
 - type InitConfigParsFunc
 - type InitFunc
 - type IsEnabledFunc
 - type ParametersApp
 - type Plugin
 - type PluginForEachFunc
 - type PreProvideFunc
 - type ProvideFunc
 
Constants ¶
const (
	DefaultFlagSetName = "appConfig"
)
    Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
	// contains filtered or unexported fields
}
    func (*App) AdditionalConfigs ¶
func (a *App) AdditionalConfigs() map[string]*configuration.Configuration
func (*App) Config ¶
func (a *App) Config() *configuration.Configuration
func (*App) ForEachCoreComponent ¶
func (a *App) ForEachCoreComponent(f CoreComponentForEachFunc)
ForEachCoreComponent calls the given CoreComponentForEachFunc on each loaded core components.
func (*App) ForEachPlugin ¶
func (n *App) ForEachPlugin(f PluginForEachFunc)
ForEachPlugin calls the given PluginForEachFunc on each loaded plugin.
func (*App) IsPluginSkipped ¶
IsPluginSkipped returns whether the plugin is loaded or skipped.
func (*App) LogDebug ¶
func (a *App) LogDebug(args ...interface{})
LogDebug uses fmt.Sprint to construct and log a message.
func (*App) LogError ¶
func (a *App) LogError(args ...interface{})
LogError uses fmt.Sprint to construct and log a message.
func (*App) LogErrorAndExit ¶
func (a *App) LogErrorAndExit(args ...interface{})
LogErrorAndExit uses fmt.Sprint to construct and log a message, then calls os.Exit.
func (*App) LogErrorfAndExit ¶
LogErrorfAndExit uses fmt.Sprintf to log a templated message, then calls os.Exit.
func (*App) LogFatalAndExit ¶
func (a *App) LogFatalAndExit(args ...interface{})
LogFatalAndExit uses fmt.Sprint to construct and log a message, then calls os.Exit.
func (*App) LogFatalfAndExit ¶
LogFatalfAndExit uses fmt.Sprintf to log a templated message, then calls os.Exit.
func (*App) LogInfo ¶
func (a *App) LogInfo(args ...interface{})
LogInfo uses fmt.Sprint to construct and log a message.
func (*App) LogPanic ¶
func (a *App) LogPanic(args ...interface{})
LogPanic uses fmt.Sprint to construct and log a message, then panics.
func (*App) LogWarn ¶
func (a *App) LogWarn(args ...interface{})
LogWarn uses fmt.Sprint to construct and log a message.
func (*App) Parameters ¶
func (a *App) Parameters() *ParametersApp
type AppOption ¶
type AppOption func(opts *AppOptions)
AppOption is a function setting a AppOptions option.
func WithCoreComponents ¶
func WithCoreComponents(coreComponents ...*CoreComponent) AppOption
WithCoreComponents sets the core components.
func WithInitComponent ¶
func WithInitComponent(initComponent *InitComponent) AppOption
WithInitComponent sets the init component.
func WithUsageText ¶
WithUsageText overwrites the default usage text of the app.
func WithVersionCheck ¶
WithVersionCheck enables the GitHub version check.
type AppOptions ¶
type AppOptions struct {
	// contains filtered or unexported fields
}
    AppOptions defines options for an App.
type Component ¶
type Component struct {
	// A reference to the App instance.
	App *App
	// The name of the component.
	Name string
	// The config parameters for this component.
	Params *ComponentParams
	// The function to call to initialize the component dependencies.
	DepsFunc interface{}
	// InitConfigPars gets called in the init stage of app initialization.
	// This can be used to provide config parameters even if the component is disabled.
	InitConfigPars InitConfigParsFunc
	// PreProvide gets called before the provide stage of app initialization.
	// This can be used to force disable other components before they get initialized.
	PreProvide PreProvideFunc
	// Provide gets called in the provide stage of app initialization (enabled components only).
	Provide ProvideFunc
	// Configure gets called in the configure stage of app initialization (enabled components only).
	Configure Callback
	// Run gets called in the run stage of app initialization (enabled components only).
	Run Callback
	// contains filtered or unexported fields
}
    Component is something which extends the App's capabilities.
func (*Component) Identifier ¶
func (*Component) LogDebug ¶
func (c *Component) LogDebug(args ...interface{})
LogDebug uses fmt.Sprint to construct and log a message.
func (*Component) LogError ¶
func (c *Component) LogError(args ...interface{})
LogError uses fmt.Sprint to construct and log a message.
func (*Component) LogErrorAndExit ¶
func (c *Component) LogErrorAndExit(args ...interface{})
LogErrorAndExit uses fmt.Sprint to construct and log a message, then calls os.Exit.
func (*Component) LogErrorfAndExit ¶
LogErrorfAndExit uses fmt.Sprintf to log a templated message, then calls os.Exit.
func (*Component) LogFatalAndExit ¶
func (c *Component) LogFatalAndExit(args ...interface{})
LogFatalAndExit uses fmt.Sprint to construct and log a message, then calls os.Exit.
func (*Component) LogFatalfAndExit ¶
LogFatalfAndExit uses fmt.Sprintf to log a templated message, then calls os.Exit.
func (*Component) LogInfo ¶
func (c *Component) LogInfo(args ...interface{})
LogInfo uses fmt.Sprint to construct and log a message.
func (*Component) LogPanic ¶
func (c *Component) LogPanic(args ...interface{})
LogPanic uses fmt.Sprint to construct and log a message, then panics.
func (*Component) LogWarn ¶
func (c *Component) LogWarn(args ...interface{})
LogWarn uses fmt.Sprint to construct and log a message.
type ComponentParams ¶
type ComponentParams struct {
	// Handler to add configuration parameters to the default config.
	Params map[string]any
	// Handler to add configuration parameters to the additional configs.
	AdditionalParams map[string]map[string]any
	// The configuration values to mask.
	Masked []string
}
    ComponentParams defines the parameters configuration of a component.
type ConfigurationSet ¶
type ConfigurationSet struct {
	// contains filtered or unexported fields
}
    type ConfigurationSets ¶
type ConfigurationSets []*ConfigurationSet
func (ConfigurationSets) ConfigsMap ¶
func (c ConfigurationSets) ConfigsMap() map[string]*configuration.Configuration
func (ConfigurationSets) FlagSets ¶
func (c ConfigurationSets) FlagSets() []*flag.FlagSet
func (ConfigurationSets) FlagSetsMap ¶
func (c ConfigurationSets) FlagSetsMap() map[string]*flag.FlagSet
type CoreComponent ¶
type CoreComponent struct {
	*Component
}
    CoreComponent is a component essential for app operation. It can not be disabled.
type CoreComponentForEachFunc ¶
type CoreComponentForEachFunc func(coreComponent *CoreComponent) bool
CoreComponentForEachFunc is used in ForEachCoreComponent. Returning false indicates to stop looping.
type InitComponent ¶
type InitComponent struct {
	*Component
	NonHiddenFlags []string
	// Init gets called in the initialization stage of the app.
	Init InitFunc
	// The additional configs this InitComponent brings to the app.
	AdditionalConfigs []*ConfigurationSet
}
    InitComponent is the module initializing configuration of the app. An App can only have one of such modules.
type InitConfig ¶
type InitConfig struct {
	// contains filtered or unexported fields
}
    InitConfig describes the result of a app initialization.
func (*InitConfig) ForceDisableComponent ¶
func (ic *InitConfig) ForceDisableComponent(identifier string)
ForceDisableComponent is used to force disable components before the provide stage.
type InitConfigParsFunc ¶
InitConfigParsFunc gets called with a dig.Container.
type IsEnabledFunc ¶
type IsEnabledFunc func() bool
IsEnabledFunc gets called to check whether the Plugin is enabled. It returns true if the Plugin is enabled.
type ParametersApp ¶
type ParametersApp struct {
	CheckForUpdates bool `default:"true" usage:"whether to check for updates of the application or not"`
}
    type Plugin ¶
type Plugin struct {
	*Component
	// IsEnabled gets called to check whether the Plugin is enabled.
	IsEnabled IsEnabledFunc
}
    type PluginForEachFunc ¶
PluginForEachFunc is used in ForEachPlugin. Returning false indicates to stop looping.
type PreProvideFunc ¶
type PreProvideFunc func(c *dig.Container, application *App, initConf *InitConfig) error
PreProvideFunc gets called with a dig.Container, the configs the InitComponent brings to the app and the InitConfig.
type ProvideFunc ¶
ProvideFunc gets called with a dig.Container.