Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Module = types.Module{ {CreateFunc: NewConfig}, {CreateFunc: ConfigAdapter}, }
Functions ¶
This section is empty.
Types ¶
type CommunicationConfig ¶ added in v1.2.0
type CommunicationConfig struct {
Enabled bool `envconfig:"COMMUNICATION_ENABLED" default:"false" yaml:"enabled"`
// TransportType (kafka,grpc)
TransportType string `envconfig:"COMMUNICATION_TRANSPORT_TYPE" default:"grpc" yaml:"transport_type"`
KafkaTopic string `envconfig:"COMMUNICATION_KAFKA_TOPIC" yaml:"kafka_topic"`
// GRPCAddresses адреса grpc, которые потому разбираются в map[string(serviceName)][]string(addresses)
// Например: "service1=address1:port1,address2:port2;service2=address3:port3"
GRPCAddresses string `envconfig:"COMMUNICATION_GRPC_ADDRESS" yaml:"grpc_address"`
}
type Config ¶
type Config struct {
HTTP HTTPServerConfig `yaml:"http"`
GRPC GRPCServerConfig `yaml:"grpc"`
APM ElasticAPMConfig `yaml:"apm"`
Kafka KafkaConfig `yaml:"kafka"`
DB []DB `yaml:"db"`
ElasticSearch ElasticSearch `yaml:"elastic_search"`
Sentry Sentry `yaml:"sentry"`
CouchbaseConfig CouchbaseConfig `yaml:"couchbase"`
ConsulConfig ConsulConfig `yaml:"consul"`
RedisConfig RedisConfig `yaml:"redis"`
ThrottleConfig ThrottleConfig `yaml:"throttle"`
Communication CommunicationConfig `yaml:"communication"`
ReleaseID string
Env string `envconfig:"ENV" default:"development" required:"true" yaml:"env"`
LogLevel string `envconfig:"LOG_LEVEL" default:"info" yaml:"log_level"`
AppName string `envconfig:"APP_NAME" yaml:"app_name"`
// DebugLog включает/выключает полные логи ответов (response payload).
DebugLog bool `envconfig:"DEBUG_LOG" default:"false" yaml:"debug_log"`
EnableServerMetrics bool `envconfig:"ENABLE_SERVER_METRICS" default:"true" yaml:"enable_server_metrics"`
}
type ConfigAdapterIn ¶
type Configure ¶
func ConfigAdapter ¶
func ConfigAdapter(in ConfigAdapterIn) []Configure
type ConsulConfig ¶ added in v1.1.0
type ConsulConfig struct {
Address string `envconfig:"CONSUL_ADDRESS" yaml:"address"`
Scheme string `envconfig:"CONSUL_SCHEME" default:"http" yaml:"proto"`
Token string `envconfig:"CONSUL_TOKEN" yaml:"token"`
InsecureSkipVerify bool `envconfig:"CONSUL_INSECURE_SKIP_VERIFY" default:"true" yaml:"insecure_skip_verify"`
SessionTTL string `envconfig:"CONSUL_SESSION_TTL" default:"20s" yaml:"session_ttl"`
LeaderTTL time.Duration `envconfig:"CONSUL_LEADER_TTL" default:"15s" yaml:"leader_ttl"`
ConsulServiceName string `envconfig:"CONSUL_SERVICE_NAME" yaml:"service_name"`
}
type CouchbaseConfig ¶ added in v1.0.23
type CouchbaseConfig struct {
DSN string `envconfig:"COUCHBASE_DSN" yaml:"dsn"`
User string `envconfig:"COUCHBASE_USER" yaml:"user"`
Password string `envconfig:"COUCHBASE_PWD" yaml:"password"`
Buckets string `envconfig:"COUCHBASE_BUCKET" yaml:"bucket"`
EnableDebug bool `envconfig:"COUCHBASE_ENABLE_DEBUG" default:"false" yaml:"enable_debug"`
}
type DB ¶ added in v1.0.1
type DB struct {
DSN string `yaml:"dsn"`
Name string `yaml:"name"`
// ConnType sqlx|pgx
ConnType string `yaml:"conntype"`
MaxOpenConnections int `yaml:"max_open_connections"`
MaxIdleConnections int `yaml:"max_idle_connections"`
ConnMaxLifetime time.Duration `yaml:"conn_max_lifetime"`
// DBType postgres/mssql/mysql
DBType string `yaml:"db_type"`
}
type ElasticAPMConfig ¶
type ElasticSearch ¶
type ElasticSearch struct {
// DSN представляет из себя строку, где URI:port нод кластера перечислены через запятую без пробелов
// Например: 'http://es1.localhost.com:9200,http://es2.localhost.com:9200'
DSN string `envconfig:"ELASTIC_SEARCH_DSN" yaml:"dsn"`
MaxRetries int `envconfig:"ELASTIC_SEARCH_MAX_RETRIES" default:"5" required:"true" yaml:"max_retries"`
WithLogger bool `envconfig:"ELASTIC_WITH_LOGGER" default:"false" required:"true" yaml:"with_logger"`
}
type GRPCServerConfig ¶
type GRPCServerConfig struct {
ListenAddr string `envconfig:"GRPC_LISTEN_ADDR" required:"true" default:":9090" yaml:"listen_addr"`
KeepaliveTime time.Duration `envconfig:"GRPC_KEEPALIVE_TIME" default:"30s" yaml:"keepalive_time"`
KeepaliveTimeout time.Duration `envconfig:"GRPC_KEEPALIVE_TIMEOUT" default:"10s" yaml:"keepalive_timeout"`
RegisterReflectionServer bool `envconfig:"GRPC_REGISTER_REFLECTION_SERVER" default:"true" yaml:"register_reflection_server"`
MaxReceiveMessageSize int `envconfig:"GRPC_MAX_RECEIVE_MESSAGE_SIZE" default:"10485760" yaml:"max_receive_message_size"` // 10MB
MaxSendMessageSize int `envconfig:"GRPC_MAX_SEND_MESSAGE_SIZE" default:"104857600" yaml:"max_send_message_size"` // 100MB
WithMetadata bool `envconfig:"GRPC_WITH_METADATA" default:"false" yaml:"with_metadata"`
}
type HTTPServerConfig ¶
type HTTPServerConfig struct {
ListenAddr string `envconfig:"HTTP_LISTEN_ADDR" required:"true" default:":8080" yaml:"listen_addr"`
KeepaliveTime time.Duration `envconfig:"HTTP_KEEPALIVE_TIME" default:"30s" yaml:"keepalive_time"`
KeepaliveTimeout time.Duration `envconfig:"HTTP_KEEPALIVE_TIMEOUT" default:"10s" yaml:"keepalive_timeout"`
}
type KafkaConfig ¶ added in v1.0.9
type RedisConfig ¶ added in v1.2.0
type ThrottleConfig ¶ added in v1.2.0
Click to show internal directories.
Click to hide internal directories.