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.
    	// 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 {
      		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 `` /* 132-byte string literal not displayed */
      	} `group:"Broker" namespace:"broker" env-namespace:"BROKER"`
      
      	Etcd struct {
      		mbp.EtcdConfig
      
      		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 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.

              Source Files