Documentation ¶
Index ¶
- Constants
- type Core
- type CoreOptions
- type Option
- func AfterStart(fn func(context.Context) error) Option
- func AfterStop(fn func(context.Context) error) Option
- func AppCore(s Core) Option
- func AppInfo(opts ...app.Option) Option
- func BeforeStart(fn func(context.Context) error) Option
- func BeforeStop(fn func(context.Context) error) Option
- func Context(ctx context.Context) Option
- func Logger(l any) Option
- func Options(opts ...any) Option
- func StartTimeout(t time.Duration) Option
- func StopTimeout(t time.Duration) Option
- type TohoApp
Constants ¶
const DefaultTimeout = 15 * time.Second
DefaultTimeout is the default timeout for starting or stopping an application. It can be configured with the StartTimeout and StopTimeout options.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core interface { // Init is used to configure application core. Init(*CoreOptions) error // Start starts the application. Start(context.Context) error // Stop gracefully stops the application. Stop(context.Context) error // Wait for termination of interrupt signals. Wait() <-chan os.Signal }
Core interface defines the methods for initializing and starting the application.
type CoreOptions ¶
type CoreOptions struct { App app.App ConfigPointer any LogPointer any Options []any StartTimeout time.Duration StopTimeout time.Duration }
CoreOptions struct holds the configuration options for the Core interface.
type Option ¶
type Option func(o *options)
Option is an application option.
func AfterStart ¶
AfterStart run functions after app starts.
func BeforeStart ¶
BeforeStart run functions before app starts.
func BeforeStop ¶
BeforeStop run functions before app stops.
type TohoApp ¶
type TohoApp[C, L any] struct { // contains filtered or unexported fields }
TohoApp defines a application components lifecycle manager. [C] defines type of the configuration struct for the application. [L] defines type of the logger for the application.
func (*TohoApp[C, L]) Start ¶
Start executes all OnStart hooks registered with the application's Lifecycle.