Documentation
¶
Index ¶
- type DBOptions
- type Duration
- type NilValidator
- type Validator
- type WorkerApp
- func (a *WorkerApp) Description(description string) *WorkerApp
- func (a *WorkerApp) FileOpts() *WorkerApp
- func (a *WorkerApp) GetFileOpts() *file.Options
- func (a *WorkerApp) Initialize()
- func (a *WorkerApp) Log(format string, v ...interface{})
- func (a *WorkerApp) Logger() *log.Logger
- func (a *WorkerApp) MySQLDB() *sql.DB
- func (a *WorkerApp) MySQLOpts() *WorkerApp
- func (a *WorkerApp) NewConsumer(topic, channel string) bus.Consumer
- func (a *WorkerApp) NewProducer() bus.Producer
- func (a *WorkerApp) PostgresDB() *sql.DB
- func (a *WorkerApp) PostgresOpts() *WorkerApp
- func (a *WorkerApp) Run()
- func (a *WorkerApp) SetLogger(lgr *log.Logger) *WorkerApp
- func (a *WorkerApp) TaskType() string
- func (a *WorkerApp) Version(version string) *WorkerApp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
Duration is a wrapper around time.Duration and allows for automatic toml string parsing of time.Duration values. Use this type in a custom config for automatic serializing and de-serializing of time.Duration.
func (*Duration) MarshalTOML ¶
func (*Duration) UnmarshalText ¶
type NilValidator ¶
type NilValidator struct{}
NilValidator satisfies the Validator interface but does nothing.
func (*NilValidator) Validate ¶
func (v *NilValidator) Validate() error
type Validator ¶
type Validator interface {
Validate() error
}
Validator provides a standard method for running underlying validation for underlying object values.
type WorkerApp ¶
type WorkerApp struct {
// contains filtered or unexported fields
}
func NewWorkerApp ¶
NewWorkerApp will create a new worker bootstrap application. *tskType: defines the worker type; the type of tasks the worker is expecting. Also acts as a name for identification (required) *mkr: MakeWorker function that the launcher will call to create a new worker. *options: a struct pointer to additional specific application config options. Note that
the bootstrapped WorkerApp already provides bus and launcher config options and the user can request to add postgres and mysql config options.
func (*WorkerApp) Description ¶
Description allows the user to set a description of the worker that will be shown with the help screen.
The description should also include information about what the worker expects from the NewWorker 'info' string.
func (*WorkerApp) GetFileOpts ¶
func (*WorkerApp) Initialize ¶
func (a *WorkerApp) Initialize()
Start is non-blocking and will perform application startup tasks such as: *Parsing and handling flags *Parsing and validating the config file *Setting config defaults
Note that start will handle application closure if there was an error during startup or a flag option was provided that asked the application to show the version, for example. So, if start is able to finish by returning, the user knows it is safe to move on.
func (*WorkerApp) MySQLDB ¶
MySQLDB returns the MySQL sql.DB application connection. Will be nil if called before Start() or MySQLOpts() was not called.
func (*WorkerApp) MySQLOpts ¶
MySQLOpts will parse mysql db connection options from the config toml file.
If using mysql options then a mysql db connection is made during startup. The mysql db connection is available through the MySQL() method.
MySQLOpts needs to be called before Start() to be effective.
If the user needs more than one db connection then those connection options need to be made available with the WorkerApp initialization. Note that the DBOptions struct is available to use in this way.
func (*WorkerApp) NewConsumer ¶
NewConsumer is a convenience method that will use the bus config information to create a new consumer instance. Can optionally provide a topic and channel on which to consume. All other bus options are the same.
func (*WorkerApp) NewProducer ¶
NewProducer will use the bus config information to create a new producer instance.
func (*WorkerApp) PostgresDB ¶
PostgresDB returns the Postgres sql.DB application connection. Will be nil if called before Start() or PostgresOpts() was not called.
func (*WorkerApp) PostgresOpts ¶
PostgresOpts will parse postgres db connection options from the config toml file.
If using postgres options then a postgres db connection is made during startup. The postgres db connection is available through the Postgres() method.
PostgresOpts needs to be called before Start() to be effective.
If the user needs more than one db connection then those connection options need to be made available with the WorkerApp initialization. Note that the DBOptions struct is available to use in this way.
func (*WorkerApp) Run ¶
func (a *WorkerApp) Run()
Run will run until the application is complete and then exit.
func (*WorkerApp) SetLogger ¶
SetLogger allows the user to override the default application logger (stdout) with a custom one.
If the provided logger is nil the logger output is discarded.
SetLogger should be called before initializing the application.