Documentation ¶
Overview ¶
Package conf extends builtin 'flag' packagea to provide: - environment parsing with predefined prefix, - config file generation with grouping (instead of lexicographical order), - ability to extract current values of or registered flags (defined with wrappers), - new types of flags e.g. SliceFlag, - predefined flags for logging (logrus integration),
Index ¶
- Constants
- Variables
- func DumpConfig() string
- func DumpConfigMap(flagMap map[string]string) string
- func GetFlags() map[string]string
- func LoadConfig(filename string) error
- func LogLevel() (logrus.Level, error)
- func ParseFlags() error
- type BoolFlag
- type DurationFlag
- type Flag
- type IntFlag
- type IntSetFlag
- type StringFlag
- type StringSliceFlag
Constants ¶
const EnvironmentPrefix = "SWAN_"
EnvironmentPrefix is prefix that is used for environment based configuration.
Variables ¶
var CassandraAddress = NewStringFlag("cassandra_address", "Address of Cassandra DB endpoint for Metadata and Snap Publishers.", "127.0.0.1")
CassandraAddress represents cassandra address flag.
var CassandraConnectionTimeout = NewDurationFlag("cassandra_connection_timeout", "Timout for communication with Cassandra cluster.", 0)
CassandraConnectionTimeout encodes the internal connection timeout for the publisher. Note that increasing this value may increase the total connection time significantly, due to internal retry logic in the gocql library.
var CassandraCreateKeyspace = NewBoolFlag("cassandra_create_keyspace", "Attempt to create keyspace.", false)
CassandraCreateKeyspace sets that publisher will attempt to create keyspace
var CassandraIgnorePeerAddr = NewBoolFlag("cassandra_ignore_peer_addr", "If true, doesn't resolve internal nodes addresses.", false)
CassandraIgnorePeerAddr sets that driver won't resolve internal nodes addresses.
var CassandraInitialHostLookup = NewBoolFlag("cassandra_initial_host_loopup", "If false, driver won't attempt to get host info from Cassandra.", true)
CassandraInitialHostLookup sets that driver will attempt to get host info from Cassandra.
var CassandraKeyspaceName = NewStringFlag("cassandra_keyspace_name", "Keyspace used to store metadata.", "swan")
CassandraKeyspaceName sets keyspace name used by driver.
var CassandraPassword = NewStringFlag("cassandra_password", "The password which will be presented when connecting to the cluster at 'cassandra_address'.", "")
CassandraPassword holds the password which will be presented when connecting to the cluster at CassandraAddress.
var CassandraPort = NewIntFlag("cassandra_port", "Port of Cassandra DB endpoint.", 9042)
CassandraPort sets port of Cassandra DB endpoint.
var CassandraSslCAPath = NewStringFlag("cassandra_ssl_ca_path", "Enables self-signed certificates by setting a certificate authority directly. This is not recommended in production settings.", "")
CassandraSslCAPath enables self-signed certificates by setting a certificate authority directly.
var CassandraSslCertPath = NewStringFlag("cassandra_ssl_cert_path", "Sets the client certificate, in case the cluster requires client verification.", "")
CassandraSslCertPath sets the client certificate, in case the cluster requires client verification.
var CassandraSslEnabled = NewBoolFlag("cassandra_ssl", "Determines whether the cassandra publisher should connect to the cluster over an SSL encrypted connection. Flags CassandraSslHostValidation, CassandraSslCAPath, CassandraSslCertPath and CassandraSslKeyPath should be set accordingly.", false)
CassandraSslEnabled determines whether the cassandra publisher should connect to the cluster over an SSL encrypted connection.
var CassandraSslHostValidation = NewBoolFlag("cassandra_ssl_host_validation", "Determines whether the publisher will attempt to validate the host. Note that self-signed certificates and hostname mismatch, will cause the connection to fail if not set up correctly. The recommended setting is to enable this flag.", false)
CassandraSslHostValidation determines whether the publisher will attempt to validate the cluster at CassandraAddress.
var CassandraSslKeyPath = NewStringFlag("cassandra_ssl_key_path", "Sets the client private key, in case the cluster requires client verification.", "")
CassandraSslKeyPath sets the client private key, in case the cluster requires client verification.
var CassandraTagIndex = NewStringFlag("cassandra_tag_index", fmt.Sprintf("Allows to pass comma-separated list of tags that will be used to insert metrics into %s.tags table to improve SELECT performance", CassandraKeyspaceName.Value()), "swan_experiment")
CassandraTagIndex allows to pass comma-separated list of tags that will be used to insert metrics into tags table to improve SELECT performance.
var CassandraTimeout = NewDurationFlag("cassandra_timeout", "Query timeout for the publisher in seconds.", 0)
CassandraTimeout sets query timeout for the publisher in seconds.
var CassandraUsername = NewStringFlag("cassandra_username", "The user name which will be presented when connecting to the cluster at 'cassandra_address'.", "")
CassandraUsername holds the user name which will be presented when connecting to the cluster at CassandraAddress.
var DefaultMetadataDB = NewStringFlag("default_metadata_db", "Database to which metadata will be stored. Suported: cassandra, influxdb", "cassandra")
DefaultMetadataDB sets default database for metadata
var DefaultSnapPublisher = NewStringFlag("default_snap_publisher", "Publisher to use. Name shall be used from snap-plugin-publisher-<name>. Supported: cassandra, influxdb", "cassandra")
DefaultSnapPublisher sets default publisher used by swan
var InfluxDBAddress = NewStringFlag("influxdb_address", "Address of InfluxDB DB endpoint for Metadata and Snap Publishers.", "127.0.0.1")
InfluxDBAddress represents influxdb address flag.
var InfluxDBCreateDatabase = NewBoolFlag("influxdb_create_database", "Attempt to create database (if it does not exist)", true)
InfluxDBCreateDatabase controls whether driver shall try to create database in influx
var InfluxDBInsecureSkipVerify = NewBoolFlag("influxdb_insecure_skip_verify", "If set skip certificate validation", true)
InfluxDBInsecureSkipVerify controls the certificate verification step
var InfluxDBMetaName = NewStringFlag("influxdb_metadata_db_name", "Database's name used to store metadata.", "swan_metadata")
InfluxDBMetaName sets database name used by driver.
var InfluxDBMetricsName = NewStringFlag("influxdb_metrics_db_name", "Database's name used to store metrics.", "swan_metrics")
InfluxDBMetricsName sets database name used by driver.
var InfluxDBPassword = NewStringFlag("influxdb_password", "The password which will be presented when connecting to the cluster at 'influxdb_address'.", "swan")
InfluxDBPassword holds the password which will be presented when connecting to the cluster at InfluxDBAddress.
var InfluxDBPort = NewIntFlag("influxdb_port", "Port of InfluxDB DB endpoint.", 8086)
InfluxDBPort sets port of InfluxDB DB endpoint.
var InfluxDBUsername = NewStringFlag("influxdb_username", "The user name which will be presented when connecting to the cluster at 'influxdb_address'.", "swan")
InfluxDBUsername holds the user name which will be presented when connecting to the cluster at InfluxDBAddress.
Functions ¶
func DumpConfig ¶
func DumpConfig() string
DumpConfig dumps environment based configuration with current values of flags.
func DumpConfigMap ¶
DumpConfigMap dumps environment based configuration with current values overwritten by given flagMap.
func LoadConfig ¶
LoadConfig from given file the is simple environment format. Description: - '#' indicates means comment, - every other line containing '=' is splited as key and value for environment.
func LogLevel ¶
LogLevel returns configured logLevel from input option or env variable. If it cannot parse the log level, it returns default value.
func ParseFlags ¶
func ParseFlags() error
ParseFlags parse both the command line flags of the process and environment variables. Command line flags override values from environment.
Types ¶
type BoolFlag ¶
type BoolFlag struct { Flag // contains filtered or unexported fields }
BoolFlag represents flag with bool value.
func NewBoolFlag ¶
NewBoolFlag is a constructor of BoolFlag struct.
type DurationFlag ¶
type DurationFlag struct { Flag // contains filtered or unexported fields }
DurationFlag represents flag with duration value.
func NewDurationFlag ¶
func NewDurationFlag(name string, usage string, value time.Duration) DurationFlag
NewDurationFlag is a constructor of DurationFlag struct.
func (DurationFlag) Value ¶
func (d DurationFlag) Value() time.Duration
Value returns value of defined flag after parse.
type Flag ¶
type Flag struct { Name string // contains filtered or unexported fields }
Flag represents option's definition from CLI and Environment variable.
type IntFlag ¶
type IntFlag struct { Flag // contains filtered or unexported fields }
IntFlag represents flag with int value.
func NewIntFlag ¶
NewIntFlag is a constructor of IntFlag struct.
type IntSetFlag ¶
type IntSetFlag struct { Flag // contains filtered or unexported fields }
IntSetFlag represents flag with set of integers value.
func NewIntSetFlag ¶
func NewIntSetFlag(name string, usage string, value string) *IntSetFlag
NewIntSetFlag is a constructor of string range based flags
func (*IntSetFlag) Set ¶
func (isf *IntSetFlag) Set(value string) error
Set new value for IntSetFlag.
func (*IntSetFlag) String ¶
func (isf *IntSetFlag) String() string
String method returns IntSet as string.
func (*IntSetFlag) Value ¶
func (isf *IntSetFlag) Value() isolation.IntSet
Value returns value of defined flag after parse.
type StringFlag ¶
type StringFlag struct { Flag // contains filtered or unexported fields }
StringFlag ...
func NewStringFlag ¶
func NewStringFlag(name string, usage string, value string) StringFlag
NewStringFlag is a constructor of StringFlag struct.
func (StringFlag) Value ¶
func (s StringFlag) Value() string
Value returns value of defined flag after parse.
type StringSliceFlag ¶
type StringSliceFlag struct { Flag // contains filtered or unexported fields }
StringSliceFlag represents flag with slice string values.
func NewStringSliceFlag ¶
func NewStringSliceFlag(name string, usage string, value []string) StringSliceFlag
NewStringSliceFlag is a constructor of StringSliceFlag struct.
func (StringSliceFlag) Value ¶
func (s StringSliceFlag) Value() []string
Value returns value of defined flag after parse.