Documentation ¶
Index ¶
- Variables
- func MustComponent[i any](app *App) i
- func Version() string
- func VersionDescription() string
- type App
- func (app *App) AnySyncVersion() string
- func (app *App) AppName() string
- func (app *App) ChildApp() *App
- func (app *App) Close(ctx context.Context) error
- func (app *App) Component(name string) Component
- func (app *App) ComponentNames() (names []string)
- func (app *App) IterateComponents(fn func(Component))
- func (app *App) MustComponent(name string) Component
- func (app *App) Name() string
- func (app *App) Register(s Component) *App
- func (app *App) SetDeviceState(state int)
- func (app *App) SetVersionName(v string)
- func (app *App) Start(ctx context.Context) (err error)
- func (app *App) StartStat() Stat
- func (app *App) StopStat() Stat
- func (app *App) Version() string
- func (app *App) VersionDescription() string
- func (app *App) VersionName() string
- type Component
- type ComponentRunnable
- type ComponentStatable
- type Stat
Constants ¶
This section is empty.
Variables ¶
var ( StopDeadline = time.Minute StopWarningAfter = time.Second * 10 StartWarningAfter = time.Second * 10 )
var (
// values of this vars will be defined while compilation
AppName, GitCommit, GitBranch, GitState, GitSummary, BuildDate string
)
Functions ¶
func MustComponent ¶
MustComponent - generic version of app.MustComponent
func VersionDescription ¶
func VersionDescription() string
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the central part of the application It contains and manages all components
func (*App) AnySyncVersion ¶
func (*App) ChildApp ¶ added in v0.2.0
ChildApp creates a child container which has access to parent's components It doesn't call Start on any of the parent's components
func (*App) Close ¶
Close stops the application All components with ComponentRunnable implementation will be closed in the reversed order
func (*App) Component ¶
Component returns service by name If service with given name wasn't registered, nil will be returned
func (*App) ComponentNames ¶
ComponentNames returns all registered names
func (*App) IterateComponents ¶ added in v0.2.7
IterateComponents iterates over all registered components. It's safe for concurrent use.
func (*App) MustComponent ¶
MustComponent is like Component, but it will panic if service wasn't found
func (*App) Register ¶
Register adds service to registry All components will be started in the order they were registered
func (*App) SetDeviceState ¶
func (*App) SetVersionName ¶ added in v0.2.2
SetVersionName sets the custom application version
func (*App) Start ¶
Start starts the application All registered services will be initialized and started
func (*App) VersionDescription ¶
VersionDescription return the full info about the build
func (*App) VersionName ¶ added in v0.2.2
VersionName returns a string with the settled app version or auto-generated version if it didn't set
type Component ¶
type Component interface { // Init will be called first // When returned error is not nil - app start will be aborted Init(a *App) (err error) // Name must return unique service name Name() (name string) }
Component is a minimal interface for a common app.Component
type ComponentRunnable ¶
type ComponentRunnable interface { Component // Run will be called after init stage // Non-nil error also will be aborted app start Run(ctx context.Context) (err error) // Close will be called when app shutting down // Also will be called when service return error on Init or Run stage // Non-nil error will be printed to log Close(ctx context.Context) (err error) }
ComponentRunnable is an interface for realizing ability to start background processes or deep configure service
type ComponentStatable ¶
type ComponentStatable interface {
StateChange(state int)
}
Directories ¶
Path | Synopsis |
---|---|
mock_debugstat
Code generated by MockGen.
|
Code generated by MockGen. |
Package ldiff provides a container of elements with fixed id and changeable content.
|
Package ldiff provides a container of elements with fixed id and changeable content. |
mock_ldiff
Code generated by MockGen.
|
Code generated by MockGen. |