runconsumer

package
v2.0.200+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(app Application)

Types

type Application

type Application interface {
	consumer.Application

	// NewConfig returns a new, zero-valued Config instance.
	NewConfig() Config
	// InitApplication initializes the Application, eg by starting related
	// services and registering implemented service APIs.
	InitApplication(InitArgs) error
}

Application interface run by Run.

type BaseConfig

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 mbp.ClientConfig `group:"Broker" namespace:"broker" env-namespace:"BROKER"`

	Etcd struct {
		mbp.EtcdConfig

		Prefix string `` /* 127-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 Config

type Config interface {
	// GetBaseConfig of the Config.
	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
}

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