...

Package client_config

import "bitbucket.org/twicedb/twicedb-go/client_config"
Overview
Index

Overview ▾

Package config provides utilities to access runtime configuration for the client in both environment variables (higher precedence) and configuration files (lower precedence).

func ConfigureLogger

func ConfigureLogger()

func LoadClientClientCommonNameForFiles

func LoadClientClientCommonNameForFiles(certFile string, keyFile string) (shared.ClientCommonName, error)

func LoadClientTLSCredentials

func LoadClientTLSCredentials(certFile string, keyFile string, caFile string) (credentials.TransportCredentials, error)

type ClientConfig

type ClientConfig struct {
    Client struct {
        CertFile                  string `yaml:"certFile" env:"CLIENT_CERT_FILE" env-description:"Absolute path to the client certificate file"`
        KeyFile                   string `yaml:"keyFile" env:"CLIENT_KEY_FILE" env-description:"Absolute path to the client key file"`
        CAFile                    string `yaml:"caFile" env:"CLIENT_CA_FILE" env-description:"Absolute path to the CA file"`
        Log                       string `yaml:"log" env:"CLIENT_LOG" env-description:"Client log" env-default:"/tmp/twicedb.go-client.log"`
        ZkPort                    int    `yaml:"zkPort" env:"ZK_PORT" env-description:"Zookeeper port (same port for all hosts)" env-default:"2281"`
        ReadQueueCapacity         int    `yaml:"readQueueCapacity" env:"CLIENT_READ_QUEUE_CAPACITY" env-description:"Capacity of the read queue" env-default:"100"`
        WriteQueueCapacity        int    `yaml:"writeQueueCapacity" env:"CLIENT_WRITE_QUEUE_CAPACITY" env-description:"Capacity of the write queue" env-default:"100"`
        MinCompressionSizeInBytes int    `yaml:"minCompressionSizeInBytes" env:"MIN_COMPRESSION_SIZE_IN_BYTES" env-description:"Minimum size (in bytes) of object to compress" env-default:"129"`
    }
    Server struct {
        // Oddly, localhost:50004 doesn't work. Maybe localhost doesn't map to an
        // IP address?
        ReaderHostPort string `yaml:"readerhostport" env:"CLIENT_READER_HOSTPORT" env-description:"Reader hostport" env-default:"0.0.0.0:50004"`
        WriterHostPort string `yaml:"writerhostport" env:"CLIENT_WRITER_HOSTPORT" env-description:"Writer hostport" env-default:"0.0.0.0:50004"`
        Shard          int    `yaml:"shard" env:"CLIENT_SHARD" env-description:"Client's assigned shard number"`
    }
}

func ClientCfg

func ClientCfg() ClientConfig