import "go.gazette.dev/core/mainboilerplate/runconsumer"
Package runconsumer extends consumer.Application with support for configuration and application initialization. It provides a Main function which executes the full consumer life-cycle, including config parsing, service bootstrap, and Shard serving.
func Main(app Application)
type Application interface { consumer.Application // NewConfig returns a new, zero-valued Config instance. // Main calls NewConfig to obtain a new instance of the Application's // custom configuration type. It will next use `go-flags` to parse // command-line and environment flags into the provide Config, in order // to provide the Application with a complete configuration. NewConfig() Config // InitApplication initializes the Application. // Main calls InitApplication after parsing the Config and binding // HTTP and gRPC servers, but before announcing this process's // MemberSpec. // // InitApplication is a good opportunity to register additional gRPC // services or perform other initialization. InitApplication(InitArgs) error }
Application is the user-defined consumer Application which is executed by Main. It extends consumer.Application with callbacks to support custom configuration parsing and initialization.
type BaseConfig struct { Consumer struct { mbp.ServiceConfig Limit uint32 `long:"limit" env:"LIMIT" default:"32" description:"Maximum number of Shards this consumer process will allocate"` } `group:"Consumer" namespace:"consumer" env-namespace:"CONSUMER"` Broker struct { mbp.ClientConfig FileRoot string `long:"file-root" env:"FILE_ROOT" description:"Local path which roots file:// fragment URLs which are being directly read (optional)"` } `group:"Broker" namespace:"broker" env-namespace:"BROKER"` Etcd struct { mbp.EtcdConfig Prefix string `long:"prefix" env:"PREFIX" default-mask:"/gazette/consumers/app-name-and-release" description:"Etcd prefix for the consumer group"` } `group:"Etcd" namespace:"etcd" env-namespace:"ETCD"` Log mbp.LogConfig `group:"Logging" namespace:"log" env-namespace:"LOG"` Diagnostics mbp.DiagnosticsConfig `group:"Debug" namespace:"debug" env-namespace:"DEBUG"` }
BaseConfig is the top-level configuration object of a Gazette consumer.
func (c BaseConfig) GetBaseConfig() BaseConfig
GetBaseConfig returns itself, and trivially implements the Config interface.
type Config interface { GetBaseConfig() BaseConfig }
Config is the top-level configuration object of an Application. It must be parse-able by `go-flags`, and must present a BaseConfig.
type InitArgs struct { // Context of the service. Typically this is context.Background(), // but tests may prefer to use a scoped context. Context context.Context // Config previously returned by NewConfig, and since parsed into. Config Config // Server is a dual HTTP and gRPC Server. Applications may register // APIs they implement against the Server mux. Server *server.Server // Service of the consumer. Applications may use the Service to power Shard // resolution, request proxying, and state inspection. Service *consumer.Service // Tasks are independent, cancelable goroutines having the lifetime of // the consumer, such as service loops and the like. Applications may // add additional tasks which should be started with the consumer. Tasks *task.Group }
InitArgs are arguments passed to Application.InitApplication.
Package runconsumer imports 16 packages (graph) and is imported by 19 packages. Updated 2020-10-01. Refresh now. Tools for package owners.