Documentation
¶
Overview ¶
Package env contains functions for working with environment configuration (capidaemon.json, capitoolbelt.json, capiwebapi.json)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Amqp091Config ¶ added in v1.1.25
type Amqp091Config struct {
URL string `json:"url" env:"CAPI_AMQP091_URL, overwrite"` // RabbitMQ URL, like "amqp://guest:guest@127.0.0.1/" or "amqps://user123:pass123@b-b781b39a-1234-1234-1234-1234fded4f84.mq.us-east-1.on.aws:5671"
Exchange string `json:"exchange" env:"CAPI_AMQP091_EXCHANGE, overwrite"` // Traditionally, "capillaries"
PrefetchCount int `json:"prefetch_count" env:"CAPI_AMQP091_PREFETCH_COUNT, overwrite"` // 20
PrefetchSize int `json:"prefetch_size" env:"CAPI_AMQP091_PREFETCH_SIZE, overwrite"` // 0
}
type CassandraConfig ¶
type CassandraConfig struct {
Hosts []string `json:"hosts" env:"CAPI_CASSANDRA_HOSTS, overwrite"` // CAPI_CASSANDRA_HOSTS="1.2.3.4,5.6.7.8"
Port int `json:"port" env:"CAPI_CASSANDRA_PORT, overwrite"` // 9142 for Amazon Keyspaces, 9042 for regular Cassandra
Username string `json:"username" env:"CAPI_CASSANDRA_USERNAME, overwrite"` // Cassandra user name
Password string `json:"password" env:"CAPI_CASSANDRA_PASSWORD, overwrite"` // Cassandra user password
WriterWorkers int `json:"writer_workers" env:"CAPI_CASSANDRA_WRITER_WORKERS, overwrite"` // 20 is conservative, 80 is very aggressive
NumConns int `json:"num_conns" env:"CAPI_CASSANDRA_NUM_CONNS, overwrite"` // gocql.ClusterConfig.NumConns default is 2, don't make it too high
Timeout int `json:"timeout" env:"CAPI_CASSANDRA_TIMEOUT, overwrite"` // in ms, set it to 5s, gocql default 600ms is way too aggressive for heavy writes by multiple workers
ConnectTimeout int `json:"connect_timeout" env:"CAPI_CASSANDRA_CONNECT_TIMEOUT, overwrite"` // in ms, set it to 1s, gocql default 600ms may be ok, but let's stay on the safe side
KeyspaceReplicationConfig string `json:"keyspace_replication_config" env:"CAPI_CASSANDRA_KEYSPACE_REPLICATION_CONFIG, overwrite"` // "{ 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1 }" for Cassandra" or "{ 'class' : 'SingleRegionStrategy'}" for Amazon Keyspaces
SslOpts *SslOptions `json:"ssl_opts"`
Consistency string `json:"consistency" env:"CAPI_CASSANDRA_CONSISTENCY, overwrite"` // gocql.ClusterConfig..Consistency, Amazon Keyspaces requires LOCAL_QUORUM, gocql default is QUORUM
DisableInitialHostLookup bool `json:"disable_initial_host_lookup" env:"CAPI_CASSANDRA_DISABLE_INITIAL_HOST_LOOKUP, overwrite"` // gocql.ClusterConfig.DisableInitialHostLookup default false
}
func (*CassandraConfig) MarshalJSON ¶ added in v1.1.20
func (c *CassandraConfig) MarshalJSON() ([]byte, error)
func (*CassandraConfig) ShallowCopy ¶ added in v1.1.20
func (c *CassandraConfig) ShallowCopy() CassandraConfig
type DaemonConfig ¶ added in v1.1.25
type EnvConfig ¶
type EnvConfig struct {
HandlerExecutableType string `json:"handler_executable_type"` // daemon,webapi,toolbelt
Cassandra CassandraConfig `json:"cassandra"`
Amqp Amqp091Config `json:"amqp091"`
Log LogConfig `json:"log"`
CaPath string `json:"ca_path" env:"CAPI_CA_PATH, overwrite"` // Used for HTTP, host's CA dir if empty
PrivateKeys map[string]string `json:"private_keys" env:"CAPI_PRIVATE_KEYS, overwrite"` // Used for SFTP only
Daemon DaemonConfig `json:"daemon,omitempty"`
Webapi WebapiConfig `json:"webapi,omitempty"`
CustomProcessorsSettings map[string]json.RawMessage `json:"custom_processors"`
CustomProcessorDefFactoryInstance sc.CustomProcessorDefFactory `json:"-"`
}
func ReadEnvConfigFile ¶
func (*EnvConfig) Deserialize ¶
type LogConfig ¶ added in v1.1.20
type LogConfig struct {
LogFile string `json:"log_file" env:"CAPI_LOG_FILE, overwrite"` // If empty, log only to stdout
Level string `json:"level" env:"CAPI_LOG_LEVEL, overwrite"` // zap: DEBUG,INFO,WARN,ERROR,DPANIC,PANIC,FATAL
PrometheusExporterPort int `json:"prometheus_exporter_port" env:"CAPI_PROMETHEUS_EXPORTER_PORT, overwrite"` // if empty - no Prometheus stats exported
}
type SslOptions ¶
type SslOptions struct {
CertPath string `json:"cert_path" env:"CAPI_CASSANDRA_CERT_PATH, overwrite"` // gocql.SslOptions.CertPath
KeyPath string `json:"key_path" env:"CAPI_CASSANDRA_KEY_PATH, overwrite"` // gocql.SslOptions.KeyPath
CaPath string `json:"ca_path" env:"CAPI_CASSANDRA_CA_PATH, overwrite"` // Amazon Keyspaces wants to see /home/.../.ssh/sf-class2-root.crt there
EnableHostVerification bool `json:"enable_host_verification" env:"CAPI_CASSANDRA_ENABLE_HOST_VERIFICATION, overwrite"` // Rumors say Amazon Keyspaces wants explicit false here
}
This was not tested outside of the EnableHostVerification=false scenario
type WebapiConfig ¶ added in v1.1.0
type WebapiConfig struct {
Port int `json:"webapi_port" env:"CAPI_WEBAPI_PORT, overwrite"` // 6543
AccessControlAllowOrigin string `json:"access_control_allow_origin" env:"CAPI_WEBAPI_ACCESS_CONTROL_ALLOW_ORIGIN, overwrite"` // http://localhost:8080,http://127.0.0.1:8080
}
Click to show internal directories.
Click to hide internal directories.