core: Index | Files | Directories

package mainboilerplate

import ""


Package Files

client.go config.go diagnostics.go etcd.go logging.go service.go


var BuildDate = "unknown"

BuildDate is populated at build with $(date +%F-%T-%Z).

var Version = "development"

Version is populated at build with $(git describe --dirty).

func AddPrintConfigCmd Uses

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 InitDiagnosticsAndRecover Uses

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 Uses

func InitLog(cfg LogConfig)

InitLog configures the logger.

func Must Uses

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 Uses

func MustParseArgs(parser *flags.Parser)

MustParseArgs requires that Parser be able to ParseArgs without error.

func MustParseConfig Uses

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).

type AddressConfig Uses

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) MustDial Uses

func (c *AddressConfig) MustDial(ctx context.Context) *grpc.ClientConn

MustDial dials the server address using a protocol.Dispatcher balancer, and panics on error.

func (*AddressConfig) MustJournalClient Uses

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

MustJournalClient dials and returns a new JournalClient.

func (*AddressConfig) MustShardClient Uses

func (c *AddressConfig) MustShardClient(ctx context.Context) pc.ShardClient

MustShardClient dials and returns a new ShardClient.

type ClientConfig Uses

type ClientConfig struct {

    Cache struct {
        Size int           `long:"cache.size" env:"CACHE_SIZE" default:"0" description:"Size of client route cache. If <= zero, no cache is used (server always proxies)"`
        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 Uses

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

BuildRouter returns a configured DispatchRouter.

func (*ClientConfig) MustRoutedJournalClient Uses

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

MustRoutedJournalClient composes MustDial and BuildRouter to return a RoutedJournalClient.

func (*ClientConfig) MustRoutedShardClient Uses

func (c *ClientConfig) MustRoutedShardClient(ctx context.Context) pc.RoutedShardClient

MustRoutedShardClient composes MustDial and BuildRouter to return a RoutedShardClient.

type DiagnosticsConfig Uses

type DiagnosticsConfig struct {

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

type EtcdConfig Uses

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.

func (*EtcdConfig) MustDial Uses

func (c *EtcdConfig) MustDial() *clientv3.Client

MustDial builds an Etcd client connection.

type LogConfig Uses

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 Uses

type ServiceConfig struct {
    ID   string `long:"id" env:"ID" description:"Unique ID of this process. Auto-generated if not set"`
    Host string `long:"host" env:"HOST" description:"Addressable, advertised hostname or IP of this process. Hostname is used if not set"`
    Port uint16 `long:"port" env:"PORT" description:"Service port for HTTP and gRPC requests. A random port is used if not set"`

ServiceConfig represents identification and addressing configuration of the process.

func (ServiceConfig) BuildProcessSpec Uses

func (cfg ServiceConfig) BuildProcessSpec(srv *server.Server) protocol.ProcessSpec

ProcessSpec of the ServiceConfig.

type ZoneConfig Uses

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.


runconsumerPackage runconsumer extends consumer.Application with support for configuration and application initialization.

Package mainboilerplate imports 21 packages (graph) and is imported by 17 packages. Updated 2020-10-13. Refresh now. Tools for package owners.