Documentation
¶
Overview ¶
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
A CacheConfig provides go-micro cache configuration for custom cache providers. This structure is expected to be initialized automatically by fx via yaml and env.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Package config provides go-micro adapters' configuration structures
The config package's structures are self-initialized by fx and bootstrapper. Fields are populated via yaml values or env variables. Env variables overwrite yaml configuration.
Index ¶
- func BuildNewCacheConfig(path string) func() (*CacheConfig, error)
- func BuildNewCorsConfig(path string) func() (*CORSConfig, error)
- func BuildNewCryptoConfig(path string) func() (*CryptoConfig, error)
- func BuildNewLoggerConfig(path string) func() (*LoggerConfig, error)
- func BuildNewMessagingConfig(path string) func() (*BrokerConfig, error)
- func BuildNewRegistryConfig(path string) func() (*RegistryConfig, error)
- func BuildNewResilienceConfig(path string) func() (*ResilienceConfig, error)
- func BuildNewServerConfig(path string) func() (*ServerConfig, error)
- func BuildNewStorageConfig(path string) func() (*StorageConfig, error)
- func BuildNewTracerConfig(path string) func() (*TracerConfig, error)
- func BuildNewWorkerConfig(path string) func() (*WorkerConfig, error)
- type BrokerConfig
- type CORSConfig
- type CacheConfig
- type CircuitBreakerConfig
- type CryptoConfig
- type ElasticLogConfig
- type FileLogConfig
- type InvalidConfigurationParameterError
- type LoggerConfig
- type RateLimiterConfig
- type RegistryConfig
- type ResilienceConfig
- type ServerConfig
- type StorageConfig
- type TracerConfig
- type WorkerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildNewCacheConfig ¶
func BuildNewCacheConfig(path string) func() (*CacheConfig, error)
A CacheConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a cache configuration used to initialize a go-micro cache and the first encountered error.
func BuildNewCorsConfig ¶
func BuildNewCorsConfig(path string) func() (*CORSConfig, error)
A CORSConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a cors configuration used to initialize a cors middleware and the first encountered error.
func BuildNewCryptoConfig ¶
func BuildNewCryptoConfig(path string) func() (*CryptoConfig, error)
A CryptoConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a crypto configuration used to initialize jwt, encryptor and hash managers and the first encountered error.
func BuildNewLoggerConfig ¶
func BuildNewLoggerConfig(path string) func() (*LoggerConfig, error)
A LoggerConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a logger configuration used to initialize a new logger instance and the first encountered error.
func BuildNewMessagingConfig ¶
func BuildNewMessagingConfig(path string) func() (*BrokerConfig, error)
A BrokerConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a broker configuration used to initialize a go-micro broker and the first encountered error.
func BuildNewRegistryConfig ¶
func BuildNewRegistryConfig(path string) func() (*RegistryConfig, error)
A RegistryConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a registry configuration used to initialize a go-micro registry and the first encountered error.
func BuildNewResilienceConfig ¶
func BuildNewResilienceConfig(path string) func() (*ResilienceConfig, error)
A ResilienceConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a resilience patterns configuration used to initialize a resilience middlewares and the first encountered error.
func BuildNewServerConfig ¶
func BuildNewServerConfig(path string) func() (*ServerConfig, error)
A ServerConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a server configuration used to initialize a go-micro service and the first encountered error.
func BuildNewStorageConfig ¶
func BuildNewStorageConfig(path string) func() (*StorageConfig, error)
A StorageConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a persistence configuration used inside adapters layers and the first encountered error.
func BuildNewTracerConfig ¶
func BuildNewTracerConfig(path string) func() (*TracerConfig, error)
A TracerConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a tracer configuration used to initialize a go-telemetry tracer provider and the first encountered error.
func BuildNewWorkerConfig ¶
func BuildNewWorkerConfig(path string) func() (*WorkerConfig, error)
A WorkerConfig constructor. Called automatically by fx and bootstrapper with config path provided via cli.
Returns a worker configuration used to initialize an async worker pool and the first encountered error.
Types ¶
type BrokerConfig ¶
type BrokerConfig struct { // Messaging is a nested structure used as a marker for yaml configuration. Messaging struct { // Enable is a broker's enable/disable flag. Enable bool `yaml:"enable" env:"BROKER_ENABLE,overwrite"` // Addrs is a list of broker instances. Addrs []string `yaml:"addresses" env:"BROKER_ADDRESSES,overwrite"` // Type is a broker type field. // 1 - RabbitMQ. // 2 - NATS. // // By default - Memory. Type int `yaml:"type" env:"BROKER_TYPE,overwrite"` // DisableAutoAck is an auto acknowledgement flag // // By default - false DisableAutoAck bool `yaml:"disable_auto_ack" env:"BROKER_DISABLE_AUTO_ACK,overwrite"` // Durable is a flag to make broker's queues durable // // By default - false Durable bool `yaml:"durable" env:"BROKER_DURABLE,overwrite"` // AckOnSuccess is an auto acknowledgement flag // // By default - false AckOnSuccess bool `yaml:"ack_on_success" env:"BROKER_ACK_ON_SUCCESS,overwrite"` // RequeueOnError is an auto requeue on error flag // // By default - false RequeueOnError bool `yaml:"requeue_on_error" env:"BROKER_REQUEUE_ON_ERROR,overwrite"` } `yaml:"messaging"` }
A BrokerConfig provides go-micro broker configuration for custom broker providers. This structure is expected to be initialized automatically by fx via yaml and env.
func (*BrokerConfig) Validate ¶
func (b *BrokerConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type CORSConfig ¶
type CORSConfig struct { // CORS is a nested structure used as a marker for yaml configuration. CORS struct { // AllowedOrigins is an http AllowedOrigins mapper // // By default - ["*"] AllowedOrigins []string `yaml:"origins" env:"ALLOWED_ORIGINS,overwrite"` // AllowedMethods is an http AllowedMethods mapper // // By default - ["*"] AllowedMethods []string `yaml:"methods" env:"ALLOWED_METHODS,overwrite"` // AllowedHeaders is an http AllowedHeaders mapper // // By default - ["*"] AllowedHeaders []string `yaml:"headers" env:"ALLOWED_HEADERS,overwrite"` // AllowCredentials is an http AllowCredentials mapper // // By default - false AllowCredentials bool `yaml:"credentials" env:"ALLOW_CREDENTIALS,overwrite"` } `yaml:"cors"` }
A CORSConfig provides configuration for cors middleware passed to a go-micro service. This structure is expected to be initialized automatically by fx via yaml and env.
func (*CORSConfig) Validate ¶
func (cc *CORSConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type CacheConfig ¶
type CacheConfig struct { // Cache is a nested structure used as a marker for yaml configuration. Cache struct { // Type is gocache adapter type to be auto-configured. // 1 - Freecache. // 2 - Redis. // // By default - 1 Type int `yaml:"type" env:"CACHE_TYPE,overwrite"` // Size is an optional field used to manually cache freecache // buffer size. // // By default - 10 * 1024 * 1024 Size int `yaml:"size" env:"CACHE_SIZE,overwrite"` // Address is an optional field used to manually change redis // instance address. // // By default - 0.0.0.0:6379 Address string `yaml:"address" env:"CACHE_ADDRESS,overwrite"` // Username is an optional field used to manually change redis // instance username // // By default - 'default' Username string `yaml:"username" env:"CACHE_USERNAME,overwrite"` // Password is an optional field used to manually cache redis // instance password // // By default - no password Password string `yaml:"password" env:"CACHE_PASSWORD,overwrite"` // Database int `yaml:"database" env:"CACHE_DATABASE,overwrite"` } `yaml:"cache"` }
A CacheConfig provides go-micro cache configuration for custom cache providers. This structure is expected to be initialized automatically by fx via yaml and env.
func (*CacheConfig) Validate ¶
func (b *CacheConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type CircuitBreakerConfig ¶
type CircuitBreakerConfig struct { // Timeout is how long to wait for command to complete, in milliseconds // // By default - 1000 Timeout int `yaml:"timeout" env:"CIRCUIT_TIMEOUT,overwrite"` // MaxConcurrent is how many commands of the same type can run at the same time // // By default - 10 MaxConcurrent int `yaml:"max_concurrent" env:"CIRCUIT_MAX_CONCURRENT,overwrite"` // VolumeThreshold is the minimum number of requests needed before a circuit can be tripped due to health // // By default - 20 VolumeThreshold int `yaml:"volume_threshold" env:"CIRCUIT_VOLUME_THRESHOLD,overwrite"` // SleepWindow is how long, in milliseconds, to wait after a circuit opens before testing for recovery // // By default - 5000 SleepWindow int `yaml:"sleep_window" env:"CIRCUIT_SLEEP_WINDOW,overwrite"` // ErrorPercentThreshold causes circuits to open once the rolling measure of errors exceeds this percent of requests // // By default - 50 ErrorPercentThreshold int `yaml:"error_percent_threshold" env:"CIRCUIT_ERROR_PERCENT_THRESHOLD,overwrite"` }
A CircuitBreakerConfig provides hystrix circuit breaker configuration. This structure is expected to be initialized automatically by fx via yaml and env.
type CryptoConfig ¶
type CryptoConfig struct { // Crypto is a nested structure used as a marker for yaml configurations Crypto struct { // EncryptorType is an encryption algorithm type. // 1 - AES Gcm // // By default - 1 EncryptorType int `yaml:"encryptor_type" env:"ENCRYPTOR_TYPE"` // JwtManagerType is a JWT library implementation type. // 1 - go-jwt/v5 // // By default - 1 JwtManagerType int `yaml:"jwt_manager_type" env:"JWT_MANAGER_TYPE"` // HasherType is a hash function implementation type. // 1 - md5 // // By default - 1 HasherType int `yaml:"hasher_type" env:"HASHER_TYPE"` } `yaml:"crypto"` }
A CryptoConfig provides configuration for built-in crypto providers. This structure is expected to be initialized automatically by fx via yaml and env.s
type ElasticLogConfig ¶
type ElasticLogConfig struct { // Address is an elasticsearch instance address. Address string `yaml:"address" env:"ELASTIC_ADDRESS,overwrite"` // Index is an elasticsearch instance index. Index string `yaml:"index" env:"ELASTIC_INDEX,overwrite"` // Level is an elasticsearch instance logging level. Level int `yaml:"level" env:"ELASTIC_LEVEL,overwrite"` // Bulk is an elasticsearch instance bulk logging flag. Bulk bool `yaml:"bulk" env:"ELASTIC_BULK,overwrite"` // Async is an elasticsearch instance async logging flag. Async bool `yaml:"async" env:"ELASTIC_ASYNC,overwrite"` // HealthcheckEnabled is an elasticsearch instance flag to enable // periodical healthchecks. HealthcheckEnabled bool `yaml:"healthcheck" env:"ELASTIC_HEALTHCHECK,overwrite"` // BasicAuthUsername is an elasticsearch instance's basic auth username BasicAuthUsername string `yaml:"username" env:"ELASTIC_AUTH_USERNAME,overwrite"` // BasicAuthPassword is an elasticsearch instance's basic auth password BasicAuthPassword string `yaml:"password" env:"ELASTIC_AUTH_PASSWORD,overwrite"` // GzipEnabled is an elasticsearch instance flag to enable log zipping GzipEnabled bool `yaml:"gzip" env:"ELASTIC_GZIP_ENABLED,overwrite"` }
An ElasticLogConfig provides nested logger configuration for elastic logger providers. This structure is expected to be initialized automatically by fx via yaml and env.
type FileLogConfig ¶
type FileLogConfig struct { // Filename is a logging file to create/use to log to Filename string `yaml:"filename" env:"FILELOG_NAME,overwrite"` // MaxSize is the file's size limit before log rolling MaxSize int `yaml:"maxsize" env:"FILELOG_MAX_SIZE,overwrite"` // MaxAge is the file's age limit before log rolling MaxAge int `yaml:"maxage" env:"FILELOG_MAX_AGE,overwrite"` // MaxBackups is the maximum number of file's copies MaxBackups int `yaml:"maxbackups" env:"FILELOG_MAX_BACKUPS,overwrite"` // LocalTime is a flag to use local (server) time LocalTime bool `yaml:"localtime"` // Compress is a flag to compress log files on rolling Compress bool `yaml:"compress" env:"FILELOG_COMPRESS,overwrite"` }
A FileLogConfig provides go-micro logger configuration for file logger providers. This structure is expected to be initialized automatically by fx via yaml and env.
type InvalidConfigurationParameterError ¶
func (*InvalidConfigurationParameterError) Error ¶
func (e *InvalidConfigurationParameterError) Error() string
type LoggerConfig ¶
type LoggerConfig struct { // Logger is a nested structure used as a marker for yaml configurations. Logger struct { // Name is used to configure logger name Name string `yaml:"name" env:"LOGGER_NAME,overwrite"` // Level is used to select logging level // 1 - Trace // 2 - Debug // 3 - Info // 4 - Warning // 5 - Error // 6 - Fatal // // By default - 4 Level int `yaml:"level" env:"LOGGER_LEVEL,overwrite"` // Pretty is a flag used to enforce pretty log output // // By default - false Pretty bool `yaml:"pretty" env:"LOGGER_PRETTY,overwrite"` // Color is a flag used to enforce color indication of log levels // // By default - false Color bool `yaml:"color" env:"LOGGER_COLOR,overwrite"` // File is used to configure file log output // // By default - empty structure File FileLogConfig `yaml:"file"` // Elastic is used to configure elasticsearch log storage // // By default - empty structure Elastic ElasticLogConfig `yaml:"elastic"` } `yaml:"logger"` }
A LoggerConfig provides go-micro logger configuration for custom logger providers. This structure is expected to be initialized automatically by fx via yaml and env.
func (*LoggerConfig) Validate ¶
func (lc *LoggerConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type RateLimiterConfig ¶
type RateLimiterConfig struct { // Limit is global requests limit cap // // By default - 3000 Limit uint64 `yaml:"limit" env:"RATE_LIMIT,overwrite"` // IPLimit is ip specific requests limit cap // // By default - 20 IPLimit uint64 `yaml:"iplimit" env:"RATE_LIMIT_IP,overwrite"` }
A RateLimiterConfig provides rate-limiter's middleware configuration. This structure is expected to be initialized automatically by fx via yaml and env.
type RegistryConfig ¶
type RegistryConfig struct { // Registry is a nested structure used as a marker for yaml configuration. Registry struct { // Addresses is a list of registry instances. Addresses []string `yaml:"addresses" env:"REGISTRY_ADDRESSES,overwrite"` // CacheTTL is a service discovery interval. CacheTTL time.Duration `yaml:"cache_duration" env:"REGISTRY_CACHE_DURATION,overwrite"` // Type is a registry provider type // 1 - Kubernetes. // 2 - Consul. // 3 - ETCD. // 4 - MDNS. // // By default - 4 Type int `yaml:"type" env:"REGISTRY_TYPE,overwrite"` } `yaml:"registry"` }
A RegistryConfig provides go-micro registry configuration for custom registry providers. This structure is expected to be initialized automatically by fx via yaml and env.
func (*RegistryConfig) Validate ¶
func (r *RegistryConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type ResilienceConfig ¶
type ResilienceConfig struct { // Resilience is a nested structure used as a marker for yaml configuration. Resilience struct { // RateLimiter is a ratelimiter configuration. RateLimiter RateLimiterConfig `yaml:"rate_limiter"` // CircuitBreaker is a circuit breaker configuration. CircuitBreaker CircuitBreakerConfig `yaml:"circuit_breaker"` } `yaml:"resilience"` }
A CacheConfig provides an entry point configuration for resilience patterns. This structure is expected to be initialized automatically by fx via yaml and env.
func (*ResilienceConfig) Validate ¶
func (rc *ResilienceConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type ServerConfig ¶
type ServerConfig struct { // Namespace is service specific namespace. Used to build requests to the other // services in the same namespace. Namespace string `yaml:"namespace" env:"SERVER_NAMESPACE,overwrite"` // Name is the name of the current service. Name string `yaml:"name" env:"SERVER_NAME,overwrite"` // Version is current version of the service. Used in version middleware // to set X-Version header. // // By default - 0. Version string `yaml:"version" env:"SERVER_VERSION,overwrite"` // Address is the service's address/port. Address string `yaml:"address" env:"SERVER_ADDRESS,overwrite"` // ReplAddress is system service's address. ReplAddress string `yaml:"repl_address" env:"REPL_ADDRESS,overwrite"` // Debug is flag to enable/disable debug features of the system's service. // // By default - false. Debug bool `yaml:"debug" env:"SERVER_DEBUG,overwrite"` }
A ServerConfig provides go-micro service. This structure is expected to be initialized automatically by fx via yaml and env.
func (*ServerConfig) Validate ¶
func (hs *ServerConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type StorageConfig ¶
type StorageConfig struct { // Persistence is a nested structure used as a marker for yaml configuration. Storage struct { // Type is a persistence driver type. Type int `yaml:"type" env:"STORAGE_TYPE,overwrite"` // URL is a persistence driver adapter's url to connect to. URL string `yaml:"url" env:"STORAGE_URL,overwrite"` // DB is a database name to connect to. DB string `yaml:"db" env:"STORAGE_DB,overwrite"` } `yaml:"storage"` }
A StorageConfig provides configuration for service level storage adapters. This structure is expected to be initialized automatically by fx via yaml and env. It is expected to be injected directly into services.
func (*StorageConfig) Validate ¶
func (p *StorageConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type TracerConfig ¶
type TracerConfig struct { // Tracer is a nested structure used as a marker for yaml configuration. Tracer struct { // Name is tracer's name used to trace requests. Name string `yaml:"name" env:"TRACER_NAME,overwrite"` // Enable is flag to enable/disable tracing. Enable bool `yaml:"enable" env:"TRACER_ENABLE,overwrite"` // Address is tracer's instance address. Address string `yaml:"address" env:"TRACER_ADDRESS,overwrite"` // TracerType is a tracer provider selector. // 0 - Console. // 1 - Zipkin. // // By default - 0. TracerType int `yaml:"type" env:"TRACER_TYPE,overwrite"` FractionRatio float64 `yaml:"fraction" env:"TRACER_FRACTION_RATIO,overwrite"` } `yaml:"tracer"` }
A TracerConfig provides go-telemetry configuration for custom telemetry providers. This structure is expected to be initialized automatically by fx via yaml and env.
func (*TracerConfig) Validate ¶
func (tc *TracerConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic
type WorkerConfig ¶
type WorkerConfig struct { // Worker is a nested structure used as a marker for yaml configuration. Worker struct { // Enable is a worker's enable/disable flag. Enable bool `yaml:"enable" env:"WORKER_ENABLE,overwrite"` // Type is worker's implementation type. // 0 - Asynq worker. // // By default - 0. Type int `yaml:"type" env:"WORKER_TYPE,overwrite"` // MaxConcurrency is the maximum number of workers. MaxConcurrency int `yaml:"max_concurrency" env:"WORKER_MAX_CONCURRENCY,overwrite"` // RedisAddresses is redis instances addresses. RedisAddresses []string `yaml:"addresses" env:"WORKER_ADDRESS,overwrite"` // RedisUsername is redis basic auth username. RedisUsername string `yaml:"username" env:"WORKER_USERNAME,overwrite"` // RedisPassword is redis basic auth password. RedisPassword string `yaml:"password" env:"WORKER_PASSWORD,overwrite"` // RedisDatabase is worker's redis database for queueing. // // By default - 0. RedisDatabase int `yaml:"database" env:"WORKER_DATABASE,overwrite"` } `yaml:"worker"` }
A WorkerConfig provides an async worker's configuration for custom worker providers. This structure is expected to be initialized automatically by fx via yaml and env.
func (*WorkerConfig) Validate ¶
func (wc *WorkerConfig) Validate() error
Validate is called by fx and bootstrapper automatically after config initialization. It returns the first error encountered during validation.
A successful Validate returns err == nil. Errors other than nil will cause application to panic