bootstrap

package
v0.29.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 17 Imported by: 34

Documentation

Index

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"`
	SSLMode      string `toml:"sslmode" comment:"default is disable, use require for ssl"`
	SSLCert      string `toml:"sslcert"`
	SSLKey       string `toml:"sslkey"`
	SSLRootcert  string `toml:"sslrootcert"`
}

type Info added in v0.2.0

type Info struct {
	AppName       string             `json:"app_name"`
	Version       string             `json:"version"`
	LauncherStats task.LauncherStats `json:"launcher,omitempty"`
}

type NewRunner added in v0.2.0

type NewRunner func(*Starter) Runner

type NilValidator

type NilValidator struct{}

NilValidator satisfies the Validator interface but does nothing.

func (*NilValidator) Validate

func (v *NilValidator) Validate() error

type Runner added in v0.2.0

type Runner interface {
	Run(ctx context.Context) error
	Info() interface{}
}

type Starter added in v0.29.0

type Starter struct {
	Utility    `toml:"-"`
	StatusPort int `toml:"status_port" comment:"http service port for request health status"`

	// options
	BusOpt      bus.Options           `toml:"bus"`
	LauncherOpt *task.LauncherOptions `toml:"launcher"`
	// contains filtered or unexported fields
}

func NewTaskMaster added in v0.2.0

func NewTaskMaster(appName string, initFn NewRunner, options Validator) *Starter

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 options. Note that the bootstrapped WorkerApp already provides bus and launcher options

func NewWorkerApp

func NewWorkerApp(tskType string, newWkr task.NewWorker, options Validator) *Starter

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 options. Note that the bootstrapped Worker already provides bus and launcher options

func (*Starter) AppOpt added in v0.29.0

func (tm *Starter) AppOpt() any

func (*Starter) Description added in v0.29.0

func (tm *Starter) Description(description string) *Starter

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 (*Starter) HandleRequest added in v0.29.0

func (tm *Starter) 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 (*Starter) Initialize added in v0.29.0

func (tm *Starter) Initialize() *Starter

Initialize is non-blocking and will perform application startup tasks such as: *Parsing and handling flags *Parsing and validating the options file *Setting options 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 (*Starter) NewConsumer added in v0.29.0

func (tm *Starter) NewConsumer() bus.Consumer

NewConsumer is a convenience method that will use the bus options 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 (*Starter) NewProducer added in v0.29.0

func (tm *Starter) NewProducer() bus.Producer

NewProducer will use the bus options information to create a new producer instance.

func (*Starter) Run added in v0.29.0

func (tm *Starter) Run()

Run until the application is complete and then exit.

func (*Starter) SetHandler added in v0.29.0

func (tm *Starter) SetHandler(fn func(http.ResponseWriter, *http.Request))

SetHandler will overwrite the current HandleRequest function on root requests

func (*Starter) Version added in v0.29.0

func (tm *Starter) Version(version string) *Starter

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 {
	Validator
	// contains filtered or unexported fields
}

func NewUtility added in v0.2.0

func NewUtility(name string, config Validator) *Utility

func (*Utility) AddInfo added in v0.3.0

func (u *Utility) AddInfo(info func() interface{}, port int) *Utility

func (*Utility) Description added in v0.2.0

func (u *Utility) Description(description string) *Utility

func (*Utility) Initialize added in v0.2.0

func (u *Utility) Initialize() *Utility

func (*Utility) Version added in v0.2.0

func (u *Utility) Version(version string) *Utility

type Validator

type Validator interface {
	Validate() error
}

Validator provides a standard method for running underlying validation for underlying object values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL