Documentation ¶
Index ¶
- Variables
- func BuildEnvConfigName(name ...string) string
- func ReadEnvConfig(c interface{}, path ...string) error
- type App
- func (a *App) AddHttp(handler http.Handler, port int)
- func (a *App) AddPrometheus(path string, port int)
- func (a *App) AddSQS(prefix string, handler MsgHandler)
- func (a *App) AddSQSWithConfig(config *SQSWorkerConfig, handler MsgHandler)
- func (a *App) AddTask(t Task)
- func (a *App) AddTaskFunc(t TaskFunc)
- func (a App) ReadConfig(c interface{}, name ...string) error
- func (a *App) Start()
- func (a App) Stop()
- type AppConfig
- type Deleter
- type Metrics
- type MsgContext
- type MsgHandler
- type MsgHandlerFunc
- type MsgRouter
- type PrometheusConfig
- type Queue
- type QueueConfig
- type Receiver
- type SQSWorkerConfig
- type Sender
- type Task
- type TaskFunc
Constants ¶
This section is empty.
Variables ¶
var (
NoMsgTypeErr = errors.New("no msgType attribute found on message")
)
Functions ¶
func BuildEnvConfigName ¶
BuildEnvConfigName will format an environment variable name string from the supplied parts.
func ReadEnvConfig ¶
ReadEnvConfig will read values from environment variables into the matching fields in c. The path argument specifies the names that will become underscore delimited to build the full environment variable name.
Types ¶
type App ¶
type App struct { Metrics *Metrics // contains filtered or unexported fields }
App holds config and state comprising the app.
func (*App) AddPrometheus ¶
AddPrometheus adds an HTTP server and metrics endpoint to allow collection of Prometheus metrics.
func (*App) AddSQS ¶
func (a *App) AddSQS(prefix string, handler MsgHandler)
func (*App) AddSQSWithConfig ¶
func (a *App) AddSQSWithConfig(config *SQSWorkerConfig, handler MsgHandler)
func (*App) AddTaskFunc ¶
func (App) ReadConfig ¶
ReadConfig will read configuration environment variables into c. The supplied name elements are appended to the app name to form a full environment variable name.
type AppConfig ¶
type AppConfig struct { Name string Env string `default:"dev"` Prometheus PrometheusConfig }
AppConfig holds configuration data for the app.
func NewAppConfig ¶
NewAppConfig returns a pointer to a new AppConfig.
func (AppConfig) WithMetrics ¶
WithMetrics adds Prometheus metrics configuration with prefix being the metric name prefix for any subsequently created metrics.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics(config PrometheusConfig) *Metrics
func (Metrics) NewCounterVec ¶
func (m Metrics) NewCounterVec(name string, help string, labelNames []string) *prometheus.CounterVec
func (Metrics) NewHistogramVec ¶
func (m Metrics) NewHistogramVec(name string, help string, labelNames []string) *prometheus.HistogramVec
type MsgHandler ¶
type MsgHandler interface {
Process(msg *MsgContext) error
}
type MsgHandlerFunc ¶
type MsgHandlerFunc func(msg *MsgContext) error
func (MsgHandlerFunc) Process ¶
func (f MsgHandlerFunc) Process(msg *MsgContext) error
type MsgRouter ¶
type MsgRouter struct {
// contains filtered or unexported fields
}
MsgRouter handles routing messages to handlers based on the message's msgType.
func NewMsgRouter ¶
func NewMsgRouter() *MsgRouter
func (*MsgRouter) Handle ¶
func (r *MsgRouter) Handle(msgType string, handler MsgHandler)
Handle registers handler to receive messages of msgType.
func (*MsgRouter) HandleFunc ¶
func (r *MsgRouter) HandleFunc(msgType string, handler MsgHandlerFunc)
Handle registers handler to receive messages of msgType.
func (MsgRouter) Process ¶
func (r MsgRouter) Process(msg *MsgContext) error
Process will pass msg to the registered handler for the message's message type.
type PrometheusConfig ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
type QueueConfig ¶
func NewQueueConfig ¶
func NewQueueConfig(msgTypeKey string) *QueueConfig
type Receiver ¶
type Receiver interface {
Receive(ctx context.Context, queue string, max int) ([]*sqs.Message, error)
}
Receiver is an interface for receiving messages from a queue.
type SQSWorkerConfig ¶
func NewSQSWorkerConfig ¶
func NewSQSWorkerConfig() *SQSWorkerConfig