Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnitRegister ¶
func UnitRegister(unit UnitConfig)
Types ¶
type App ¶
type App interface { Run() int // Run application Flags() Flags // Return command-line flags Log() Logger // Return logger unit Timer() Timer // Return timer unit Bus() Bus // Return event bus unit Unit(string) Unit // Return singular unit for name Units(string) []Unit // Return multiple units for name }
type Bus ¶
type Bus interface { Unit Emit(Event) // Emit an event on the bus NewHandler(string, EventHandler) // Register an event handler for an event name }
Bus unit - handles events
type Config ¶
type Config interface { Name() string // Returns name of the unit New(Logger) (Unit, error) // Opens the driver from configuration, or returns error }
Unit configuration interface
type ConfigFunc ¶
type Event ¶
type Event interface { Source() Unit // Source of the event Name() string // Name of the event NS() EventNS // Namespace for the event Value() interface{} // Any value associated with the event }
Event emitted on the event bus
type EventHandler ¶
type EventHandler func(Event) // Handler for an emitted event
type Flags ¶
type Flags interface { Name() string // Return name of flagset Args() []string // Args returns the command line arguments HasFlag(string) bool // HasFlag returns true if a flag exists FlagBool(name string, value bool, usage string) *bool FlagString(name, value, usage string) *string FlagDuration(name string, value time.Duration, usage string) *time.Duration FlagInt(name string, value int, usage string) *int FlagUint(name string, value uint, usage string) *uint FlagFloat64(name string, value float64, usage string) *float64 GetBool(string) bool GetString(string) string GetDuration(string) time.Duration GetInt(string) int GetUint(string) uint GetFloat64(string) float64 }
type Logger ¶
type Logger interface { Unit Name() string // Return unit name Error(error) error // Output logging messages Debug(args ...interface{}) // Debug output IsDebug() bool // Return IsDebug flag }
Abstract logging interface
type LoggerBase ¶
type LoggerBase struct { UnitBase // contains filtered or unexported fields }
LoggerBase is the struct for any logger
func (*LoggerBase) Debug ¶
func (this *LoggerBase) Debug(args ...interface{})
func (*LoggerBase) Error ¶
func (this *LoggerBase) Error(err error) error
func (*LoggerBase) IsDebug ¶
func (this *LoggerBase) IsDebug() bool
func (*LoggerBase) Name ¶
func (this *LoggerBase) Name() string
type MainCommandFunc ¶
type Timer ¶
type Timer interface { Unit NewTicker(time.Duration) TimerId // Create periodic event at interval NewTimer(time.Duration) TimerId // Create one-shot event after interval Cancel(TimerId) error // Cancel events }
Timer unit - sends out messages on the event bus
type Unit ¶
type Unit interface { Close() error // Close closes the driver and frees the underlying resources String() string // String returns a string representation of the unit }
Unit interface
type UnitConfig ¶
type UnitConfig struct { Name string // Unique name of the unit Type UnitType // Unit type Requires []string // Unit dependencies Config ConfigFunc }
func UnitsByName ¶
func UnitsByName(unitName string) []UnitConfig
func UnitsByType ¶
func UnitsByType(unitType UnitType) []UnitConfig
func (UnitConfig) String ¶
func (u UnitConfig) String() string
Click to show internal directories.
Click to hide internal directories.