mainboilerplate

package
v2.0.206+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPrintConfigCmd

func AddPrintConfigCmd(parser *flags.Parser, configName string)

AddPrintConfigCmd to the Parser. The "print-config" command helps users test whether their applications are correctly configured, by exporting all runtime configuration in INI format.

func AnnounceServeAndAllocate

func AnnounceServeAndAllocate(etcd EtcdContext, srv *server.Server, state *allocator.State, spec memberSpec)

AnnounceServeAndAllocate will announce the |spec| to |etcd|, begin asynchronously serving the ServerContext, and synchronously run allocator.Allocate. It installs a signal handler which zeros the |spec| item limit and updates the announcement, causing the Allocate to gracefully exit. This is the principal service loop of gazette brokers and consumers.

func InitDiagnosticsAndRecover

func InitDiagnosticsAndRecover(cfg DiagnosticsConfig) func()

InitDiagnosticsAndRecover enables serving of metrics and debugging services registered on the default HTTPMux. It also returns a closure which should be deferred, which recover a panic and attempt to log a K8s termination message.

func InitLog

func InitLog(cfg LogConfig)

InitLog configures the logger.

func Must

func Must(err error, msg string, extra ...interface{})

Must panics if |err| is non-nil, supplying |msg| and |extra| as formatter and fields of the generated panic.

func MustParseArgs

func MustParseArgs(parser *flags.Parser)

MustParseArgs requires that Parser be able to ParseArgs without error.

func MustParseConfig

func MustParseConfig(parser *flags.Parser, configName string)

MustParseConfig requires that the Parser parse from the combination of an optional INI file, configured environment bindings, and explicit flags. An INI file matching |configName| is searched for in:

  • The current working directory.
  • ~/.config/gazette (under the users's $HOME or %UserProfile% directory).
  • $APPLICATION_CONFIG_ROOT

Types

type AddressConfig

type AddressConfig struct {
	Address pb.Endpoint `long:"address" env:"ADDRESS" default:"http://localhost:8080" description:"Service address endpoint"`
}

AddressConfig of a remote service.

func (*AddressConfig) Dial

Dial the server address using a protocol.Dispatcher balancer.

func (*AddressConfig) JournalClient

func (c *AddressConfig) JournalClient(ctx context.Context) pb.JournalClient

JournalClient dials and returns a new JournalClient.

func (*AddressConfig) ShardClient

func (c *AddressConfig) ShardClient(ctx context.Context) consumer.ShardClient

ShardClient dials and returns a new ShardClient.

type ClientConfig

type ClientConfig struct {
	AddressConfig

	Cache struct {
		Size int           `` /* 141-byte string literal not displayed */
		TTL  time.Duration `long:"cache.ttl" env:"CACHE_TTL" default:"1m" description:"Time-to-live of route cache entries."`
	}
}

ClientConfig configures the client of a remote Gazette service.

func (*ClientConfig) BuildRouter

func (c *ClientConfig) BuildRouter() pb.DispatchRouter

BuildRouter returns a configured DispatchRouter.

func (*ClientConfig) RoutedJournalClient

func (c *ClientConfig) RoutedJournalClient(ctx context.Context) pb.RoutedJournalClient

RoutedJournalClient composes Dial and BuildRouter to return a RoutedJournalClient.

func (*ClientConfig) RoutedShardClient

func (c *ClientConfig) RoutedShardClient(ctx context.Context) consumer.RoutedShardClient

RoutedShardClient composes Dial and BuildRouter to return a RoutedShardClient.

type DiagnosticsConfig

type DiagnosticsConfig struct {
}

DiagnosticsConfig configures pull-based application metrics, debugging and diagnostics.

type EtcdConfig

type EtcdConfig struct {
	Address  protocol.Endpoint `long:"address" env:"ADDRESS" default:"http://localhost:2379" description:"Etcd service address endpoint"`
	LeaseTTL time.Duration     `long:"lease" env:"LEASE_TTL" default:"20s" description:"Time-to-live of Etcd lease"`
}

EtcdConfig configures the application Etcd session.

type EtcdContext

type EtcdContext struct {
	Etcd    *clientv3.Client
	Session *concurrency.Session
}

EtcdContext composes an Etcd client and TTL session lease.

func MustEtcdContext

func MustEtcdContext(cfg EtcdConfig) EtcdContext

MustEtcdContext builds an EtcdContext from an EtcdConfig.

type LogConfig

type LogConfig struct {
	Level  string `long:"level" env:"LEVEL" default:"info" choice:"info" choice:"debug" choice:"warn" description:"Logging level"`
	Format string `long:"format" env:"FORMAT" default:"text" choice:"json" choice:"text" choice:"color" description:"Logging output format"`
}

LogConfig configures handling of application log events.

type ServiceConfig

type ServiceConfig struct {
	ZoneConfig
	ID   string `long:"id" env:"ID" default:"localhost" description:"Unique ID of the process"`
	Host string `long:"host" env:"HOST" default:"localhost" description:"Addressable, advertised hostname of this process"`
	Port uint16 `long:"port" env:"PORT" default:"8080" description:"Service port for HTTP and gRPC requests"`
}

ServiceConfig represents identification and addressing configuration of the process.

func (ServiceConfig) MemberKey

func (cfg ServiceConfig) MemberKey(ks *keyspace.KeySpace) string

MemberKey of an allocator implied by the ServiceConfig.

func (ServiceConfig) ProcessSpec

func (cfg ServiceConfig) ProcessSpec() protocol.ProcessSpec

ProcessSpec of the ServiceConfig.

type ZoneConfig

type ZoneConfig struct {
	Zone string `long:"zone" env:"ZONE" default:"local" description:"Availability zone within which this process is running"`
}

ZoneConfig configures the zone of the application.

Directories

Path Synopsis
Package runconsumer extends consumer.Application with support for configuration and application initialization.
Package runconsumer extends consumer.Application with support for configuration and application initialization.

Jump to

Keyboard shortcuts

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