Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface {
// Cannot be invoked once the application has been initialised.
ParseConfig()
// Initialises the application object.
//
// This must be called, as it does several things to set up the
// various facilities (such as logging) used by the application.
Init()
// Run the application.
//
// This enters the application's event loop, which will block until
// the application is subsequently terminated.
Run()
// Terminate the application.
//
// Breaks out of the event loop, returning control back to the calling
// function.
Terminate()
// Return the application's pretty name.
Name() string
// Return the application's version.
Version() *semver.SemVer
// Return the application's version control commit identifier.
Commit() string
// Return the application's context.
Context() context.Context
// Set the parent context for the application.
//
// Danger. Setting this while the application is running can cause
// unintended side effects due to the old context's cancel function
// being executed.
//
// It is advisable to run this prior to initialisation.
SetContext(context.Context)
// Return the application's process manager instance.
ProcessManager() process.Manager
// Return the application's logger instance.
Logger() logger.Logger
// Return the application's configuration.
Configuration() config.Config
// Set the callback that will be invoked when the application starts.
//
// If not set, then the default startup handler will be invoked.
//
// This cannot be set once the application has been initialised.
SetOnStart(CallbackFn)
// Set the callback that will be invoked when the application exits.
//
// If not set, then the default exit handler will be invoked.
//
/// This cannot be set once the application has been initialised.
SetOnExit(CallbackFn)
// Set the callback that will be invoked whenever the event loop
// fires.
//
// If not set, then the default main loop callback will be invoked.
//
// This cannot be set once the application has been initialised.
SetMainLoop(MainLoopFn)
// Is the application running?
IsRunning() bool
// Is the application in 'debug' mode.
IsDebug() bool
// Add a responder to the application's responder chain.
AddResponder(responder.Respondable) (responder.Respondable, error)
// Remove a responder from the application's responder chain.
RemoveResponder(responder.Respondable) bool
// Send an event to the application's responder.
//
// Event will be consumed by the first responder that handles it.
SendFirstResponder(events.Event) (events.Event, bool)
// Send an event to all the application's responders.
SendAllResponders(events.Event) []events.Event
// Return the name of the application's responder chain.
//
// Implements `Respondable`.
Type() string
// Ascertain if any of the application's responders will respond to
// an event.
//
// The first responder found that responds to the event will result
// in `true` being returned.
//
// Implements `Respondable`.
RespondsTo(events.Event) bool
// Send an event to the application's responders.
//
// The first object that can respond to the event will consume it.
//
// Implements `Respondable`.
Invoke(events.Event) events.Event
}
Application.
type Config ¶ added in v0.3.3
type Config struct {
// The application's pretty name.
Name string
// The application's version number.
Version *semver.SemVer
// The application's configuration.
AppConfig any
// Validators used to validate the application's configuration.
Validators config.ValidatorsMap
// Require CLI flags like '-config' to be provided?
RequireCLI bool
}
Application configuration.
type SignalResponder ¶ added in v1.0.6
type SignalResponder struct {
// contains filtered or unexported fields
}
Signal responder.
func NewSignalResponder ¶ added in v1.0.6
func NewSignalResponder() *SignalResponder
func (*SignalResponder) Invoke ¶ added in v1.0.6
func (sr *SignalResponder) Invoke(evt events.Event) events.Event
Invokes the given event.
func (*SignalResponder) Name ¶ added in v1.0.6
func (sr *SignalResponder) Name() string
Returns the name of the responder.
func (*SignalResponder) RespondsTo ¶ added in v1.0.6
func (sr *SignalResponder) RespondsTo(evt events.Event) bool
Returns whether the responder can respond to a given event.
func (*SignalResponder) SetOnSignal ¶ added in v1.0.6
func (sr *SignalResponder) SetOnSignal(callback OnSignalFn)
Sets the callback function.
func (*SignalResponder) Type ¶ added in v1.0.6
func (sr *SignalResponder) Type() string
Returns the type of the responder.
Click to show internal directories.
Click to hide internal directories.