config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2017 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvKeyRoot the environment variable key for runtime root dir
	EnvKeyRoot = "CADENCE_ROOT"
	// EnvKeyConfigDir the environment variable key for config dir
	EnvKeyConfigDir = "CADENCE_CONFIG_DIR"
	// EnvKeyEnvironment is the environment variable key for environment
	EnvKeyEnvironment = "CADENCE_ENVIRONMENT"
	// EnvKeyAvailabilityZone is the environment variable key for AZ
	EnvKeyAvailabilityZone = "CADENCE_AVAILABILTY_ZONE"
)

Variables

This section is empty.

Functions

func Load

func Load(env string, configDir string, zone string, config interface{}) error

Load loads the configuration from a set of yaml config files found in the config directory

The loader first fetches the set of files matching a pre-determined naming convention, then sorts them by hierarchy order and after that, simply loads the files one after another with the key/values in the later files overriding the key/values in the earlier files

The hierarchy is as follows from lowest to highest

base.yaml
    env.yaml   -- environment is one of the input params ex-development
      env_az.yaml -- zone is another input param

Types

type BootstrapMode

type BootstrapMode int

BootstrapMode is an enum type for ringpop bootstrap mode

const (
	// BootstrapModeNone represents a bootstrap mode set to nothing or invalid
	BootstrapModeNone BootstrapMode = iota
	// BootstrapModeFile represents a file-based bootstrap mode
	BootstrapModeFile
	// BootstrapModeHosts represents a list of hosts passed in the configuration
	BootstrapModeHosts
	// BootstrapModeCustom represents a custom bootstrap mode
	BootstrapModeCustom
)

func (*BootstrapMode) UnmarshalYAML

func (m *BootstrapMode) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is called by the yaml package to convert the config YAML into a BootstrapMode.

type Cassandra

type Cassandra struct {
	// Hosts is a csv of cassandra endpoints
	Hosts string `yaml:"hosts" validate:"nonzero"`
	// Port is the cassandra port used for connection by gocql client
	Port int `yaml:"port"`
	// User is the cassandra user used for authentication by gocql client
	User string `yaml:"user"`
	// Password is the cassandra password used for authentication by gocql client
	Password string `yaml:"password"`
	// Keyspace is the cassandra keyspace
	Keyspace string `yaml:"keyspace" validate:"nonzero"`
	// VisibilityKeyspace is the cassandra keyspace for visibility store
	VisibilityKeyspace string `yaml:"visibilityKeyspace" validate:"nonzero"`
	// Consistency is the default cassandra consistency level
	Consistency string `yaml:"consistency"`
	// Datacenter is the data center filter arg for cassandra
	Datacenter string `yaml:"datacenter"`
	// NumHistoryShards is the desired number of history shards
	NumHistoryShards int `yaml:"numHistoryShards" validate:"nonzero"`
}

Cassandra contains configuration to connect to Cassandra cluster

type Config

type Config struct {
	// Ringpop is the ringpop related configuration
	Ringpop Ringpop `yaml:"ringpop"`
	// Cassandra is the configuration for connecting to cassandra
	Cassandra Cassandra `yaml:"cassandra"`
	// Log is the logging config
	Log Logger `yaml:"log"`
	// Services is a map of service name to service config items
	Services map[string]Service `yaml:"services"`
}

Config contains the configuration for a set of cadence services

func (*Config) String

func (c *Config) String() string

String converts the config object into a string

type Logger

type Logger struct {
	// Stdout is true if the output needs to goto standard out
	Stdout bool `yaml:"stdout"`
	// Level is the desired log level
	Level string `yaml:"level"`
	// OutputFile is the path to the log output file
	OutputFile string `yaml:"outputFile"`
}

Logger contains the config items for logger

func (*Logger) NewBarkLogger

func (cfg *Logger) NewBarkLogger() bark.Logger

NewBarkLogger builds and returns a new bark logger for this logging configuration

type Metrics

