env

package
v1.1.23 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 7 Imported by: 0

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 AmqpConfig

type AmqpConfig struct {
	URL           string `json:"url" env:"CAPI_AMQP_URL, overwrite"`
	Exchange      string `json:"exchange" env:"CAPI_AMQP_EXCHANGE, overwrite"`
	PrefetchCount int    `json:"prefetch_count" env:"CAPI_AMQP_PREFETCH_COUNT, overwrite"`
	PrefetchSize  int    `json:"prefetch_size" env:"CAPI_AMQP_PREFETCH_SIZE, overwrite"`
}

type CassandraConfig

type CassandraConfig struct {
	Hosts                     []string    `json:"hosts" env:"CAPI_CASSANDRA_HOSTS, overwrite"`
	Port                      int         `json:"port" env:"CAPI_CASSANDRA_PORT, overwrite"`
	Username                  string      `json:"username" env:"CAPI_CASSANDRA_USERNAME, overwrite"`
	Password                  string      `json:"password" env:"CAPI_CASSANDRA_PASSWORD, overwrite"`
	WriterWorkers             int         `json:"writer_workers" env:"CAPI_CASSANDRA_WRITER_WORKERS, overwrite"`                           // 20 is conservative, 80 is very aggressive
	MinInserterRate           int         `json:"min_inserter_rate" env:"CAPI_CASSANDRA_MIN_INSERTER_RATE, overwrite"`                     // writes/sec; if the rate falls below this, we consider the db too slow and throw an error
	NumConns                  int         `json:"num_conns" env:"CAPI_CASSANDRA_NUM_CONNS, overwrite"`                                     // gocql 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 }
	SslOpts                   *SslOptions `json:"ssl_opts"`
}

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 EnvConfig

type EnvConfig struct {
	HandlerExecutableType string          `json:"handler_executable_type"`
	Cassandra             CassandraConfig `json:"cassandra"`
	Amqp                  AmqpConfig      `json:"amqp"`
	// ZapConfig                         zap.Config                 `json:"zap_config"`
	Log                               LogConfig                    `json:"log"`
	ThreadPoolSize                    int                          `json:"thread_pool_size" env:"CAPI_THREAD_POOL_SIZE, overwrite"`
	DeadLetterTtl                     int                          `json:"dead_letter_ttl" env:"CAPI_DEAD_LETTER_TTL, overwrite"`
	CaPath                            string                       `json:"ca_path" env:"CAPI_CA_PATH, overwrite"`
	PrivateKeys                       map[string]string            `json:"private_keys" env:"CAPI_PRIVATE_KEYS, overwrite"`
	Webapi                            WebapiConfig                 `json:"webapi,omitempty"`
	CustomProcessorsSettings          map[string]json.RawMessage   `json:"custom_processors"`
	CustomProcessorDefFactoryInstance sc.CustomProcessorDefFactory `json:"-"`
}

func ReadEnvConfigFile

func ReadEnvConfigFile(ctx context.Context, envConfigFile string) (*EnvConfig, error)

func (*EnvConfig) Deserialize

func (ec *EnvConfig) Deserialize(ctx context.Context, jsonBytes []byte) error

func (*EnvConfig) String added in v1.1.20

func (ec *EnvConfig) String() string

type LogConfig added in v1.1.20

type LogConfig struct {
	Level string `json:"level" env:"CAPI_LOG_LEVEL, overwrite"`
}

type SslOptions

type SslOptions struct {
	CertPath               string `json:"cert_path" env:"CAPI_CASSANDRA_CERT_PATH, overwrite"`
	KeyPath                string `json:"key_path" env:"CAPI_CASSANDRA_KEY_PATH, overwrite"`
	CaPath                 string `json:"ca_path" env:"CAPI_CASSANDRA_CA_PATH, overwrite"`
	EnableHostVerification bool   `json:"enable_host_verification" env:"CAPI_CASSANDRA_ENABLE_HOST_VERIFICATION, overwrite"`
}

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"`
	AccessControlAllowOrigin string `json:"access_control_allow_origin" env:"CAPI_WEBAPI_ACCESS_CONTROL_ALLOW_ORIGIN, overwrite"`
}

Jump to

Keyboard shortcuts

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