Documentation ¶
Overview ¶
Package app provides an application level context
This provides you with a logger, a tracer and a viper config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrModuleUnknown returned when no module can be found for the specified key ErrModuleUnknown error // Version of the application Version string )
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface { // Add modules to the application context Add(...Module) error // Get the module at the specified key, thread-safe Get(Key) interface{} // Get the module at the specified key, thread-safe GetOK(Key) (interface{}, bool) // Set the module at the specified key, this should be safe across multiple threads Set(Key, interface{}) error // Logger gets the root logger for this application Logger() logrus.FieldLogger // NewLogger creates a new named logger for this application NewLogger(string, logrus.Fields) logrus.FieldLogger // Tracer returns the root Tracer() tracing.Tracer // Config returns the viper config for this application Config() *viper.Viper // Info returns the app info object for this application Info() cjm.AppInfo // Init the application and its modules with the config. Init() error // Start the application an its enabled modules Start() error // Stop the application an its enabled modules Stop() error }
Application is an application level context package It can be used as a kind of dependency injection container
func New ¶
func New(nme string) (Application, error)
New application with the specified name, at the specified basepath
func NewWithConfig ¶
func NewWithConfig(nme string, configPath string) (Application, error)
NewWithConfig application with the specified name, with a specific config file path
type Init ¶
type Init func(Application) error
Init is an initializer for an initalization function
func (Init) Call ¶
func (fn Init) Call(app Application) error
Call implements the callback interface
type Key ¶
type Key string
A Key represents a key for a module. Users of this package can define their own keys, this is just the type definition.
type LifecycleCallback ¶
type LifecycleCallback interface {
Call(Application) error
}
LifecycleCallback function definition
type Module ¶
type Module interface { Init(Application) error Start(Application) error Stop(Application) error Reload(Application) error }
A Module is a component that has a specific lifecycle
func MakeModule ¶
func MakeModule(callbacks ...LifecycleCallback) Module
MakeModule by passing the callback functions. You can pass multiple callback functions of the same type if you want
type Reload ¶
type Reload func(Application) error
Reload is an initalizater for a reload function
func (Reload) Call ¶
func (fn Reload) Call(app Application) error
Call implements the callback interface
type Start ¶
type Start func(Application) error
Start is an initializer for a start function
func (Start) Call ¶
func (fn Start) Call(app Application) error
Call implements the callback interface
type Stop ¶
type Stop func(Application) error
Stop is an initializer for a stop function
func (Stop) Call ¶
func (fn Stop) Call(app Application) error
Call implements the callback interface
Directories ¶
Path | Synopsis |
---|---|
Package logging provides a configuration model for logrus.
|
Package logging provides a configuration model for logrus. |
Package tracing implements a super simple tracer/profiler based on go-metrics.
|
Package tracing implements a super simple tracer/profiler based on go-metrics. |