v0.99.0 Latest Latest

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 17 Imported by: 6



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.



This section is empty.


This section is empty.


func Main

func Main(app Application)


type Application

type Application interface {

	// 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

type BaseConfig struct {
	Consumer struct {
		Limit          uint32        `long:"limit" env:"LIMIT" default:"32" description:"Maximum number of Shards this consumer process will allocate"`
		MaxHotStandbys uint32        `` /* 165-byte string literal not displayed */
		WatchDelay     time.Duration `` /* 188-byte string literal not displayed */
	} `group:"Consumer" namespace:"consumer" env-namespace:"CONSUMER"`

	Broker struct {
		FileRoot string `` /* 132-byte string literal not displayed */
	} `group:"Broker" namespace:"broker" env-namespace:"BROKER"`

	Etcd struct {

		Prefix string `` /* 130-byte string literal not displayed */
	} `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 (BaseConfig) GetBaseConfig

func (c BaseConfig) GetBaseConfig() BaseConfig

GetBaseConfig returns itself, and trivially implements the Config interface.

type Cmd added in v0.89.0

type Cmd struct {
	Cfg Config
	App Application

Cmd wraps a Config and Application to provide an Execute entry-point.

func (Cmd) Execute added in v0.89.0

func (sc Cmd) Execute(args []string) error

type Config

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

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.

Jump to

Keyboard shortcuts

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