type Metrics struct {
	// M3 is the configuration for m3 metrics reporter
	M3 *m3.Configuration `yaml:"m3"`
	// Statsd is the configuration for statsd reporter
	Statsd *Statsd `yaml:"statsd"`
	// Tags is the set of key-value pairs to be reported
	// as part of every metric
	Tags map[string]string `yaml:"tags"`
}

Metrics contains the config items for metrics subsystem

func (*Metrics) NewScope

func (c *Metrics) NewScope() tally.Scope

NewScope builds a new tally scope for this metrics configuration

If the underlying configuration is valid for multiple reporter types, only one of them will be used for reporting. Currently, m3 is preferred over statsd

type Ringpop

type Ringpop struct {
	// Name to be used in ringpop advertisement
	Name string `yaml:"name" validate:"nonzero"`
	// BootstrapMode is a enum that defines the ringpop bootstrap method
	BootstrapMode BootstrapMode `yaml:"bootstrapMode"`
	// BootstrapHosts is a list of seed hosts to be used for ringpop bootstrap
	BootstrapHosts []string `yaml:"bootstrapHosts"`
	// BootstrapFile is the file path to be used for ringpop bootstrap
	BootstrapFile string `yaml:"bootstrapFile"`
	// MaxJoinDuration is the max wait time to join the ring
	MaxJoinDuration time.Duration `yaml:"maxJoinDuration"`
	// Custom discovery provider, cannot be specified through yaml
	DiscoveryProvider discovery.DiscoverProvider `yaml:"-"`
}

Ringpop contains the ringpop config items

func (*Ringpop) NewFactory

func (rpConfig *Ringpop) NewFactory() (*RingpopFactory, error)

NewFactory builds a ringpop factory conforming to the underlying configuration

type RingpopFactory

type RingpopFactory struct {
	// contains filtered or unexported fields
}

RingpopFactory implements the RingpopFactory interface

func (*RingpopFactory) CreateRingpop

func (factory *RingpopFactory) CreateRingpop(ch *tchannel.Channel) (*ringpop.Ringpop, error)

CreateRingpop is the implementation for RingpopFactory.CreateRingpop

type Service

type Service struct {
	// TChannel is the tchannel configuration
	TChannel TChannel `yaml:"tchannel"`
	// Metrics is the metrics subsystem configuration
	Metrics Metrics `yaml:"metrics"`
}

Service contains the service specific config items

type Statsd

type Statsd struct {
	// The host and port of the statsd server
	HostPort string `yaml:"hostPort" validate:"nonzero"`
	// The prefix to use in reporting to statsd
	Prefix string `yaml:"prefix" validate:"nonzero"`
	// FlushInterval is the maximum interval for sending packets.
	// If it is not specified, it defaults to 1 second.
	FlushInterval time.Duration `yaml:"flushInterval"`
	// FlushBytes specifies the maximum udp packet size you wish to send.
	// If FlushBytes is unspecified, it defaults  to 1432 bytes, which is
	// considered safe for local traffic.
	FlushBytes int `yaml:"flushBytes"`
}

Statsd contains the config items for statsd metrics reporter

type TChannel

type TChannel struct {
	// Port is the port  on which the channel will bind to
	Port int `yaml:"port"`
	// BindOnLocalHost is true if localhost is the bind address
	BindOnLocalHost bool `yaml:"bindOnLocalHost"`
	// DisableLogging disables all logging for tchannel
	DisableLogging bool `yaml:"disableLogging"`
	// LogLevel is the desired log level
	LogLevel string `yaml:"logLevel"`
}

TChannel contains the tchannel config items

func (*TChannel) NewFactory

func (cfg *TChannel) NewFactory() *TChannelFactory

NewFactory builds a new tchannelFactory conforming to the underlying configuration

type TChannelFactory

type TChannelFactory struct {
	// contains filtered or unexported fields
}

TChannelFactory is an implementation of service.TChannelFactory interface

func (*TChannelFactory) CreateChannel

func (factory *TChannelFactory) CreateChannel(sName string,
	thriftServices []thrift.TChanServer) (*tchannel.Channel, *thrift.Server)

CreateChannel implements the TChannelFactory interface

Jump to

Keyboard shortcuts

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