config

package
v2.0.0-...-0175b30 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFromFile

func ReadFromFile(cnfPath string) ([]byte, error)

ReadFromFile reads data from a file

Types

type AMQPConfig

type AMQPConfig struct {
	Exchange         string            `yaml:"exchange" envconfig:"AMQP_EXCHANGE"`
	ExchangeType     string            `yaml:"exchange_type" envconfig:"AMQP_EXCHANGE_TYPE"`
	QueueBindingArgs QueueBindingArgs  `yaml:"queue_binding_args" envconfig:"AMQP_QUEUE_BINDING_ARGS"`
	BindingKey       string            `yaml:"binding_key" envconfig:"AMQP_BINDING_KEY"`
	PrefetchCount    int               `yaml:"prefetch_count" envconfig:"AMQP_PREFETCH_COUNT"`
	TaskRoutes       map[string]string `yaml:"task_routes"`
}

AMQPConfig wraps RabbitMQ related configuration

type Config

type Config struct {
	Broker          string       `yaml:"broker" envconfig:"BROKER"`
	Concurrency     int          `yaml:"concurrency" envconfig:"CONCURRENCY"`
	Maxcpucores     int          `yaml:"maxcpucores" envconfig:"MAXCPUCORES"`
	Maxthreads      int          `yaml:"maxthreads" envconfig:"MAXTHREADS"`
	CeleryMessage   int          `yaml:"celery_message" envconfig:"CELERY_MESSAGE"`
	DefaultQueue    string       `yaml:"default_queue" envconfig:"DEFAULT_QUEUE"`
	ResultBackend   string       `yaml:"result_backend" envconfig:"RESULT_BACKEND"`
	ResultsExpireIn int          `yaml:"results_expire_in" envconfig:"RESULTS_EXPIRE_IN"`
	AMQP            *AMQPConfig  `yaml:"amqp"`
	Redis           *RedisConfig `yaml:"redis"`
	TLSConfig       *tls.Config
	//NoUnixSignals when set disables signal handling in machinery
	NoUnixSignals bool `yaml:"no_unix_signals" envconfig:"NO_UNIX_SIGNALS"`
}

Config holds all configuration for our program

func NewFromEnvironment

func NewFromEnvironment(keepReloading bool) (*Config, error)

NewFromEnvironment creates a config object from environment variables

func NewFromYaml

func NewFromYaml(cnfPath string, keepReloading bool) (*Config, error)

NewFromYaml creates a config object from YAML file

type QueueBindingArgs

type QueueBindingArgs map[string]interface{}

QueueBindingArgs arguments which are used when binding to the exchange

func (*QueueBindingArgs) Decode

func (args *QueueBindingArgs) Decode(value string) error

Decode from yaml to map (any field whose type or pointer-to-type implements envconfig.Decoder can control its own deserialization)

type RedisConfig

type RedisConfig struct {
	// Maximum number of idle connections in the pool.
	MaxIdle int `yaml:"max_idle" envconfig:"REDIS_MAX_IDLE"`

	// Maximum number of connections allocated by the pool at a given time.
	// When zero, there is no limit on the number of connections in the pool.
	MaxActive int `yaml:"max_active" envconfig:"REDIS_MAX_ACTIVE"`

	// Close connections after remaining idle for this duration in seconds. If the value
	// is zero, then idle connections are not closed. Applications should set
	// the timeout to a value less than the server's timeout.
	IdleTimeout int `yaml:"max_idle_timeout" envconfig:"REDIS_IDLE_TIMEOUT"`

	// If Wait is true and the pool is at the MaxActive limit, then Get() waits
	// for a connection to be returned to the pool before returning.
	Wait bool `yaml:"wait" envconfig:"REDIS_WAIT"`

	// ReadTimeout specifies the timeout in seconds for reading a single command reply.
	ReadTimeout int `yaml:"read_timeout" envconfig:"REDIS_READ_TIMEOUT"`

	// WriteTimeout specifies the timeout in seconds for writing a single command.
	WriteTimeout int `yaml:"write_timeout" envconfig:"REDIS_WRITE_TIMEOUT"`

	// ConnectTimeout specifies the timeout in seconds for connecting to the Redis server when
	// no DialNetDial option is specified.
	ConnectTimeout int `yaml:"connect_timeout" envconfig:"REDIS_CONNECT_TIMEOUT"`
}

Jump to

Keyboard shortcuts

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