Documentation
¶
Index ¶
- Constants
- func Run(options ...Option)
- type Application
- type Bundle
- type ComponentOption
- type Context
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) Join(ctx context.Context) context.Context
- func (c *Context) Set(key interface{}, value interface{})
- func (c *Context) Value(key interface{}) interface{}
- type Dispatcher
- type Env
- type Hook
- type Info
- type Logger
- type Option
- func ShutdownTimeout(timeout time.Duration) Option
- func StartTimeout(timeout time.Duration) Option
- func WithBundles(bundles ...Bundle) Option
- func WithComponents(components ...ComponentOption) Option
- func WithLogger(logger Logger) Option
- func WithName(name string) Option
- func WithParameterParser(parser ParameterParser) Option
- func WithParameters(parameters ...Parameter) Option
- type Parameter
- type ParameterParser
Constants ¶
const DefaultTableFormat = `{{range .}}{{usage_key .}} {{usage_type .}} {{usage_default .}} {{usage_required .}} {{usage_description .}}
{{end}}`
DefaultTableFormat constant to use to display usage in a tabular format
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Application ¶
type Application struct {
Name string
Prefix string
Parameters []Parameter
Dispatcher Dispatcher
Bundles []Bundle
StartTimeout time.Duration
ShutdownTimeout time.Duration
Logger Logger
ParameterParser ParameterParser
// contains filtered or unexported fields
}
Application is a control part of application.
func New ¶
func New(options ...Option) *Application
New creates slice application with provided options.
type Bundle ¶
type Bundle struct {
Name string
Parameters []Parameter
Components []ComponentOption
Hooks []Hook
Bundles []Bundle
}
A Bundle is a separate unit of application.
type ComponentOption ¶ added in v0.4.0
type ComponentOption interface {
// contains filtered or unexported methods
}
ComponentOption modifies application components.
func Group ¶ added in v0.5.0
func Group(options ...ComponentOption) ComponentOption
Group groups component options.
func Provide ¶ added in v0.4.0
func Provide(constructor di.Constructor, options ...di.ProvideOption) ComponentOption
Provide returns container option that provides to container reliable way to build type. The constructor will be invoked lazily on-demand. For more information about constructors see di.Constructor interface. di.ProvideOption can add additional behavior to the process of type resolving.
func Supply ¶ added in v0.4.0
func Supply(value di.Value, options ...di.ProvideOption) ComponentOption
Supply provides value as is.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is a slice mutable context.
func (*Context) Done ¶
func (c *Context) Done() <-chan struct{}
Done implements context.Context interface.
type Dispatcher ¶
type Dispatcher interface {
// Run runs your application. Context will be canceled if application get
// syscall.SIGINT or syscall.SIGTERM. Example implementation handles application
// shutdown and worker errors:
//
// func(d *ExampleDispatcher) Run(ctx context.Context) (err error) {
// errChan := make(chan error)
// go func() {
// errChan <- d.Worker.Start()
// }
// select {
// // application shutdown
// case <-ctx.Done():
// return ctx.Err()
// case err = <-errChan:
// }
// return err
// }
Run(ctx context.Context) (err error)
}
Dispatcher controls application lifecycle.
type Env ¶
type Env string
Env
type Hook ¶
type Hook struct {
// BeforeStart invokes function before application start.
BeforeStart di.Invocation
// BeforeShutdown invokes function before application shutdown.
BeforeShutdown di.Invocation
}
Hook
type Info ¶
type Info struct {
// The Application name.
Name string
// The raw value of APP_ENV environment variable. Due to the abundance of possible
// application launch environments, this is a raw value.
Env Env
// The debug flag.
Debug bool
}
The application information.
type Logger ¶
type Logger interface {
Printf(bundle string, format string, values ...interface{})
Fatal(err error)
}
Logger
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configure slice.
func ShutdownTimeout ¶ added in v0.4.0
ShutdownTimeout sets application shutdown timeout.
func StartTimeout ¶
StartTimeout sets application boot timeout.
func WithBundles ¶
WithBundles registers application bundles.
func WithComponents ¶
func WithComponents(components ...ComponentOption) Option
WithComponents contains component options.
func WithLogger ¶ added in v0.4.0
WithLogger sets application logger.
func WithName ¶
WithName sets application name. In case you need to change the name, you can use the APP_NAME environment variable.
func WithParameterParser ¶
func WithParameterParser(parser ParameterParser) Option
WithParameterParser sets parser for application.
func WithParameters ¶
WithParameters adds parameters to container. On boot stage all parameter structures will be processed via ParameterParser.