Documentation ¶
Index ¶
- type DBOptions
- type Duration
- type Info
- type NewRunner
- type NilValidator
- type Runner
- type TaskMaster
- func (tm *TaskMaster) AppName() string
- func (tm *TaskMaster) AppOpt() interface{}
- func (tm *TaskMaster) Description(description string) *TaskMaster
- func (tm *TaskMaster) FileOpts() *TaskMaster
- func (tm *TaskMaster) GetBusOpts() *bus.Options
- func (tm *TaskMaster) GetFileOpts() *file.Options
- func (tm *TaskMaster) HandleRequest(w http.ResponseWriter, r *http.Request)
- func (tm *TaskMaster) HttpPort() int
- func (tm *TaskMaster) Initialize() *TaskMaster
- func (tm *TaskMaster) Log(format string, v ...interface{})
- func (tm *TaskMaster) Logger() *log.Logger
- func (tm *TaskMaster) MySQLDB() *sql.DB
- func (tm *TaskMaster) MySQLOpts() *TaskMaster
- func (tm *TaskMaster) NewConsumer() bus.Consumer
- func (tm *TaskMaster) NewProducer() bus.Producer
- func (tm *TaskMaster) PostgresDB() *sql.DB
- func (tm *TaskMaster) PostgresOpts() *TaskMaster
- func (tm *TaskMaster) Run()
- func (tm *TaskMaster) SetHandler(fn func(http.ResponseWriter, *http.Request))
- func (tm *TaskMaster) SetLogger(lgr *log.Logger) *TaskMaster
- func (tm *TaskMaster) Version(version string) *TaskMaster
- type Utility
- type Validator
- type Worker
- func (w *Worker) Description(description string) *Worker
- func (w *Worker) FileOpts() *Worker
- func (w *Worker) GetFileOpts() *file.Options
- func (w *Worker) HandleRequest(wr http.ResponseWriter, r *http.Request)
- func (w *Worker) HttpPort() int
- func (w *Worker) InfoStats() Info
- func (w *Worker) Initialize() *Worker
- func (w *Worker) Log(format string, v ...interface{})
- func (w *Worker) Logger() *log.Logger
- func (w *Worker) MySQLDB() *sql.DB
- func (w *Worker) MySQLOpts() *Worker
- func (w *Worker) NewConsumer(topic, channel string) bus.Consumer
- func (w *Worker) NewProducer() bus.Producer
- func (w *Worker) PostgresDB() *sql.DB
- func (w *Worker) PostgresOpts() *Worker
- func (w *Worker) Run()
- func (w *Worker) SetLogger(lgr *log.Logger) *Worker
- func (w *Worker) TaskType() string
- func (w *Worker) Version(version string) *Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBOptions ¶
type DBOptions struct { Username string `toml:"username" commented:"true"` Password string `toml:"password" commented:"true"` Host string `toml:"host" comment:"host can be 'host:port', 'host', 'host:' or ':port'"` DBName string `toml:"dbname"` Serializable bool `toml:"serializable" comment:"set isolation level to serializable, required for proper writing to database" commented:"true"` }
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 NewRunner ¶ added in v0.2.0
type NewRunner func(*TaskMaster) Runner
type NilValidator ¶
type NilValidator struct{}
NilValidator satisfies the Validator interface but does nothing.
func (*NilValidator) Validate ¶
func (v *NilValidator) Validate() error
type TaskMaster ¶ added in v0.2.0
type TaskMaster struct {
// contains filtered or unexported fields
}
func NewTaskMaster ¶ added in v0.2.0
func NewTaskMaster(appName string, initFn NewRunner, options Validator) *TaskMaster
NewTaskMaster will create a new taskmaster bootstrap application. *appName: defines the taskmaster name; acts as a name for identification and easy-of-use (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 (*TaskMaster) AppName ¶ added in v0.2.0
func (tm *TaskMaster) AppName() string
AppName returns the AppName initialized with the WorkerApp.
func (*TaskMaster) AppOpt ¶ added in v0.2.0
func (tm *TaskMaster) AppOpt() interface{}
func (*TaskMaster) Description ¶ added in v0.2.0
func (tm *TaskMaster) Description(description string) *TaskMaster
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 (*TaskMaster) FileOpts ¶ added in v0.2.0
func (tm *TaskMaster) FileOpts() *TaskMaster
FileOpts provides file options such as aws connection info.
func (*TaskMaster) GetBusOpts ¶ added in v0.6.1
func (tm *TaskMaster) GetBusOpts() *bus.Options
func (*TaskMaster) GetFileOpts ¶ added in v0.2.0
func (tm *TaskMaster) GetFileOpts() *file.Options
func (*TaskMaster) HandleRequest ¶ added in v0.2.0
func (tm *TaskMaster) HandleRequest(w http.ResponseWriter, r *http.Request)
HandleRequest is a simple http handler function that takes the compiled status functions that are called and the results marshaled to return as the body of the response
func (*TaskMaster) HttpPort ¶ added in v0.2.0
func (tm *TaskMaster) HttpPort() int
HttpPort gets the application http port for requesting a heath check on the application itself.
func (*TaskMaster) Initialize ¶ added in v0.2.0
func (tm *TaskMaster) Initialize() *TaskMaster
Initialize 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 (*TaskMaster) Log ¶ added in v0.2.0
func (tm *TaskMaster) Log(format string, v ...interface{})
Log is a wrapper around the application logger Printf method.
func (*TaskMaster) Logger ¶ added in v0.2.0
func (tm *TaskMaster) Logger() *log.Logger
Logger returns a reference to the application logger.
func (*TaskMaster) MySQLDB ¶ added in v0.2.0
func (tm *TaskMaster) MySQLDB() *sql.DB
MySQLDB returns the MySQL sql.DB application connection. Will be nil if called before Start() or MySQLOpts() was not called.
func (*TaskMaster) MySQLOpts ¶ added in v0.2.0
func (tm *TaskMaster) MySQLOpts() *TaskMaster
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 (*TaskMaster) NewConsumer ¶ added in v0.2.0
func (tm *TaskMaster) NewConsumer() bus.Consumer
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 (*TaskMaster) NewProducer ¶ added in v0.2.0
func (tm *TaskMaster) NewProducer() bus.Producer
NewProducer will use the bus config information to create a new producer instance.
func (*TaskMaster) PostgresDB ¶ added in v0.2.0
func (tm *TaskMaster) PostgresDB() *sql.DB
PostgresDB returns the Postgres sql.DB application connection. Will be nil if called before Start() or PostgresOpts() was not called.
func (*TaskMaster) PostgresOpts ¶ added in v0.2.0
func (tm *TaskMaster) PostgresOpts() *TaskMaster
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 (*TaskMaster) Run ¶ added in v0.2.0
func (tm *TaskMaster) Run()
Run until the application is complete and then exit.
func (*TaskMaster) SetHandler ¶ added in v0.6.0
func (tm *TaskMaster) SetHandler(fn func(http.ResponseWriter, *http.Request))
SetHandler will overwrite the current HandleRequest function on root requests
func (*TaskMaster) SetLogger ¶ added in v0.2.0
func (tm *TaskMaster) SetLogger(lgr *log.Logger) *TaskMaster
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.
func (*TaskMaster) Version ¶ added in v0.2.0
func (tm *TaskMaster) Version(version string) *TaskMaster
Version sets the application version. The version is what is shown if the '-version' flag is specified when running the WorkerApp.
type Utility ¶ added in v0.2.0
type Utility struct {
// contains filtered or unexported fields
}
func NewUtility ¶ added in v0.2.0
func (*Utility) Description ¶ added in v0.2.0
func (*Utility) Initialize ¶ added in v0.2.0
func (u *Utility) Initialize()
type Validator ¶
type Validator interface {
Validate() error
}
Validator provides a standard method for running underlying validation for underlying object values.
type Worker ¶ added in v0.2.0
type Worker struct { Info // info stats on various worker types // 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 Worker already provides bus and launcher config options and the user can request to add postgres and mysql config options.
func (*Worker) Description ¶ added in v0.2.0
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 (*Worker) FileOpts ¶ added in v0.2.0
FileOpts provides file options such as aws connection info.
func (*Worker) GetFileOpts ¶ added in v0.2.0
func (*Worker) HandleRequest ¶ added in v0.2.0
func (w *Worker) HandleRequest(wr http.ResponseWriter, r *http.Request)
HandleRequest is a simple http handler function that takes the compiled status functions that are called and the results marshaled to return as the body of the response
func (*Worker) HttpPort ¶ added in v0.2.0
HttpPort gets the application http port for requesting a heath check on the application itself. If the port is not provided The port should alwasy be provided
func (*Worker) Initialize ¶ added in v0.2.0
Initialize 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 Initialize 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 Initialize is able to finish by returning, the user knows it is safe to move on.
func (*Worker) MySQLDB ¶ added in v0.2.0
MySQLDB returns the MySQL sql.DB application connection. Will be nil if called before Start() or MySQLOpts() was not called.
func (*Worker) MySQLOpts ¶ added in v0.2.0
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 Worker initialization. Note that the DBOptions struct is available to use in this way.
func (*Worker) NewConsumer ¶ added in v0.2.0
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 (*Worker) NewProducer ¶ added in v0.2.0
NewProducer will use the bus config information to create a new producer instance.
func (*Worker) PostgresDB ¶ added in v0.2.0
PostgresDB returns the Postgres sql.DB application connection. Will be nil if called before Start() or PostgresOpts() was not called.
func (*Worker) PostgresOpts ¶ added in v0.2.0
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 Worker initialization. Note that the DBOptions struct is available to use in this way.
func (*Worker) Run ¶ added in v0.2.0
func (w *Worker) Run()
Run will run until the application is complete and then exit.
func (*Worker) SetLogger ¶ added in v0.2.0
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.