conf

package
v0.0.0-...-b44688a Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

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

View Source
const EnvironmentPrefix = "SWAN_"

EnvironmentPrefix is prefix that is used for environment based configuration.

Variables

View Source
var CassandraAddress = NewStringFlag("cassandra_address", "Address of Cassandra DB endpoint for Metadata and Snap Publishers.", "127.0.0.1")

CassandraAddress represents cassandra address flag.

View Source
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.

View Source
var CassandraCreateKeyspace = NewBoolFlag("cassandra_create_keyspace", "Attempt to create keyspace.", false)

CassandraCreateKeyspace sets that publisher will attempt to create keyspace

View Source
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.

View Source
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.

View Source
var CassandraKeyspaceName = NewStringFlag("cassandra_keyspace_name", "Keyspace used to store metadata.", "swan")

CassandraKeyspaceName sets keyspace name used by driver.

View Source
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.

View Source
var CassandraPort = NewIntFlag("cassandra_port", "Port of Cassandra DB endpoint.", 9042)

CassandraPort sets port of Cassandra DB endpoint.

View Source
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.

View Source
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.

View Source
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.

View Source
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.

View Source
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.

View Source
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.

View Source
var CassandraTimeout = NewDurationFlag("cassandra_timeout", "Query timeout for the publisher in seconds.", 0)

CassandraTimeout sets query timeout for the publisher in seconds.

View Source
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.

View Source
var DefaultMetadataDB = NewStringFlag("default_metadata_db", "Database to which metadata will be stored. Suported: cassandra, influxdb", "cassandra")

DefaultMetadataDB sets default database for metadata

View Source
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

View Source
var InfluxDBAddress = NewStringFlag("influxdb_address", "Address of InfluxDB DB endpoint for Metadata and Snap Publishers.", "127.0.0.1")

InfluxDBAddress represents influxdb address flag.

View Source
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

View Source
var InfluxDBInsecureSkipVerify = NewBoolFlag("influxdb_insecure_skip_verify", "If set skip certificate validation", true)

InfluxDBInsecureSkipVerify controls the certificate verification step

View Source
var InfluxDBMetaName = NewStringFlag("influxdb_metadata_db_name", "Database's name used to store metadata.", "swan_metadata")

InfluxDBMetaName sets database name used by driver.

View Source
var InfluxDBMetricsName = NewStringFlag("influxdb_metrics_db_name", "Database's name used to store metrics.", "swan_metrics")

InfluxDBMetricsName sets database name used by driver.

View Source
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.

View Source
var InfluxDBPort = NewIntFlag("influxdb_port", "Port of InfluxDB DB endpoint.", 8086)

InfluxDBPort sets port of InfluxDB DB endpoint.

View Source
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

func DumpConfigMap(flagMap map[string]string) string

DumpConfigMap dumps environment based configuration with current values overwritten by given flagMap.

func GetFlags

func GetFlags() map[string]string

GetFlags returns flags as map with current values.

func LoadConfig

func LoadConfig(filename string) error

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

func LogLevel() (logrus.Level, error)

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

func NewBoolFlag(name string, usage string, value bool) BoolFlag

NewBoolFlag is a constructor of BoolFlag struct.

func (BoolFlag) Value

func (b BoolFlag) Value() bool

Value returns value of defined flag after parse.

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

func NewIntFlag(name string, usage string, value int) IntFlag

NewIntFlag is a constructor of IntFlag struct.

func (IntFlag) Value

func (i IntFlag) Value() int

Value returns value of defined flag after parse.

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.

Jump to

Keyboard shortcuts

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