Documentation
¶
Overview ¶
Package config loads the application configuration: the framework's own sections, held by App, and the sections a project adds with Register.
Resolution ¶
Every configuration key, the framework's own and those of a registered section alike, resolves in this priority, from highest to lowest:
- Environment variables
- The configuration file
- Default values: the framework's own, and the "default" struct tags of a registered section
A key's environment variable is the key in upper case with its dots turned into underscores: server.port reads SERVER_PORT, logger.http_body.enabled reads LOGGER_HTTP_BODY_ENABLED, and the endpoint field of a registered Sample section reads SAMPLE_ENDPOINT. A key reads its variable whether or not the file mentions the key and whether or not it has a default. A variable set to an empty string, false or 0 takes effect like any other value: an empty string clears a string and zeroes a number, a bool or a list. A variable whose name maps to no key reads nothing and is not reported — one named like a section rather than a key, such as SERVER, included: a process shares its environment with everything else running in it, such as the variables a container platform injects.
A registered type's section is its name in snake case: a SampleConfig type reads the [sample_config] section and the SAMPLE_CONFIG_ variables.
Failures ¶
Init fails, and the process with it, on configuration it cannot honor:
- A variable whose value does not decode into its key's type. The error names the variable, its value and the key, such as a SERVER_PORT of "tcp://10.0.0.1:8080" injected by a Kubernetes service link. A duration or a map has no empty form, so an empty value fails too.
- A key in the file under a section of the framework's own configuration that the section does not have, such as leve under logger. The error names the section and the key. A section the framework does not know is not checked: a project registers its own sections before Init or after it.
- A registered section named like a section of the framework's own configuration, such as a type named Mysql.
- Two types registering the same section. Registering the same type again is no conflict.
- A malformed "default" struct tag in a registered section.
Init checks the registrations made before it and reports each refused one once; a registration made after Init that cannot be honored panics.
Index ¶
- Constants
- Variables
- func Get[T any]() (t T)
- func Init() (err error)
- func Register[T any]()
- func Save(out io.Writer) error
- func SetConfigFile(file string)
- type AppInfo
- type Audit
- type Auth
- type ByteSize
- type Cache
- type Cassandra
- type CircuitBreaker
- type Clickhouse
- type Config
- type Consistency
- type ConsumeFromWhere
- type DBType
- type Database
- type Debug
- type DerefAliases
- type Elasticsearch
- type Etcd
- type GRPC
- type HTTPBodyLogMode
- type HTTPBodyLogger
- type Influxdb
- type Kafka
- type KafkaSASLMechanism
- type Ldap
- type LogFormat
- type LogLevel
- type Logger
- type LoggerOutput
- type Logmgmt
- type Middleware
- type Minio
- type Mode
- type Mongo
- type Mqtt
- type MySQL
- type Nats
- type OTEL
- type OTLPCompression
- type OTLPProtocol
- type Postgres
- type ReadConcern
- type ReconnectPolicy
- type Redis
- type RethinkDB
- type RetryPolicy
- type RocketMQ
- type Scope
- type Scylla
- type Server
- type Sqlite
- type TracesSampler
- type WriteConcern
Constants ¶
const ( APP_NAME = "APP_NAME" APP_VERSION = "APP_VERSION" APP_DESCRIPTION = "APP_DESCRIPTION" APP_AUTHOR = "APP_AUTHOR" APP_EMAIL = "APP_EMAIL" APP_HOMEPAGE = "APP_HOMEPAGE" APP_LICENSE = "APP_LICENSE" APP_BUILD_TIME = "APP_BUILD_TIME" APP_GIT_COMMIT = "APP_GIT_COMMIT" APP_GIT_BRANCH = "APP_GIT_BRANCH" APP_GO_VERSION = "APP_GO_VERSION" )
const ( AUDIT_ENABLED = "AUDIT_ENABLED" AUDIT_EXCLUDE_OPERATIONS = "AUDIT_EXCLUDE_OPERATIONS" )
const ( AUTH_JWT_SECRET = "AUTH_JWT_SECRET" AUTH_ACCESS_TOKEN_EXPIRE_DURATION = "AUTH_ACCESS_TOKEN_EXPIRE_DURATION" AUTH_REFRESH_TOKEN_EXPIRE_DURATION = "AUTH_REFRESH_TOKEN_EXPIRE_DURATION" AUTH_RBAC_ENABLED = "AUTH_RBAC_ENABLED" )
const ( CACHE_MAX_ENTRIES = "CACHE_MAX_ENTRIES" CACHE_TOPIC = "CACHE_TOPIC" )
const ( CASSANDRA_HOSTS = "CASSANDRA_HOSTS" CASSANDRA_PORT = "CASSANDRA_PORT" CASSANDRA_KEYSPACE = "CASSANDRA_KEYSPACE" CASSANDRA_USERNAME = "CASSANDRA_USERNAME" CASSANDRA_PASSWORD = "CASSANDRA_PASSWORD" CASSANDRA_CONSISTENCY = "CASSANDRA_CONSISTENCY" CASSANDRA_TIMEOUT = "CASSANDRA_TIMEOUT" CASSANDRA_CONNECT_TIMEOUT = "CASSANDRA_CONNECT_TIMEOUT" CASSANDRA_NUM_CONNS = "CASSANDRA_NUM_CONNS" CASSANDRA_PAGE_SIZE = "CASSANDRA_PAGE_SIZE" CASSANDRA_RETRY_POLICY = "CASSANDRA_RETRY_POLICY" CASSANDRA_RECONNECT_INTERVAL = "CASSANDRA_RECONNECT_INTERVAL" CASSANDRA_MAX_RETRY_COUNT = "CASSANDRA_MAX_RETRY_COUNT" CASSANDRA_TLS_ENABLED = "CASSANDRA_TLS_ENABLED" CASSANDRA_CERT_FILE = "CASSANDRA_CERT_FILE" CASSANDRA_KEY_FILE = "CASSANDRA_KEY_FILE" CASSANDRA_CA_FILE = "CASSANDRA_CA_FILE" CASSANDRA_INSECURE_SKIP_VERIFY = "CASSANDRA_INSECURE_SKIP_VERIFY" CASSANDRA_ENABLED = "CASSANDRA_ENABLED" )
const ( CLICKHOUSE_HOST = "CLICKHOUSE_HOST" CLICKHOUSE_PORT = "CLICKHOUSE_PORT" CLICKHOUSE_DATABASE = "CLICKHOUSE_DATABASE" CLICKHOUSE_USERNAME = "CLICKHOUSE_USERNAME" CLICKHOUSE_PASSWORD = "CLICKHOUSE_PASSWORD" CLICKHOUSE_DIAL_TIMEOUT = "CLICKHOUSE_DIAL_TIMEOUT" CLICKHOUSE_READ_TIMEOUT = "CLICKHOUSE_READ_TIMEOUT" CLICKHOUSE_COMPRESS = "CLICKHOUSE_COMPRESS" CLICKHOUSE_DEBUG = "CLICKHOUSE_DEBUG" CLICKHOUSE_ENABLED = "CLICKHOUSE_ENABLED" )
const ( DATABASE_TYPE = "DATABASE_TYPE" DATABASE_AUTO_MIGRATE = "DATABASE_AUTO_MIGRATE" DATABASE_SLOW_QUERY_THRESHOLD = "DATABASE_SLOW_QUERY_THRESHOLD" DATABASE_MAX_IDLE_CONNS = "DATABASE_MAX_IDLE_CONNS" DATABASE_MAX_OPEN_CONNS = "DATABASE_MAX_OPEN_CONNS" DATABASE_CONN_MAX_LIFETIME = "DATABASE_CONN_MAX_LIFETIME" DATABASE_CONN_MAX_IDLE_TIME = "DATABASE_CONN_MAX_IDLE_TIME" )
const ( DEBUG_STATSVIZ_ENABLED = "DEBUG_STATSVIZ_ENABLED" DEBUG_STATSVIZ_LISTEN = "DEBUG_STATSVIZ_LISTEN" DEBUG_STATSVIZ_PORT = "DEBUG_STATSVIZ_PORT" DEBUG_PPROF_ENABLED = "DEBUG_PPROF_ENABLED" DEBUG_PPROF_LISTEN = "DEBUG_PPROF_LISTEN" DEBUG_PPROF_PORT = "DEBUG_PPROF_PORT" DEBUG_GOPS_ENABLED = "DEBUG_GOPS_ENABLED" DEBUG_GOPS_LISTEN = "DEBUG_GOPS_LISTEN" DEBUG_GOPS_PORT = "DEBUG_GOPS_PORT" )
const ( ELASTICSEARCH_ADDRS = "ELASTICSEARCH_ADDRS" ELASTICSEARCH_USERNAME = "ELASTICSEARCH_USERNAME" ELASTICSEARCH_PASSWORD = "ELASTICSEARCH_PASSWORD" ELASTICSEARCH_CLOUD_ID = "ELASTICSEARCH_CLOUD_ID" ELASTICSEARCH_API_KEY = "ELASTICSEARCH_API_KEY" ELASTICSEARCH_MAX_RETRIES = "ELASTICSEARCH_MAX_RETRIES" ELASTICSEARCH_RETRY_ON_STATUS = "ELASTICSEARCH_RETRY_ON_STATUS" ELASTICSEARCH_DISABLE_RETRIES = "ELASTICSEARCH_DISABLE_RETRIES" ELASTICSEARCH_RETRY_BACKOFF = "ELASTICSEARCH_RETRY_BACKOFF" ELASTICSEARCH_RETRY_BACKOFF_MIN = "ELASTICSEARCH_RETRY_BACKOFF_MIN" ELASTICSEARCH_RETRY_BACKOFF_MAX = "ELASTICSEARCH_RETRY_BACKOFF_MAX" ELASTICSEARCH_COMPRESS = "ELASTICSEARCH_COMPRESS" ELASTICSEARCH_DISCOVERY_INTERVAL = "ELASTICSEARCH_DISCOVERY_INTERVAL" ELASTICSEARCH_METRICS_ENABLED = "ELASTICSEARCH_METRICS_ENABLED" ELASTICSEARCH_DEBUG_LOGGER_ENABLED = "ELASTICSEARCH_DEBUG_LOGGER_ENABLED" ELASTICSEARCH_CONNECTION_POOL_SIZE = "ELASTICSEARCH_CONNECTION_POOL_SIZE" ELASTICSEARCH_RESPONSE_HEADER_TIMEOUT = "ELASTICSEARCH_RESPONSE_HEADER_TIMEOUT" ELASTICSEARCH_REQUEST_TIMEOUT = "ELASTICSEARCH_REQUEST_TIMEOUT" ELASTICSEARCH_DIAL_TIMEOUT = "ELASTICSEARCH_DIAL_TIMEOUT" ELASTICSEARCH_KEEP_ALIVE_INTERVAL = "ELASTICSEARCH_KEEP_ALIVE_INTERVAL" ELASTICSEARCH_TLS_ENABLED = "ELASTICSEARCH_TLS_ENABLED" ELASTICSEARCH_CERT_FILE = "ELASTICSEARCH_CERT_FILE" ELASTICSEARCH_KEY_FILE = "ELASTICSEARCH_KEY_FILE" ELASTICSEARCH_CA_FILE = "ELASTICSEARCH_CA_FILE" ELASTICSEARCH_INSECURE_SKIP_VERIFY = "ELASTICSEARCH_INSECURE_SKIP_VERIFY" ELASTICSEARCH_ENABLED = "ELASTICSEARCH_ENABLED" )
const ( ETCD_ENDPOINTS = "ETCD_ENDPOINTS" ETCD_DIAL_TIMEOUT = "ETCD_DIAL_TIMEOUT" ETCD_USERNAME = "ETCD_USERNAME" ETCD_PASSWORD = "ETCD_PASSWORD" ETCD_AUTO_SYNC = "ETCD_AUTO_SYNC" ETCD_AUTO_SYNC_INTERVAL = "ETCD_AUTO_SYNC_INTERVAL" ETCD_KEEPALIVE_TIME = "ETCD_KEEPALIVE_TIME" ETCD_KEEPALIVE_TIMEOUT = "ETCD_KEEPALIVE_TIMEOUT" ETCD_MAX_CALL_SEND_MSG_SIZE = "ETCD_MAX_CALL_SEND_MSG_SIZE" ETCD_MAX_CALL_RECV_MSG_SIZE = "ETCD_MAX_CALL_RECV_MSG_SIZE" ETCD_PERMIT_WITHOUT_STREAM = "ETCD_PERMIT_WITHOUT_STREAM" ETCD_REJECT_OLD_CLUSTER = "ETCD_REJECT_OLD_CLUSTER" ETCD_TLS_ENABLED = "ETCD_TLS_ENABLED" ETCD_CERT_FILE = "ETCD_CERT_FILE" ETCD_KEY_FILE = "ETCD_KEY_FILE" ETCD_CA_FILE = "ETCD_CA_FILE" ETCD_INSECURE_SKIP_VERIFY = "ETCD_INSECURE_SKIP_VERIFY" ETCD_ENABLED = "ETCD_ENABLED" )
const ( GRPC_LISTEN = "GRPC_LISTEN" GRPC_PORT = "GRPC_PORT" GRPC_TLS_ENABLED = "GRPC_TLS_ENABLED" GRPC_CERT_FILE = "GRPC_CERT_FILE" GRPC_KEY_FILE = "GRPC_KEY_FILE" GRPC_REFLECTION = "GRPC_REFLECTION" GRPC_KEEPALIVE_TIME = "GRPC_KEEPALIVE_TIME" GRPC_KEEPALIVE_TIMEOUT = "GRPC_KEEPALIVE_TIMEOUT" GRPC_KEEPALIVE_MIN_TIME = "GRPC_KEEPALIVE_MIN_TIME" GRPC_KEEPALIVE_PERMIT_WITHOUT_STREAM = "GRPC_KEEPALIVE_PERMIT_WITHOUT_STREAM" GRPC_MAX_CONNECTION_AGE = "GRPC_MAX_CONNECTION_AGE" GRPC_MAX_CONNECTION_AGE_GRACE = "GRPC_MAX_CONNECTION_AGE_GRACE" GRPC_MAX_RECV_MSG_SIZE = "GRPC_MAX_RECV_MSG_SIZE" )
const ( INFLUXDB_HOST = "INFLUXDB_HOST" INFLUXDB_PORT = "INFLUXDB_PORT" INFLUXDB_TOKEN = "INFLUXDB_TOKEN" INFLUXDB_ORG = "INFLUXDB_ORG" INFLUXDB_BUCKET = "INFLUXDB_BUCKET" INFLUXDB_BATCH_SIZE = "INFLUXDB_BATCH_SIZE" INFLUXDB_FLUSH_INTERVAL = "INFLUXDB_FLUSH_INTERVAL" INFLUXDB_RETRY_INTERVAL = "INFLUXDB_RETRY_INTERVAL" INFLUXDB_MAX_RETRIES = "INFLUXDB_MAX_RETRIES" INFLUXDB_RETRY_BUFFER_LIMIT = "INFLUXDB_RETRY_BUFFER_LIMIT" INFLUXDB_MAX_RETRY_INTERVAL = "INFLUXDB_MAX_RETRY_INTERVAL" INFLUXDB_MAX_RETRY_TIME = "INFLUXDB_MAX_RETRY_TIME" INFLUXDB_EXPONENTIAL_BASE = "INFLUXDB_EXPONENTIAL_BASE" INFLUXDB_PRECISION = "INFLUXDB_PRECISION" INFLUXDB_USE_GZIP = "INFLUXDB_USE_GZIP" INFLUXDB_TLS_ENABLED = "INFLUXDB_TLS_ENABLED" INFLUXDB_CERT_FILE = "INFLUXDB_CERT_FILE" INFLUXDB_KEY_FILE = "INFLUXDB_KEY_FILE" INFLUXDB_CA_FILE = "INFLUXDB_CA_FILE" INFLUXDB_INSECURE_SKIP_VERIFY = "INFLUXDB_INSECURE_SKIP_VERIFY" INFLUXDB_DEFAULT_TAGS = "INFLUXDB_DEFAULT_TAGS" // format: key1=value1,key2=value2 INFLUXDB_APP_NAME = "INFLUXDB_APP_NAME" INFLUXDB_ENABLED = "INFLUXDB_ENABLED" )
const ( KAFKA_BROKERS = "KAFKA_BROKERS" KAFKA_CLIENT_ID = "KAFKA_CLIENT_ID" KAFKA_SASL_ENABLED = "KAFKA_SASL_ENABLED" KAFKA_SASL_MECHANISM = "KAFKA_SASL_MECHANISM" KAFKA_SASL_USERNAME = "KAFKA_SASL_USERNAME" KAFKA_SASL_PASSWORD = "KAFKA_SASL_PASSWORD" KAFKA_TLS_ENABLED = "KAFKA_TLS_ENABLED" KAFKA_CERT_FILE = "KAFKA_CERT_FILE" KAFKA_KEY_FILE = "KAFKA_KEY_FILE" KAFKA_CA_FILE = "KAFKA_CA_FILE" KAFKA_INSECURE_SKIP_VERIFY = "KAFKA_INSECURE_SKIP_VERIFY" KAFKA_ENABLED = "KAFKA_ENABLED" )
const ( LDAP_HOST = "LDAP_HOST" LDAP_PORT = "LDAP_PORT" LDAP_BASE_DN = "LDAP_BASE_DN" LDAP_BIND_DN = "LDAP_BIND_DN" LDAP_BIND_PASSWORD = "LDAP_BIND_PASSWORD" LDAP_ATTRIBUTES = "LDAP_ATTRIBUTES" LDAP_FILTER = "LDAP_FILTER" LDAP_GROUP_FILTER = "LDAP_GROUP_FILTER" LDAP_USER_FILTER = "LDAP_USER_FILTER" LDAP_GROUP_DN = "LDAP_GROUP_DN" LDAP_USER_DN = "LDAP_USER_DN" LDAP_GROUP_ATTRIBUTE = "LDAP_GROUP_ATTRIBUTE" LDAP_USER_ATTRIBUTE = "LDAP_USER_ATTRIBUTE" LDAP_SCOPE = "LDAP_SCOPE" LDAP_REQUEST_TIMEOUT = "LDAP_REQUEST_TIMEOUT" LDAP_CONN_TIMEOUT = "LDAP_CONN_TIMEOUT" LDAP_REFERRALS = "LDAP_REFERRALS" LDAP_DEREF = "LDAP_DEREF" LDAP_PAGE_SIZE = "LDAP_PAGE_SIZE" LDAP_HEARTBEAT = "LDAP_HEARTBEAT" LDAP_TLS_ENABLED = "LDAP_TLS_ENABLED" LDAP_CERT_FILE = "LDAP_CERT_FILE" LDAP_KEY_FILE = "LDAP_KEY_FILE" LDAP_CA_FILE = "LDAP_CA_FILE" LDAP_INSECURE_SKIP_VERIFY = "LDAP_INSECURE_SKIP_VERIFY" LDAP_ENABLED = "LDAP_ENABLED" )
const ( LOGGER_OUTPUT = "LOGGER_OUTPUT" LOGGER_DIR = "LOGGER_DIR" LOGGER_FILE = "LOGGER_FILE" LOGGER_CONSOLE = "LOGGER_CONSOLE" LOGGER_LEVEL = "LOGGER_LEVEL" LOGGER_FORMAT = "LOGGER_FORMAT" LOGGER_ERROR_STACK_DISABLED = "LOGGER_ERROR_STACK_DISABLED" LOGGER_MAX_AGE = "LOGGER_MAX_AGE" LOGGER_MAX_SIZE = "LOGGER_MAX_SIZE" LOGGER_MAX_BACKUPS = "LOGGER_MAX_BACKUPS" LOGGER_HTTP_BODY_ENABLED = "LOGGER_HTTP_BODY_ENABLED" LOGGER_HTTP_BODY_LOG_REQUEST = "LOGGER_HTTP_BODY_LOG_REQUEST" LOGGER_HTTP_BODY_LOG_RESPONSE = "LOGGER_HTTP_BODY_LOG_RESPONSE" LOGGER_HTTP_BODY_MAX_BODY_SIZE = "LOGGER_HTTP_BODY_MAX_BODY_SIZE" LOGGER_HTTP_BODY_SKIP_ROUTES = "LOGGER_HTTP_BODY_SKIP_ROUTES" LOGGER_SQL_CALLER_SKIP_PREFIXES = "LOGGER_SQL_CALLER_SKIP_PREFIXES" )
const ( LOGMGMT_RETENTION = "LOGMGMT_RETENTION" LOGMGMT_CLEANUP_CRON = "LOGMGMT_CLEANUP_CRON" )
const ( MIDDLEWARE_JWT_AUTH_ENABLED = "MIDDLEWARE_JWT_AUTH_ENABLED" MIDDLEWARE_AUTHZ_ENABLED = "MIDDLEWARE_AUTHZ_ENABLED" MIDDLEWARE_IAM_SESSION_ENABLED = "MIDDLEWARE_IAM_SESSION_ENABLED" )
const ( MINIO_ENDPOINT = "MINIO_ENDPOINT" MINIO_ACCESS_KEY = "MINIO_ACCESS_KEY" MINIO_SECRET_KEY = "MINIO_SECRET_KEY" MINIO_BUCKET = "MINIO_BUCKET" MINIO_LOCATION = "MINIO_LOCATION" MINIO_SECURE = "MINIO_SECURE" MINIO_REGION = "MINIO_REGION" MINIO_TIMEOUT = "MINIO_TIMEOUT" MINIO_PART_SIZE = "MINIO_PART_SIZE" MINIO_CONCURRENCY = "MINIO_CONCURRENCY" MINIO_COMPRESS = "MINIO_COMPRESS" MINIO_TRACE = "MINIO_TRACE" MINIO_SESSION_TOKEN = "MINIO_SESSION_TOKEN" MINIO_USE_IAM = "MINIO_USE_IAM" MINIO_USE_STS = "MINIO_USE_STS" MINIO_IAM_ENDPOINT = "MINIO_IAM_ENDPOINT" MINIO_STS_ENDPOINT = "MINIO_STS_ENDPOINT" MINIO_TLS_ENABLED = "MINIO_TLS_ENABLED" MINIO_CERT_FILE = "MINIO_CERT_FILE" MINIO_KEY_FILE = "MINIO_KEY_FILE" MINIO_CA_FILE = "MINIO_CA_FILE" MINIO_INSECURE_SKIP_VERIFY = "MINIO_INSECURE_SKIP_VERIFY" MINIO_ENABLED = "MINIO_ENABLED" )
const ( MONGO_HOST = "MONGO_HOST" MONGO_PORT = "MONGO_PORT" MONGO_USERNAME = "MONGO_USERNAME" MONGO_PASSWORD = "MONGO_PASSWORD" MONGO_DATABASE = "MONGO_DATABASE" MONGO_AUTH_SOURCE = "MONGO_AUTH_SOURCE" MONGO_MAX_POOL_SIZE = "MONGO_MAX_POOL_SIZE" MONGO_MIN_POOL_SIZE = "MONGO_MIN_POOL_SIZE" MONGO_CONNECT_TIMEOUT = "MONGO_CONNECT_TIMEOUT" MONGO_SERVER_SELECTION_TIMEOUT = "MONGO_SERVER_SELECTION_TIMEOUT" MONGO_MAX_CONN_IDLE_TIME = "MONGO_MAX_CONN_IDLE_TIME" MONGO_MAX_CONNECTING = "MONGO_MAX_CONNECTING" MONGO_READ_CONCERN = "MONGO_READ_CONCERN" MONGO_WRITE_CONCERN = "MONGO_WRITE_CONCERN" MONGO_TLS_ENABLED = "MONGO_TLS_ENABLED" MONGO_CERT_FILE = "MONGO_CERT_FILE" MONGO_KEY_FILE = "MONGO_KEY_FILE" MONGO_CA_FILE = "MONGO_CA_FILE" MONGO_INSECURE_SKIP_VERIFY = "MONGO_INSECURE_SKIP_VERIFY" MONGO_ENABLED = "MONGO_ENABLED" )
const ( MQTT_ADDR = "MQTT_ADDR" MQTT_USERNAME = "MQTT_USERNAME" MQTT_PASSWORD = "MQTT_PASSWORD" MQTT_CLIENT_PREFIX = "MQTT_CLIENT_PREFIX" MQTT_CONNECT_TIMEOUT = "MQTT_CONNECT_TIMEOUT" MQTT_KEEPALIVE = "MQTT_KEEPALIVE" MQTT_CLEAN_SESSION = "MQTT_CLEAN_SESSION" MQTT_AUTO_RECONNECT = "MQTT_AUTO_RECONNECT" MQTT_USE_TLS = "MQTT_USE_TLS" MQTT_CERT_FILE = "MQTT_CERT_FILE" MQTT_KEY_FILE = "MQTT_KEY_FILE" MQTT_INSECURE_SKIP_VERIFY = "MQTT_INSECURE_SKIP_VERIFY" MQTT_ENABLED = "MQTT_ENABLED" )
const ( MYSQL_HOST = "MYSQL_HOST" MYSQL_PORT = "MYSQL_PORT" MYSQL_DATABASE = "MYSQL_DATABASE" MYSQL_USERNAME = "MYSQL_USERNAME" MYSQL_PASSWORD = "MYSQL_PASSWORD" MYSQL_DIAL_TIMEOUT = "MYSQL_DIAL_TIMEOUT" MYSQL_READ_TIMEOUT = "MYSQL_READ_TIMEOUT" MYSQL_WRITE_TIMEOUT = "MYSQL_WRITE_TIMEOUT" MYSQL_REPLICAS = "MYSQL_REPLICAS" MYSQL_STRICT = "MYSQL_STRICT" MYSQL_ENABLED = "MYSQL_ENABLED" )
const ( NATS_ADDRS = "NATS_ADDRS" NATS_CLIENT_NAME = "NATS_CLIENT_NAME" NATS_USERNAME = "NATS_USERNAME" NATS_PASSWORD = "NATS_PASSWORD" NATS_TOKEN = "NATS_TOKEN" NATS_CREDENTIALS = "NATS_CREDENTIALS" NATS_NKEY_FILE = "NATS_NKEY_FILE" NATS_MAX_RECONNECTS = "NATS_MAX_RECONNECTS" NATS_RECONNECT_WAIT = "NATS_RECONNECT_WAIT" NATS_RECONNECT_JITTER = "NATS_RECONNECT_JITTER" NATS_RECONNECT_JITTER_TLS = "NATS_RECONNECT_JITTER_TLS" NATS_CONNECT_TIMEOUT = "NATS_CONNECT_TIMEOUT" NATS_PING_INTERVAL = "NATS_PING_INTERVAL" NATS_MAX_PINGS_OUTSTANDING = "NATS_MAX_PINGS_OUTSTANDING" NATS_TLS_ENABLED = "NATS_TLS_ENABLED" NATS_CERT_FILE = "NATS_CERT_FILE" NATS_KEY_FILE = "NATS_KEY_FILE" NATS_CA_FILE = "NATS_CA_FILE" NATS_INSECURE_SKIP_VERIFY = "NATS_INSECURE_SKIP_VERIFY" NATS_ENABLED = "NATS_ENABLED" )
const ( // OTEL_ENABLED enables OpenTelemetry tracing. OTEL_ENABLED = "OTEL_ENABLED" // OTEL_SERVICE_NAME configures the OpenTelemetry service.name resource attribute. OTEL_SERVICE_NAME = "OTEL_SERVICE_NAME" // OTEL_EXPORTER_OTLP_PROTOCOL configures the OTLP traces transport protocol. OTEL_EXPORTER_OTLP_PROTOCOL = "OTEL_EXPORTER_OTLP_PROTOCOL" // OTEL_EXPORTER_OTLP_TRACES_ENDPOINT configures the trace-specific OTLP endpoint. OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" // OTEL_EXPORTER_OTLP_HEADERS configures headers sent with OTLP trace exports. OTEL_EXPORTER_OTLP_HEADERS = "OTEL_EXPORTER_OTLP_HEADERS" // OTEL_EXPORTER_OTLP_COMPRESSION configures OTLP trace export compression. OTEL_EXPORTER_OTLP_COMPRESSION = "OTEL_EXPORTER_OTLP_COMPRESSION" // OTEL_TRACES_SAMPLER configures the OpenTelemetry traces sampler. OTEL_TRACES_SAMPLER = "OTEL_TRACES_SAMPLER" // OTEL_TRACES_SAMPLER_ARG configures the OpenTelemetry traces sampler argument. OTEL_TRACES_SAMPLER_ARG = "OTEL_TRACES_SAMPLER_ARG" // OTEL_BSP_MAX_QUEUE_SIZE configures the BatchSpanProcessor queue capacity. OTEL_BSP_MAX_QUEUE_SIZE = "OTEL_BSP_MAX_QUEUE_SIZE" // OTEL_BSP_MAX_EXPORT_BATCH_SIZE configures the BatchSpanProcessor export batch limit. OTEL_BSP_MAX_EXPORT_BATCH_SIZE = "OTEL_BSP_MAX_EXPORT_BATCH_SIZE" // OTEL_BSP_SCHEDULE_DELAY configures the BatchSpanProcessor schedule delay. OTEL_BSP_SCHEDULE_DELAY = "OTEL_BSP_SCHEDULE_DELAY" // OTEL_BSP_EXPORT_TIMEOUT configures the BatchSpanProcessor export timeout. OTEL_BSP_EXPORT_TIMEOUT = "OTEL_BSP_EXPORT_TIMEOUT" )
const ( POSTGRES_HOST = "POSTGRES_HOST" POSTGRES_PORT = "POSTGRES_PORT" POSTGRES_DATABASE = "POSTGRES_DATABASE" POSTGRES_USERNAME = "POSTGRES_USERNAME" POSTGRES_PASSWORD = "POSTGRES_PASSWORD" POSTGRES_SSLMODE = "POSTGRES_SSLMODE" POSTGRES_REPLICAS = "POSTGRES_REPLICAS" POSTGRES_ENABLED = "POSTGRES_ENABLED" )
const ( REDIS_ADDR = "REDIS_ADDR" REDIS_ADDRS = "REDIS_ADDRS" REDIS_DB = "REDIS_DB" REDIS_PASSWORD = "REDIS_PASSWORD" REDIS_NAMESPACE = "REDIS_NAMESPACE" REDIS_POOL_SIZE = "REDIS_POOL_SIZE" REDIS_EXPIRATION = "REDIS_EXPIRATION" REDIS_CLUSTER_MODE = "REDIS_CLUSTER_MODE" REDIS_DIAL_TIMEOUT = "REDIS_DIAL_TIMEOUT" REDIS_READ_TIMEOUT = "REDIS_READ_TIMEOUT" REDIS_WRITE_TIMEOUT = "REDIS_WRITE_TIMEOUT" REDIS_MIN_IDLE_CONNS = "REDIS_MIN_IDLE_CONNS" REDIS_MAX_RETRIES = "REDIS_MAX_RETRIES" REDIS_MIN_RETRY_BACKOFF = "REDIS_MIN_RETRY_BACKOFF" REDIS_MAX_RETRY_BACKOFF = "REDIS_MAX_RETRY_BACKOFF" REDIS_TLS_ENABLED = "REDIS_TLS_ENABLED" REDIS_CERT_FILE = "REDIS_CERT_FILE" REDIS_KEY_FILE = "REDIS_KEY_FILE" REDIS_CA_FILE = "REDIS_CA_FILE" REDIS_INSECURE_SKIP_VERIFY = "REDIS_INSECURE_SKIP_VERIFY" REDIS_ENABLED = "REDIS_ENABLED" )
const ( RETHINKDB_HOSTS = "RETHINKDB_HOSTS" RETHINKDB_USERNAME = "RETHINKDB_USERNAME" RETHINKDB_PASSWORD = "RETHINKDB_PASSWORD" RETHINKDB_DATABASE = "RETHINKDB_DATABASE" RETHINKDB_DISCOVERY_HOST = "RETHINKDB_DISCOVERY_HOST" RETHINKDB_MAX_IDLE = "RETHINKDB_MAX_IDLE" RETHINKDB_MAX_OPEN = "RETHINKDB_MAX_OPEN" RETHINKDB_NUM_RETRIES = "RETHINKDB_NUM_RETRIES" RETHINKDB_CONNECT_TIMEOUT = "RETHINKDB_CONNECT_TIMEOUT" RETHINKDB_READ_TIMEOUT = "RETHINKDB_READ_TIMEOUT" RETHINKDB_WRITE_TIMEOUT = "RETHINKDB_WRITE_TIMEOUT" RETHINKDB_KEEP_ALIVE_TIME = "RETHINKDB_KEEP_ALIVE_TIME" RETHINKDB_TLS_ENABLED = "RETHINKDB_TLS_ENABLED" RETHINKDB_CERT_FILE = "RETHINKDB_CERT_FILE" RETHINKDB_KEY_FILE = "RETHINKDB_KEY_FILE" RETHINKDB_CA_FILE = "RETHINKDB_CA_FILE" RETHINKDB_INSECURE_SKIP_VERIFY = "RETHINKDB_INSECURE_SKIP_VERIFY" RETHINKDB_ENABLED = "RETHINKDB_ENABLED" )
const ( ROCKETMQ_NAME_SERVER_ADDRS = "ROCKETMQ_NAME_SERVER_ADDRS" ROCKETMQ_ACCESS_KEY = "ROCKETMQ_ACCESS_KEY" ROCKETMQ_SECRET_KEY = "ROCKETMQ_SECRET_KEY" ROCKETMQ_NAMESPACE = "ROCKETMQ_NAMESPACE" ROCKETMQ_GROUP_NAME = "ROCKETMQ_GROUP_NAME" ROCKETMQ_INSTANCE_NAME = "ROCKETMQ_INSTANCE_NAME" ROCKETMQ_NUM_RETRIES = "ROCKETMQ_NUM_RETRIES" ROCKETMQ_SEND_MSG_TIMEOUT = "ROCKETMQ_SEND_MSG_TIMEOUT" ROCKETMQ_VIP_CHANNEL_ENABLED = "ROCKETMQ_VIP_CHANNEL_ENABLED" ROCKETMQ_CONSUME_ORDERLY = "ROCKETMQ_CONSUME_ORDERLY" ROCKETMQ_MAX_RECONSUME_TIMES = "ROCKETMQ_MAX_RECONSUME_TIMES" ROCKETMQ_AUTO_COMMIT = "ROCKETMQ_AUTO_COMMIT" ROCKETMQ_CONSUME_CONCURRENTLY_MAX_SPAN = "ROCKETMQ_CONSUME_CONCURRENTLY_MAX_SPAN" ROCKETMQ_CONSUME_MESSAGE_BATCH_MAX_SIZE = "ROCKETMQ_CONSUME_MESSAGE_BATCH_MAX_SIZE" ROCKETMQ_CONSUME_FROM_WHERE = "ROCKETMQ_CONSUME_FROM_WHERE" ROCKETMQ_CONSUME_TIMESTAMP = "ROCKETMQ_CONSUME_TIMESTAMP" ROCKETMQ_TRACE_ENABLED = "ROCKETMQ_TRACE_ENABLED" ROCKETMQ_ENABLED = "ROCKETMQ_ENABLED" )
const ( SCYLLA_HOSTS = "SCYLLA_HOSTS" SCYLLA_USERNAME = "SCYLLA_USERNAME" SCYLLA_PASSWORD = "SCYLLA_PASSWORD" SCYLLA_KEYSPACE = "SCYLLA_KEYSPACE" SCYLLA_CONSISTENCY = "SCYLLA_CONSISTENCY" SCYLLA_NUM_CONNS = "SCYLLA_NUM_CONNS" SCYLLA_CONNECT_TIMEOUT = "SCYLLA_CONNECT_TIMEOUT" SCYLLA_TIMEOUT = "SCYLLA_TIMEOUT" SCYLLA_PAGE_SIZE = "SCYLLA_PAGE_SIZE" SCYLLA_RETRY_POLICY = "SCYLLA_RETRY_POLICY" SCYLLA_RETRY_NUM_RETRIES = "SCYLLA_RETRY_NUM_RETRIES" SCYLLA_RETRY_MIN_INTERVAL = "SCYLLA_RETRY_MIN_INTERVAL" SCYLLA_RETRY_MAX_INTERVAL = "SCYLLA_RETRY_MAX_INTERVAL" SCYLLA_RECONNECT_POLICY = "SCYLLA_RECONNECT_POLICY" SCYLLA_RECONNECT_MAX_RETRIES = "SCYLLA_RECONNECT_MAX_RETRIES" SCYLLA_RECONNECT_INITIAL_INTERVAL = "SCYLLA_RECONNECT_INITIAL_INTERVAL" SCYLLA_RECONNECT_MAX_INTERVAL = "SCYLLA_RECONNECT_MAX_INTERVAL" SCYLLA_RECONNECT_CONSTANT_INTERVAL = "SCYLLA_RECONNECT_CONSTANT_INTERVAL" SCYLLA_TRACING_ENABLED = "SCYLLA_TRACING_ENABLED" SCYLLA_TLS_ENABLED = "SCYLLA_TLS_ENABLED" SCYLLA_CERT_FILE = "SCYLLA_CERT_FILE" SCYLLA_KEY_FILE = "SCYLLA_KEY_FILE" SCYLLA_CA_FILE = "SCYLLA_CA_FILE" SCYLLA_INSECURE_SKIP_VERIFY = "SCYLLA_INSECURE_SKIP_VERIFY" SCYLLA_ENABLED = "SCYLLA_ENABLED" )
const ( Prod = "prod" Stg = "stg" Pre = "pre" Test = "test" Dev = "dev" Local = "local" )
The conventional values of Mode.
const ( SERVER_DOMAIN = "SERVER_DOMAIN" SERVER_MODE = "SERVER_MODE" SERVER_LISTEN = "SERVER_LISTEN" SERVER_PORT = "SERVER_PORT" SERVER_TRUSTED_PROXIES = "SERVER_TRUSTED_PROXIES" SERVER_SHUTDOWN_DELAY = "SERVER_SHUTDOWN_DELAY" SERVER_READ_TIMEOUT = "SERVER_READ_TIMEOUT" SERVER_WRITE_TIMEOUT = "SERVER_WRITE_TIMEOUT" SERVER_IDLE_TIMEOUT = "SERVER_IDLE_TIMEOUT" SERVER_CIRCUIT_BREAKER_NAME = "SERVER_CIRCUIT_BREAKER_NAME" SERVER_CIRCUIT_BREAKER_MAX_REQUESTS = "SERVER_CIRCUIT_BREAKER_MAX_REQUESTS" SERVER_CIRCUIT_BREAKER_INTERVAL = "SERVER_CIRCUIT_BREAKER_INTERVAL" SERVER_CIRCUIT_BREAKER_TIMEOUT = "SERVER_CIRCUIT_BREAKER_TIMEOUT" SERVER_CIRCUIT_BREAKER_FAILURE_RATE = "SERVER_CIRCUIT_BREAKER_FAILURE_RATE" SERVER_CIRCUIT_BREAKER_MIN_REQUESTS = "SERVER_CIRCUIT_BREAKER_MIN_REQUESTS" SERVER_CIRCUIT_BREAKER_ENABLED = "SERVER_CIRCUIT_BREAKER_ENABLED" SERVER_CIRCULAR_BUFFER_SIZE_OPERATION_LOG = "SERVER_CIRCULAR_BUFFER_SIZE_OPERATION_LOG" )
const ( SQLITE_PATH = "SQLITE_PATH" SQLITE_IS_MEMORY = "SQLITE_IS_MEMORY" SQLITE_ENABLED = "SQLITE_ENABLED" )
Variables ¶
var ( // App holds the framework's own configuration Init loads. App = new(Config) )
Functions ¶
func Get ¶
func Get[T any]() (t T)
Get returns the registered custom configuration. The type parameter T must match the registered type or be a pointer to it, otherwise a zero value or nil pointer will be returned.
Example usage:
config.Register[SampleConfig]() // Get by struct type - returns a copy cfg1 := config.Get[SampleConfig]() // Get by pointer type - returns pointer cfg2 := config.Get[*SampleConfig]() // Not registered - returns zero value cfg3 := config.Get[OtherConfig]() // Not registered - returns nil cfg4 := config.Get[*OtherConfig]()
func Init ¶
func Init() (err error)
Init initializes the application configuration: App and every section registered so far, each key resolved from the environment, the file and the defaults in that order. It fails on the configuration it cannot honor; the package documentation lists the rules and the failures.
func Register ¶
func Register[T any]()
Register registers a custom configuration into the config system. The type parameter T can be either struct type or pointer to struct type. Registering any other type is a declaration error, reported the way a taken section is: Init reports one registered before it, and registering one after Init panics. The registered type will be used to create and initialize the configuration instance when loading configuration from file or environment variables.
The type's section is its name in snake case: SampleConfig reads the [sample_config] section, and a field reads the environment variable of its key, SAMPLE_CONFIG_ENDPOINT, or SAMPLE_CONFIG_TLS_CERT_FILE for a nested one. The section resolves like every key, see the package documentation.
The struct tag "default" can be used to set default values for fields. For time.Duration fields, you can use duration strings like "5s", "1m", etc.
Register can be called before or after `Init`. If called before `Init`, the registration will be processed during initialization, where Init fails on one it cannot honor; a registration after Init that cannot be honored panics. The package documentation lists what cannot be honored.
Example usage:
type SampleConfig struct {
Endpoint string `json:"endpoint" mapstructure:"endpoint" default:"127.0.0.1:8080"`
Token string `json:"token" mapstructure:"token"`
Enabled bool `json:"enabled" mapstructure:"enabled"`
}
type NotifierConfig struct {
URL string `json:"url" mapstructure:"url" default:"http://127.0.0.1:9000"`
Username string `json:"username" mapstructure:"username" default:"notifier"`
Password string `json:"password" mapstructure:"password"`
Timeout time.Duration `json:"timeout" mapstructure:"timeout" default:"5s"`
Enabled bool `json:"enabled" mapstructure:"enabled"`
}
// Register with struct type
config.Register[SampleConfig]()
// Register with pointer type
config.Register[*NotifierConfig]()
After registration, you can access the config using Get:
notifierCfg := config.Get[NotifierConfig]() // or with pointer notifierPtr := config.Get[*NotifierConfig]()
func Save ¶
Save writes the configuration Init loaded, every key as it resolved, to out in the config file's format.
func SetConfigFile ¶
func SetConfigFile(file string)
SetConfigFile sets an explicit config file path. You should always call this function before `Init`.
Types ¶
type AppInfo ¶
type AppInfo struct {
// Basic application information
Name string `json:"name" mapstructure:"name" ini:"name" yaml:"name"`
Version string `json:"version" mapstructure:"version" ini:"version" yaml:"version"`
Description string `json:"description" mapstructure:"description" ini:"description" yaml:"description"`
Author string `json:"author" mapstructure:"author" ini:"author" yaml:"author"`
Email string `json:"email" mapstructure:"email" ini:"email" yaml:"email"`
Homepage string `json:"homepage" mapstructure:"homepage" ini:"homepage" yaml:"homepage"`
License string `json:"license" mapstructure:"license" ini:"license" yaml:"license"`
// Build and runtime information. BuildTime is the time the configuration
// names, or else the time of the commit Go recorded in the binary.
BuildTime time.Time `json:"build_time" mapstructure:"build_time" ini:"build_time" yaml:"build_time"`
GitCommit string `json:"git_commit" mapstructure:"git_commit" ini:"git_commit" yaml:"git_commit"`
GitBranch string `json:"git_branch" mapstructure:"git_branch" ini:"git_branch" yaml:"git_branch"`
GoVersion string `json:"go_version" mapstructure:"go_version" ini:"go_version" yaml:"go_version"`
GitTag string `json:"git_tag" mapstructure:"git_tag" ini:"git_tag" yaml:"git_tag"`
GitTreeState string `json:"git_tree_state" mapstructure:"git_tree_state" ini:"git_tree_state" yaml:"git_tree_state"`
Platform string `json:"platform" mapstructure:"platform" ini:"platform" yaml:"platform"`
Compiler string `json:"compiler" mapstructure:"compiler" ini:"compiler" yaml:"compiler"`
BuildTags []string `json:"build_tags" mapstructure:"build_tags" ini:"build_tags" yaml:"build_tags"`
}
AppInfo represents application metadata and build information This struct contains essential project information that can be used for version reporting, monitoring, and application identification
type Audit ¶
type Audit struct {
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
ExcludeOperations []types.Operation `json:"exclude_operations" mapstructure:"exclude_operations" ini:"exclude_operations" yaml:"exclude_operations"`
}
Audit configures the operation log: whether the framework records what its handlers did, and which operations it leaves out. An entry is written in the request that produced it, so a request that answered success has its record before it answers.
type Auth ¶
type Auth struct {
JWTSecret string `json:"jwt_secret" mapstructure:"jwt_secret" ini:"jwt_secret" yaml:"jwt_secret"`
AccessTokenExpireDuration time.Duration `` /* 150-byte string literal not displayed */
RefreshTokenExpireDuration time.Duration `` /* 154-byte string literal not displayed */
RBACEnabled bool `json:"rbac_enabled" mapstructure:"rbac_enabled" ini:"rbac_enabled" yaml:"rbac_enabled"`
}
type ByteSize ¶
type ByteSize uint64
ByteSize is a size in bytes read from a configuration value: a number with its unit, "64KB" being 64 times 1000 bytes and "8MiB" 8 times 1024 squared, or a bare number of bytes. Empty is zero, which each key carrying a size reads as its own default.
func (*ByteSize) UnmarshalText ¶
UnmarshalText reads text as a size, parsed with github.com/dustin/go-humanize; text that is not one, a negative size among it, is a configuration error naming the key.
type Cache ¶
type Cache struct {
// MaxEntries bounds how many entries each cached type keeps; 0 or unset
// is 100,000. A negative value, or one over 10,000,000, fails startup.
// Default: 0
MaxEntries int `json:"max_entries" mapstructure:"max_entries" ini:"max_entries" yaml:"max_entries"`
Topic string `json:"topic" mapstructure:"topic" ini:"topic" yaml:"topic"`
}
type Cassandra ¶
type Cassandra struct {
Hosts []string `json:"hosts" mapstructure:"hosts" ini:"hosts" yaml:"hosts"`
Port int `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
Keyspace string `json:"keyspace" mapstructure:"keyspace" ini:"keyspace" yaml:"keyspace"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
// Consistency is the consistency level of the session's queries (see
// Consistency); empty keeps the driver's own default.
// Default: quorum
Consistency Consistency `json:"consistency" mapstructure:"consistency" ini:"consistency" yaml:"consistency"`
Timeout time.Duration `json:"timeout" mapstructure:"timeout" ini:"timeout" yaml:"timeout"`
ConnectTimeout time.Duration `json:"connect_timeout" mapstructure:"connect_timeout" ini:"connect_timeout" yaml:"connect_timeout"`
NumConns int `json:"num_conns" mapstructure:"num_conns" ini:"num_conns" yaml:"num_conns"`
PageSize int `json:"page_size" mapstructure:"page_size" ini:"page_size" yaml:"page_size"`
// RetryPolicy is how a failed query is retried (see RetryPolicy), empty
// being simple: simple and exponential_backoff retry it MaxRetryCount
// times, downgrading_consistency once, at one, or at local_one when
// Consistency is local_quorum, and not at all when Consistency is one,
// local_one or any.
// Default: simple
RetryPolicy RetryPolicy `json:"retry_policy" mapstructure:"retry_policy" ini:"retry_policy" yaml:"retry_policy"`
ReconnectInterval time.Duration `json:"reconnect_interval" mapstructure:"reconnect_interval" ini:"reconnect_interval" yaml:"reconnect_interval"`
// MaxRetryCount is how many times the simple and exponential_backoff
// policies retry a failed query and, with ReconnectInterval above 0, how
// many times a lost connection is retried, its first try aside; 0 is no
// retry, a connection still being tried once.
// Default: 3
MaxRetryCount int `json:"max_retry_count" mapstructure:"max_retry_count" ini:"max_retry_count" yaml:"max_retry_count"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type CircuitBreaker ¶
type CircuitBreaker struct {
Name string `json:"name" mapstructure:"name" ini:"name" yaml:"name"`
MaxRequests uint32 `json:"max_requests" mapstructure:"max_requests" ini:"max_requests" yaml:"max_requests"`
Interval time.Duration `json:"interval" mapstructure:"interval" ini:"interval" yaml:"interval"`
Timeout time.Duration `json:"timeout" mapstructure:"timeout" ini:"timeout" yaml:"timeout"`
FailureRate float64 `json:"failure_rate" mapstructure:"failure_rate" ini:"failure_rate" yaml:"failure_rate"`
MinRequests uint32 `json:"min_requests" mapstructure:"min_requests" ini:"min_requests" yaml:"min_requests"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Clickhouse ¶
type Clickhouse struct {
Host string `json:"host" mapstructure:"host" ini:"host" yaml:"host"`
Port uint `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
Database string `json:"database" mapstructure:"database" ini:"database" yaml:"database"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
DialTimeout string `json:"dial_timeout" mapstructure:"dial_timeout" ini:"dial_timeout" yaml:"dial_timeout"`
ReadTimeout string `json:"read_timeout" mapstructure:"read_timeout" ini:"read_timeout" yaml:"read_timeout"`
Compress bool `json:"compress" mapstructure:"compress" ini:"compress" yaml:"compress"`
Debug bool `json:"debug" mapstructure:"debug" ini:"debug" yaml:"debug"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
Clickhouse carries the connection options of the analytical instance. There is no write timeout: clickhouse-go v2 does not define one (writes are bounded by the request context), and it forwards unknown DSN options to the server as settings, which rejects the connection over them.
type Config ¶
type Config struct {
AppInfo `json:"app" mapstructure:"app" ini:"app" yaml:"app"`
Server `json:"server" mapstructure:"server" ini:"server" yaml:"server"`
GRPC `json:"grpc" mapstructure:"grpc" ini:"grpc" yaml:"grpc"`
Cache `json:"cache" mapstructure:"cache" ini:"cache" yaml:"cache"`
Middleware `json:"middleware" mapstructure:"middleware" ini:"middleware" yaml:"middleware"`
Auth `json:"auth" mapstructure:"auth" ini:"auth" yaml:"auth"`
Database `json:"database" mapstructure:"database" ini:"database" yaml:"database"`
Sqlite `json:"sqlite" mapstructure:"sqlite" ini:"sqlite" yaml:"sqlite"`
Postgres `json:"postgres" mapstructure:"postgres" ini:"postgres" yaml:"postgres"`
MySQL `json:"mysql" mapstructure:"mysql" ini:"mysql" yaml:"mysql"`
Clickhouse `json:"clickhouse" mapstructure:"clickhouse" ini:"clickhouse" yaml:"clickhouse"`
Redis `json:"redis" mapstructure:"redis" ini:"redis" yaml:"redis"`
OTEL `json:"otel" mapstructure:"otel" ini:"otel" yaml:"otel"`
Elasticsearch `json:"elasticsearch" mapstructure:"elasticsearch" ini:"elasticsearch" yaml:"elasticsearch"`
Mongo `json:"mongo" mapstructure:"mongo" ini:"mongo" yaml:"mongo"`
Kafka `json:"kafka" mapstructure:"kafka" ini:"kafka" yaml:"kafka"`
Minio `json:"minio" mapstructure:"minio" ini:"minio" yaml:"minio"`
Logger `json:"logger" mapstructure:"logger" ini:"logger" yaml:"logger"`
Ldap `json:"ldap" mapstructure:"ldap" ini:"ldap" yaml:"ldap"`
Influxdb `json:"influxdb" mapstructure:"influxdb" ini:"influxdb" yaml:"influxdb"`
Mqtt `json:"mqtt" mapstructure:"mqtt" ini:"mqtt" yaml:"mqtt"`
Nats `json:"nats" mapstructure:"nats" ini:"nats" yaml:"nats"`
Etcd `json:"etcd" mapstructure:"etcd" ini:"etcd" yaml:"etcd"`
Cassandra `json:"cassandra" mapstructure:"cassandra" ini:"cassandra" yaml:"cassandra"`
Scylla `json:"scylla" mapstructure:"scylla" ini:"scylla" yaml:"scylla"`
RethinkDB `json:"rethinkdb" mapstructure:"rethinkdb" ini:"rethinkdb" yaml:"rethinkdb"`
RocketMQ `json:"rocketmq" mapstructure:"rocketmq" ini:"rocketmq" yaml:"rocketmq"`
Debug `json:"debug" mapstructure:"debug" ini:"debug" yaml:"debug"`
Audit `json:"audit" mapstructure:"audit" ini:"audit" yaml:"audit"`
Logmgmt `json:"logmgmt" mapstructure:"logmgmt" ini:"logmgmt" yaml:"logmgmt"`
}
Config is the framework's own configuration: one embedded struct per section, named by its mapstructure tag.
func Load ¶
Load reads one configuration file into a fresh Config carrying the same framework defaults the runtime applies, without touching the global App and without binding environment variables. Consumers that inspect configuration files outside a running application (tooling, tests) use it to learn what a file means on its own: the result depends on framework defaults and file content alone, so two machines loading the same file always reach the same conclusion regardless of their environments. A key under a framework section that the section does not have fails it, as it fails Init.
type Consistency ¶
type Consistency string
Consistency names the consistency level of a cassandra or scylla session's queries.
const ( ConsistencyAny Consistency = "any" ConsistencyOne Consistency = "one" ConsistencyTwo Consistency = "two" ConsistencyThree Consistency = "three" ConsistencyQuorum Consistency = "quorum" ConsistencyAll Consistency = "all" ConsistencyLocalQuorum Consistency = "local_quorum" ConsistencyEachQuorum Consistency = "each_quorum" ConsistencyLocalOne Consistency = "local_one" )
func (*Consistency) UnmarshalText ¶
func (c *Consistency) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the levels, in any letter case; any other text is a configuration error naming the key.
type ConsumeFromWhere ¶
type ConsumeFromWhere string
ConsumeFromWhere names where a new consumer group starts reading a queue.
const ( ConsumeFromWhereLastOffset ConsumeFromWhere = "last_offset" // consume from the last committed offset ConsumeFromWhereFirstOffset ConsumeFromWhere = "first_offset" // consume from the beginning of the queue ConsumeFromWhereTimestamp ConsumeFromWhere = "timestamp" // consume from the given timestamp )
func (*ConsumeFromWhere) UnmarshalText ¶
func (w *ConsumeFromWhere) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the starting points, in any letter case; any other text is a configuration error naming the key.
type DBType ¶
type DBType string
DBType names the dialect of the primary database.
func (*DBType) UnmarshalText ¶
UnmarshalText reads text as one of the dialects, in any letter case; any other text is a configuration error naming the key.
type Database ¶
type Database struct {
Type DBType `json:"type" mapstructure:"type" ini:"type" yaml:"type"`
AutoMigrate bool `json:"auto_migrate" mapstructure:"auto_migrate" ini:"auto_migrate" yaml:"auto_migrate"`
SlowQueryThreshold time.Duration `json:"slow_query_threshold" mapstructure:"slow_query_threshold" ini:"slow_query_threshold" yaml:"slow_query_threshold"`
MaxIdleConns int `json:"max_idle_conns" mapstructure:"max_idle_conns" ini:"max_idle_conns" yaml:"max_idle_conns"`
MaxOpenConns int `json:"max_open_conns" mapstructure:"max_open_conns" ini:"max_open_conns" yaml:"max_open_conns"`
ConnMaxLifetime time.Duration `json:"conn_max_lifetime" mapstructure:"conn_max_lifetime" ini:"conn_max_lifetime" yaml:"conn_max_lifetime"`
ConnMaxIdleTime time.Duration `json:"conn_max_idle_time" mapstructure:"conn_max_idle_time" ini:"conn_max_idle_time" yaml:"conn_max_idle_time"`
}
type Debug ¶
type Debug struct {
StatsvizEnabled bool `json:"statsviz_enabled" mapstructure:"statsviz_enabled" ini:"statsviz_enabled" yaml:"statsviz_enabled"`
StatsvizListen string `json:"statsviz_listen" mapstructure:"statsviz_listen" ini:"statsviz_listen" yaml:"statsviz_listen"`
StatsvizPort int `json:"statsviz_port" mapstructure:"statsviz_port" ini:"statsviz_port" yaml:"statsviz_port"`
PprofEnabled bool `json:"pprof_enabled" mapstructure:"pprof_enabled" ini:"pprof_enabled" yaml:"pprof_enabled"`
PprofListen string `json:"pprof_listen" mapstructure:"pprof_listen" ini:"pprof_listen" yaml:"pprof_listen"`
PprofPort int `json:"pprof_port" mapstructure:"pprof_port" ini:"pprof_port" yaml:"pprof_port"`
GopsEnabled bool `json:"gops_enabled" mapstructure:"gops_enabled" ini:"gops_enabled" yaml:"gops_enabled"`
GopsListen string `json:"gops_listen" mapstructure:"gops_listen" ini:"gops_listen" yaml:"gops_listen"`
GopsPort int `json:"gops_port" mapstructure:"gops_port" ini:"gops_port" yaml:"gops_port"`
}
type DerefAliases ¶
type DerefAliases int
DerefAliases controls alias dereferencing
const ( // NeverDerefAliases never dereferences aliases NeverDerefAliases DerefAliases = 0 // DerefInSearching dereferences aliases in searching DerefInSearching DerefAliases = 1 // DerefFindingBaseObj dereferences aliases in finding the base object DerefFindingBaseObj DerefAliases = 2 // DerefAlways dereferences aliases always DerefAlways DerefAliases = 3 )
type Elasticsearch ¶
type Elasticsearch struct {
Addrs []string `json:"addrs" mapstructure:"addrs" ini:"addrs" yaml:"addrs"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
CloudID string `json:"cloud_id" mapstructure:"cloud_id" ini:"cloud_id" yaml:"cloud_id"`
APIKey string `json:"api_key" mapstructure:"api_key" ini:"api_key" yaml:"api_key"`
MaxRetries int `json:"max_retries" mapstructure:"max_retries" ini:"max_retries" yaml:"max_retries"`
RetryOnStatus []int `json:"retry_on_status" mapstructure:"retry_on_status" ini:"retry_on_status" yaml:"retry_on_status"`
DisableRetries bool `json:"disable_retries" mapstructure:"disable_retries" ini:"disable_retries" yaml:"disable_retries"`
RetryBackoff bool `json:"retry_backoff" mapstructure:"retry_backoff" ini:"retry_backoff" yaml:"retry_backoff"`
RetryBackoffMin time.Duration `json:"retry_backoff_min" mapstructure:"retry_backoff_min" ini:"retry_backoff_min" yaml:"retry_backoff_min"`
RetryBackoffMax time.Duration `json:"retry_backoff_max" mapstructure:"retry_backoff_max" ini:"retry_backoff_max" yaml:"retry_backoff_max"`
Compress bool `json:"compress" mapstructure:"compress" ini:"compress" yaml:"compress"`
DiscoveryInterval time.Duration `json:"discovery_interval" mapstructure:"discovery_interval" ini:"discovery_interval" yaml:"discovery_interval"`
MetricsEnabled bool `json:"metrics_enabled" mapstructure:"metrics_enabled" ini:"metrics_enabled" yaml:"metrics_enabled"`
DebugLoggerEnabled bool `json:"debug_logger_enabled" mapstructure:"debug_logger_enabled" ini:"debug_logger_enabled" yaml:"debug_logger_enabled"`
ConnectionPoolSize int `json:"connection_pool_size" mapstructure:"connection_pool_size" ini:"connection_pool_size" yaml:"connection_pool_size"`
ResponseHeaderTimeout time.Duration `` /* 130-byte string literal not displayed */
RequestTimeout time.Duration `json:"request_timeout" mapstructure:"request_timeout" ini:"request_timeout" yaml:"request_timeout"`
DialTimeout time.Duration `json:"dial_timeout" mapstructure:"dial_timeout" ini:"dial_timeout" yaml:"dial_timeout"`
KeepAliveInterval time.Duration `json:"keep_alive_interval" mapstructure:"keep_alive_interval" ini:"keep_alive_interval" yaml:"keep_alive_interval"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Etcd ¶
type Etcd struct {
Endpoints []string `json:"endpoints" mapstructure:"endpoints" ini:"endpoints" yaml:"endpoints"`
DialTimeout time.Duration `json:"dial_timeout" mapstructure:"dial_timeout" ini:"dial_timeout" yaml:"dial_timeout"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
AutoSync bool `json:"auto_sync" mapstructure:"auto_sync" ini:"auto_sync" yaml:"auto_sync"`
AutoSyncInterval time.Duration `json:"auto_sync_interval" mapstructure:"auto_sync_interval" ini:"auto_sync_interval" yaml:"auto_sync_interval"`
KeepAliveTime time.Duration `json:"keepalive_time" mapstructure:"keepalive_time" ini:"keepalive_time" yaml:"keepalive_time"`
KeepAliveTimeout time.Duration `json:"keepalive_timeout" mapstructure:"keepalive_timeout" ini:"keepalive_timeout" yaml:"keepalive_timeout"`
MaxCallSendMsgSize int `` /* 126-byte string literal not displayed */
MaxCallRecvMsgSize int `` /* 126-byte string literal not displayed */
PermitWithoutStream bool `json:"permit_without_stream" mapstructure:"permit_without_stream" ini:"permit_without_stream" yaml:"permit_without_stream"`
RejectOldCluster bool `json:"reject_old_cluster" mapstructure:"reject_old_cluster" ini:"reject_old_cluster" yaml:"reject_old_cluster"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
Etcd is the etcd client configuration.
type GRPC ¶
type GRPC struct {
// Listen is the address the listener binds, every interface when empty,
// and Port its port, 8081 by default, next to the HTTP listener's 8080.
Listen string `json:"listen" mapstructure:"listen" ini:"listen" yaml:"listen"`
Port int `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
// TLSEnabled serves TLS with the certificate in CertFile and the key in
// KeyFile. Off by default: the listener is plaintext the way the HTTP
// listener is, for an ingress that terminates TLS in front of it.
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
// Reflection registers the server reflection service, through which
// grpcurl and its kind list the services and their messages. On by
// default: the definitions are the project's own, committed under pb/.
Reflection bool `json:"reflection" mapstructure:"reflection" ini:"reflection" yaml:"reflection"`
// KeepaliveTime is how long a connection may stay idle before the server
// pings it, and KeepaliveTimeout how long it then waits for the answer
// before closing the connection. Zero leaves grpc-go's own defaults, two
// hours and twenty seconds.
KeepaliveTime time.Duration `json:"keepalive_time" mapstructure:"keepalive_time" ini:"keepalive_time" yaml:"keepalive_time"`
KeepaliveTimeout time.Duration `json:"keepalive_timeout" mapstructure:"keepalive_timeout" ini:"keepalive_timeout" yaml:"keepalive_timeout"`
// KeepaliveMinTime is the least time a client must leave between its own
// pings, and KeepalivePermitWithoutStream whether it may ping at all
// with no call on the connection; a client breaking the policy is sent
// away with too_many_pings and its connection closed, so a client's
// keepalive is set to match. Zero and false leave grpc-go's own policy,
// five minutes and no pings between calls.
KeepaliveMinTime time.Duration `json:"keepalive_min_time" mapstructure:"keepalive_min_time" ini:"keepalive_min_time" yaml:"keepalive_min_time"`
KeepalivePermitWithoutStream bool `` /* 162-byte string literal not displayed */
// MaxConnectionAge is how long a connection may live before the server
// tells its client to reconnect, spread by a tenth either way so that
// the connections do not all end at once: through a balancer that
// spreads connections rather than calls, a Kubernetes Service for one,
// a client reconnecting is how the replicas started since get their
// share. MaxConnectionAgeGrace is how long the calls on the connection
// then get to finish before it is closed. Zero leaves grpc-go's own
// default, a connection living as long as its client keeps it.
MaxConnectionAge time.Duration `json:"max_connection_age" mapstructure:"max_connection_age" ini:"max_connection_age" yaml:"max_connection_age"`
MaxConnectionAgeGrace time.Duration `` /* 134-byte string literal not displayed */
// MaxRecvMsgSize is the largest message a call may carry to the server,
// a size with its unit (see ByteSize): "8MiB" is 8 times 1024 squared
// bytes, "8MB" 8 times 1000 squared; a larger message is answered
// ResourceExhausted. Empty or 0 leaves grpc-go's own limit, 4MiB; more
// than 2GiB, the most a message may carry, fails startup.
MaxRecvMsgSize ByteSize `json:"max_recv_msg_size" mapstructure:"max_recv_msg_size" ini:"max_recv_msg_size" yaml:"max_recv_msg_size"`
}
GRPC configures the gRPC listener serving the models that declare GRPC(), beside the HTTP listener. It opens only when a service is registered on it, so a project without such models exposes no port and has nothing to switch off.
type HTTPBodyLogMode ¶
type HTTPBodyLogMode string
HTTPBodyLogMode selects which finished requests get a captured HTTP body written to the log.
const ( // HTTPBodyLogModeAll writes the captured body for every request. HTTPBodyLogModeAll HTTPBodyLogMode = "all" // HTTPBodyLogModeError writes the captured body only for failed requests: // HTTP status >= 400. HTTPBodyLogModeError HTTPBodyLogMode = "error" // HTTPBodyLogModeNone disables body logging for that side entirely. HTTPBodyLogModeNone HTTPBodyLogMode = "none" )
func (*HTTPBodyLogMode) UnmarshalText ¶
func (m *HTTPBodyLogMode) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the modes, in any letter case; any other text is a configuration error naming the key.
type HTTPBodyLogger ¶
type HTTPBodyLogger struct {
// Enabled enables the HTTP request and response body logging middleware.
// Default: true
Enabled bool `json:"enabled" ini:"enabled" yaml:"enabled" mapstructure:"enabled"`
// LogRequest selects which requests get their JSON body logged
// (all|error|none), in any letter case. Empty is the default; any other
// value is a configuration error at startup.
// Default: all
LogRequest HTTPBodyLogMode `json:"log_request" ini:"log_request" yaml:"log_request" mapstructure:"log_request"`
// LogResponse selects which responses get their JSON body logged
// (all|error|none), in any letter case. Empty is the default; any other
// value is a configuration error at startup.
// Default: error
LogResponse HTTPBodyLogMode `json:"log_response" ini:"log_response" yaml:"log_response" mapstructure:"log_response"`
// MaxBodySize limits how much request or response body data can be logged,
// a size with its unit (see ByteSize); empty or 0 is the default.
// Default: 64KB
MaxBodySize ByteSize `json:"max_body_size" ini:"max_body_size" yaml:"max_body_size" mapstructure:"max_body_size"`
// SkipRoutes lists routes whose bodies are never logged, for example login
// or other credential-carrying endpoints. Bodies are logged verbatim and
// are never redacted, so every route accepting a password, token, or other
// secret belongs here. A pattern ending in "*" matches the route by prefix;
// any other pattern must match the registered route pattern exactly, so a
// route with path parameters is written with them ("/users/:id/password").
SkipRoutes []string `json:"skip_routes" ini:"skip_routes" yaml:"skip_routes" mapstructure:"skip_routes"`
}
HTTPBodyLogger represents HTTP body logging configuration.
type Influxdb ¶
type Influxdb struct {
Host string `json:"host" mapstructure:"host" ini:"host" yaml:"host"`
Port uint `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
Token string `json:"token" mapstructure:"token" ini:"token" yaml:"token"`
Org string `json:"org" mapstructure:"org" ini:"org" yaml:"org"`
Bucket string `json:"bucket" mapstructure:"bucket" ini:"bucket" yaml:"bucket"`
// Write options
BatchSize uint `json:"batch_size" mapstructure:"batch_size" ini:"batch_size" yaml:"batch_size"`
FlushInterval time.Duration `json:"flush_interval" mapstructure:"flush_interval" ini:"flush_interval" yaml:"flush_interval"`
RetryInterval time.Duration `json:"retry_interval" mapstructure:"retry_interval" ini:"retry_interval" yaml:"retry_interval"`
MaxRetries uint `json:"max_retries" mapstructure:"max_retries" ini:"max_retries" yaml:"max_retries"`
RetryBufferLimit uint `json:"retry_buffer_limit" mapstructure:"retry_buffer_limit" ini:"retry_buffer_limit" yaml:"retry_buffer_limit"`
MaxRetryInterval time.Duration `json:"max_retry_interval" mapstructure:"max_retry_interval" ini:"max_retry_interval" yaml:"max_retry_interval"`
MaxRetryTime time.Duration `json:"max_retry_time" mapstructure:"max_retry_time" ini:"max_retry_time" yaml:"max_retry_time"`
ExponentialBase uint `json:"exponential_base" mapstructure:"exponential_base" ini:"exponential_base" yaml:"exponential_base"`
Precision time.Duration `json:"precision" mapstructure:"precision" ini:"precision" yaml:"precision"`
UseGZip bool `json:"use_gzip" mapstructure:"use_gzip" ini:"use_gzip" yaml:"use_gzip"`
// TLS configuration
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
// Advanced options
DefaultTags map[string]string `json:"default_tags" mapstructure:"default_tags" ini:"default_tags" yaml:"default_tags"`
AppName string `json:"app_name" mapstructure:"app_name" ini:"app_name" yaml:"app_name"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Kafka ¶
type Kafka struct {
Brokers []string `json:"brokers" mapstructure:"brokers" ini:"brokers" yaml:"brokers"`
ClientID string `json:"client_id" mapstructure:"client_id" ini:"client_id" yaml:"client_id"`
SASLEnabled bool `json:"sasl_enabled" mapstructure:"sasl_enabled" ini:"sasl_enabled" yaml:"sasl_enabled"`
SASLMechanism KafkaSASLMechanism `json:"sasl_mechanism" mapstructure:"sasl_mechanism" ini:"sasl_mechanism" yaml:"sasl_mechanism"`
SASLUsername string `json:"sasl_username" mapstructure:"sasl_username" ini:"sasl_username" yaml:"sasl_username"`
SASLPassword string `json:"sasl_password" mapstructure:"sasl_password" ini:"sasl_password" yaml:"sasl_password"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
Kafka configures the framework-managed Kafka client backed by franz-go.
Only environment-level settings are exposed: where to connect and how to authenticate. Behavioral tuning (acks, compression, batching, balancing, offsets, protocol version) deliberately stays with franz-go defaults, which already implement current best practices (idempotent producer, all-ISR acks, cooperative-sticky balancing, automatic version negotiation). Callers that need specific behavior pass extra kgo.Opt values to provider/kafka.New.
type KafkaSASLMechanism ¶
type KafkaSASLMechanism string
KafkaSASLMechanism names the SASL mechanism the Kafka client authenticates with.
const ( KafkaSASLMechanismPlain KafkaSASLMechanism = "plain" KafkaSASLMechanismScramSHA256 KafkaSASLMechanism = "scram-sha-256" KafkaSASLMechanismScramSHA512 KafkaSASLMechanism = "scram-sha-512" )
func (*KafkaSASLMechanism) UnmarshalText ¶
func (m *KafkaSASLMechanism) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the mechanisms, in any letter case; any other text is a configuration error naming the key.
type Ldap ¶
type Ldap struct {
Host string `json:"host" mapstructure:"host" ini:"host" yaml:"host"`
Port int `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
BaseDN string `json:"base_dn" mapstructure:"base_dn" ini:"base_dn" yaml:"base_dn"`
BindDN string `json:"bind_dn" mapstructure:"bind_dn" ini:"bind_dn" yaml:"bind_dn"`
BindPassword string `json:"bind_password" mapstructure:"bind_password" ini:"bind_password" yaml:"bind_password"`
Attributes []string `json:"attributes" mapstructure:"attributes" ini:"attributes" yaml:"attributes"`
Filter string `json:"filter" mapstructure:"filter" ini:"filter" yaml:"filter"`
GroupFilter string `json:"group_filter" mapstructure:"group_filter" ini:"group_filter" yaml:"group_filter"`
UserFilter string `json:"user_filter" mapstructure:"user_filter" ini:"user_filter" yaml:"user_filter"`
GroupDN string `json:"group_dn" mapstructure:"group_dn" ini:"group_dn" yaml:"group_dn"`
UserDN string `json:"user_dn" mapstructure:"user_dn" ini:"user_dn" yaml:"user_dn"`
GroupAttribute string `json:"group_attribute" mapstructure:"group_attribute" ini:"group_attribute" yaml:"group_attribute"`
UserAttribute string `json:"user_attribute" mapstructure:"user_attribute" ini:"user_attribute" yaml:"user_attribute"`
// Scope is how deep a search looks from its base: 0 the base object
// alone, 1 its children, 2 the whole subtree. Any other value fails
// startup.
// Default: 2
Scope Scope `json:"scope" mapstructure:"scope" ini:"scope" yaml:"scope"`
RequestTimeout time.Duration `json:"request_timeout" mapstructure:"request_timeout" ini:"request_timeout" yaml:"request_timeout"`
ConnTimeout time.Duration `json:"conn_timeout" mapstructure:"conn_timeout" ini:"conn_timeout" yaml:"conn_timeout"`
Referrals bool `json:"referrals" mapstructure:"referrals" ini:"referrals" yaml:"referrals"`
// Deref is when a search dereferences aliases: 0 never, 1 while
// searching, 2 when finding the base object, 3 always. Any other value
// fails startup.
// Default: 0
Deref DerefAliases `json:"deref" mapstructure:"deref" ini:"deref" yaml:"deref"`
PageSize int `json:"page_size" mapstructure:"page_size" ini:"page_size" yaml:"page_size"`
Heartbeat time.Duration `json:"heartbeat" mapstructure:"heartbeat" ini:"heartbeat" yaml:"heartbeat"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type LogFormat ¶
type LogFormat string
LogFormat names how a log entry is laid out: json, one object per line, or text, the console layout.
func (*LogFormat) UnmarshalText ¶
UnmarshalText reads text as one of the formats, in any letter case; any other text is a configuration error naming the key.
type LogLevel ¶
type LogLevel string
LogLevel names the least severe level the log streams write, one of the levels zap knows.
func (*LogLevel) UnmarshalText ¶
UnmarshalText reads text as a level zap parses, in any letter case, and keeps it as zap spells it, so warning reads as warn; any other text is a configuration error naming the key.
type Logger ¶
type Logger struct {
// Output selects where every log stream writes (stdout|file), in any
// letter case. Any other value is a configuration error at startup.
//
// With stdout, every stream — the global one, access, SQL, HTTP body, the
// component streams such as cronjob and leader, and the rest — writes to
// the process's stdout, one line per entry, and the entry's logger field
// names the stream: its file name in file mode without ".log" ("access",
// "gorm", "cronjob"), and for the global stream File without ".log", or
// "global" when File names no file. No file is created or rotated, so
// Dir, Console, MaxAge, MaxSize and MaxBackups do not apply.
//
// With file, every stream writes to a file of its own under Dir, rotated
// by MaxAge, MaxSize and MaxBackups, and its entries carry no logger field.
//
// Stdout and the files buffer entries and write them out within a second,
// and in full when the process stops. In file mode a stream naming no file,
// or naming /dev/stdout or /dev/stderr, writes straight through.
// Default: stdout
Output LoggerOutput `json:"output" ini:"output" yaml:"output" mapstructure:"output"`
// Dir specifies which directory log to.
Dir string `json:"dir" ini:"dir" yaml:"dir" mapstructure:"dir"`
// File specifies the which file the global logger logs to in file mode.
// If value is "/dev/stdout", log to os.Stdout.
// If value is "/dev/stderr", log to os.Stderr.
// If value is empty(length is zero), log to os.Stdout.
// In stdout mode it only names the global stream (see Output).
File string `json:"file" ini:"file" yaml:"file" mapstructure:"file"`
// Console additionally mirrors the global logger's output to os.Stdout
// when File is set to a real file path in file mode. It has no effect when
// File is empty or one of "/dev/stdout"/"/dev/stderr", since those already
// log to console, nor in stdout mode, where every stream already does.
// Only the global logger built by Init() reads this field; the other
// streams stay file-only unless built with a logger.Option setting Console.
// Default: true
Console bool `json:"console" ini:"console" yaml:"console" mapstructure:"console"`
// Level is the least severe level the log streams write, one zap knows
// (debug|info|warn|error|dpanic|panic|fatal, warning for warn), in any
// letter case. Any other value is a configuration error at startup.
// Default: info
Level LogLevel `json:"level" ini:"level" yaml:"level" mapstructure:"level"`
// Format lays out each log entry (json|text), in any letter case. Any
// other value is a configuration error at startup.
// Default: json
Format LogFormat `json:"format" ini:"format" yaml:"format" mapstructure:"format"`
// ErrorStackDisabled disables attaching the error_stack field, the stack
// trace embedded in a logged error at its creation point, to the entries
// logging such an error. Stack traces are attached by default; set this to
// true in environments where the extra payload is unwanted, such as local
// development.
// Default: false
ErrorStackDisabled bool `json:"error_stack_disabled" ini:"error_stack_disabled" yaml:"error_stack_disabled" mapstructure:"error_stack_disabled"`
// MaxAge is the maximum number of days to retain old log files based on the
// timestamp encoded in their filename.
// uint is "day" and default to 30.
MaxAge int `json:"max_age" ini:"max_age" yaml:"max_age" mapstructure:"max_age"`
// MaxSize is the maximum size in megabytes of the log file before it gets
// rotated, default to 100MB.
MaxSize int `json:"max_size" ini:"max_size" yaml:"max_size" mapstructure:"max_size"`
// MaxBackups is the maximum number of old log files to retain.
// The value default to 1.
MaxBackups int `json:"max_backups" ini:"max_backups" yaml:"max_backups" mapstructure:"max_backups"`
// SQLCallerSkipPrefixes lists extra function-path prefixes to skip when
// resolving the business caller of a SQL statement log, on top of the
// built-in gorm and framework prefixes, which are always skipped and
// cannot be removed. Configure it when a project routes database calls
// through its own helper layer, such as a dao or repository package, so
// SQL logs name the code that called the helper instead of the helper
// body. Each entry is a function-path prefix matched at a package
// boundary: "example.com/app/dao" covers that package and its
// subpackages but not "example.com/app/daox". The environment form is
// comma-separated, eg.
// LOGGER_SQL_CALLER_SKIP_PREFIXES="example.com/app/dao,example.com/app/repo".
SQLCallerSkipPrefixes []string `` /* 134-byte string literal not displayed */
// HTTPBody contains HTTP request and response body logging configurations.
HTTPBody HTTPBodyLogger `json:"http_body" ini:"http_body" yaml:"http_body" mapstructure:"http_body"`
}
Logger represents section "logger" for client-side or server-side configuration, and there is only one copy during the application entire lifetime.
type LoggerOutput ¶
type LoggerOutput string
LoggerOutput selects where every log stream writes.
const ( // LoggerOutputStdout writes every log stream to stdout, each entry naming // its stream, which is what a container platform collects. LoggerOutputStdout LoggerOutput = "stdout" // LoggerOutputFile writes every log stream to a rotated file of its own, // for a deployment whose log collector reads files. LoggerOutputFile LoggerOutput = "file" )
func (*LoggerOutput) UnmarshalText ¶
func (o *LoggerOutput) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the outputs, in any letter case; any other text is a configuration error naming the key.
type Logmgmt ¶
type Logmgmt struct {
// Retention is how long operation and login logs are kept before the
// cleanup job removes them.
Retention time.Duration `json:"retention" mapstructure:"retention" ini:"retention" yaml:"retention"`
}
Logmgmt configures the log-management module.
The cleanup schedule has no key of its own: it is read from the LOGMGMT_CLEANUP_CRON environment variable only, since the module registers its cronjob at package initialization, before configuration files are loaded, so a file-provided schedule could not take effect there anyway.
type Middleware ¶
type Middleware struct {
JWTAuthEnabled bool `json:"jwt_auth_enabled" mapstructure:"jwt_auth_enabled" ini:"jwt_auth_enabled" yaml:"jwt_auth_enabled"`
AuthzEnabled bool `json:"authz_enabled" mapstructure:"authz_enabled" ini:"authz_enabled" yaml:"authz_enabled"`
IAMSessionEnabled bool `json:"iam_session_enabled" mapstructure:"iam_session_enabled" ini:"iam_session_enabled" yaml:"iam_session_enabled"`
}
type Minio ¶
type Minio struct {
Endpoint string `json:"endpoint" mapstructure:"endpoint" ini:"endpoint" yaml:"endpoint"`
AccessKey string `json:"access_key" mapstructure:"access_key" ini:"access_key" yaml:"access_key"`
SecretKey string `json:"secret_key" mapstructure:"secret_key" ini:"secret_key" yaml:"secret_key"`
// Bucket names the bucket the provider's operations use when their
// options name none. Several buckets may be listed, comma separated, as
// in "media, archive": each is created at startup when missing, and the
// first is the default.
Bucket string `json:"bucket" mapstructure:"bucket" ini:"bucket" yaml:"bucket"`
Location string `json:"location" mapstructure:"location" ini:"location" yaml:"location"`
Secure bool `json:"secure" mapstructure:"secure" ini:"secure" yaml:"secure"`
Region string `json:"region" mapstructure:"region" ini:"region" yaml:"region"`
Timeout time.Duration `json:"timeout" mapstructure:"timeout" ini:"timeout" yaml:"timeout"`
PartSize int64 `json:"part_size" mapstructure:"part_size" ini:"part_size" yaml:"part_size"`
Concurrency int `json:"concurrency" mapstructure:"concurrency" ini:"concurrency" yaml:"concurrency"`
Compress bool `json:"compress" mapstructure:"compress" ini:"compress" yaml:"compress"`
Trace bool `json:"trace" mapstructure:"trace" ini:"trace" yaml:"trace"`
SessionToken string `json:"session_token" mapstructure:"session_token" ini:"session_token" yaml:"session_token"`
UseIAM bool `json:"use_iam" mapstructure:"use_iam" ini:"use_iam" yaml:"use_iam"`
UseSTS bool `json:"use_sts" mapstructure:"use_sts" ini:"use_sts" yaml:"use_sts"`
IAMEndpoint string `json:"iam_endpoint" mapstructure:"iam_endpoint" ini:"iam_endpoint" yaml:"iam_endpoint"`
STSEndpoint string `json:"sts_endpoint" mapstructure:"sts_endpoint" ini:"sts_endpoint" yaml:"sts_endpoint"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Mode ¶
type Mode string
Mode is the deployment environment label of the process, shown by the version endpoint, the startup log and the otel resource. Any text is accepted; the constants below are the conventional values.
type Mongo ¶
type Mongo struct {
Host string `json:"host" mapstructure:"host" ini:"host" yaml:"host"`
Port int `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
Database string `json:"database" mapstructure:"database" ini:"database" yaml:"database"`
AuthSource string `json:"auth_source" mapstructure:"auth_source" ini:"auth_source" yaml:"auth_source"`
MaxPoolSize uint64 `json:"max_pool_size" mapstructure:"max_pool_size" ini:"max_pool_size" yaml:"max_pool_size"`
MinPoolSize uint64 `json:"min_pool_size" mapstructure:"min_pool_size" ini:"min_pool_size" yaml:"min_pool_size"`
ConnectTimeout time.Duration `json:"connect_timeout" mapstructure:"connect_timeout" ini:"connect_timeout" yaml:"connect_timeout"`
ServerSelectionTimeout time.Duration `` /* 134-byte string literal not displayed */
MaxConnIdleTime time.Duration `json:"max_conn_idle_time" mapstructure:"max_conn_idle_time" ini:"max_conn_idle_time" yaml:"max_conn_idle_time"`
MaxConnecting uint64 `json:"max_connecting" mapstructure:"max_connecting" ini:"max_connecting" yaml:"max_connecting"`
ReadConcern ReadConcern `json:"read_concern" mapstructure:"read_concern" ini:"read_concern" yaml:"read_concern"`
WriteConcern WriteConcern `json:"write_concern" mapstructure:"write_concern" ini:"write_concern" yaml:"write_concern"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Mqtt ¶
type Mqtt struct {
Addr string `json:"addr" mapstructure:"addr" ini:"addr" yaml:"addr"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
ClientPrefix string `json:"client_prefix" mapstructure:"client_prefix" ini:"client_prefix" yaml:"client_prefix"`
ConnectTimeout time.Duration `json:"connect_timeout" mapstructure:"connect_timeout" ini:"connect_timeout" yaml:"connect_timeout"`
Keepalive time.Duration `json:"keepalive" mapstructure:"keepalive" ini:"keepalive" yaml:"keepalive"`
CleanSession bool `json:"clean_session" mapstructure:"clean_session" ini:"clean_session" yaml:"clean_session"`
AutoReconnect bool `json:"auto_reconnect" mapstructure:"auto_reconnect" ini:"auto_reconnect" yaml:"auto_reconnect"`
UseTLS bool `json:"use_tls" mapstructure:"use_tls" ini:"use_tls" yaml:"use_tls"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type MySQL ¶
type MySQL struct {
Host string `json:"host" mapstructure:"host" ini:"host" yaml:"host"`
Port uint `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
Database string `json:"database" mapstructure:"database" ini:"database" yaml:"database"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
// DialTimeout bounds establishing a TCP connection to the server. Without
// it a dial against a host that drops packets instead of refusing them
// blocks until the OS gives up, minutes later. A healthy handshake takes
// milliseconds, so the 10s default only ever cuts off connections that
// were never going to succeed. Zero disables the bound.
DialTimeout time.Duration `json:"dial_timeout" mapstructure:"dial_timeout" ini:"dial_timeout" yaml:"dial_timeout"`
// ReadTimeout and WriteTimeout bound single socket reads and writes on an
// established connection. They default to zero (disabled) on purpose: a
// connection-level I/O deadline also kills legitimately slow queries and
// large result sets, and a per-query bound belongs to the caller's
// context deadline instead.
ReadTimeout time.Duration `json:"read_timeout" mapstructure:"read_timeout" ini:"read_timeout" yaml:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout" mapstructure:"write_timeout" ini:"write_timeout" yaml:"write_timeout"`
// Replicas lists read-replica endpoints as host:port entries (comma
// separated in ini). Every other connection setting — credentials,
// database, timeouts, the utf8mb4 charset, the UTC wire location — is
// shared with the primary, so a replica differs by address only. Configuring replicas
// makes framework reads eligible for replica routing, but never moves
// them by default: reads go to a replica only where a model declares
// PreferReplica or a call site opts in with WithReplica. Replication
// itself, replica health, and failover belong to the infrastructure;
// prefer a single load-balanced read endpoint where one exists.
Replicas []string `json:"replicas" mapstructure:"replicas" ini:"replicas" yaml:"replicas"`
// Strict adds STRICT_TRANS_TABLES to the sql_mode of every connection,
// keeping the modes the server is configured with: a value too long for
// its column is then refused, which the framework answers 400 with,
// instead of stored cut short with a warning. On by default; off leaves
// the server's modes alone, and a too-long value is stored cut short
// wherever the server itself is not strict.
Strict bool `json:"strict" mapstructure:"strict" ini:"strict" yaml:"strict"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Nats ¶
type Nats struct {
Addrs []string `json:"addrs" mapstructure:"addrs" ini:"addrs" yaml:"addrs"`
ClientName string `json:"client_name" mapstructure:"client_name" ini:"client_name" yaml:"client_name"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
Token string `json:"token" mapstructure:"token" ini:"token" yaml:"token"`
CredentialsFile string `json:"credentials_file" mapstructure:"credentials_file" ini:"credentials_file" yaml:"credentials_file"`
NKeyFile string `json:"nkey_file" mapstructure:"nkey_file" ini:"nkey_file" yaml:"nkey_file"`
// MaxReconnects is handed to the NATS client verbatim: -1 reconnects
// forever, 0 disables reconnecting, a positive value bounds the attempts.
// The default is -1 because a bounded budget turns any outage longer than
// max_reconnects*reconnect_wait into a permanently closed connection that
// only a process restart can recover.
MaxReconnects int `json:"max_reconnects" mapstructure:"max_reconnects" ini:"max_reconnects" yaml:"max_reconnects"`
ReconnectWait time.Duration `json:"reconnect_wait" mapstructure:"reconnect_wait" ini:"reconnect_wait" yaml:"reconnect_wait"`
ReconnectJitter time.Duration `json:"reconnect_jitter" mapstructure:"reconnect_jitter" ini:"reconnect_jitter" yaml:"reconnect_jitter"`
ReconnectJitterTLS time.Duration `json:"reconnect_jitter_tls" mapstructure:"reconnect_jitter_tls" ini:"reconnect_jitter_tls" yaml:"reconnect_jitter_tls"`
ConnectTimeout time.Duration `json:"connect_timeout" mapstructure:"connect_timeout" ini:"connect_timeout" yaml:"connect_timeout"`
PingInterval time.Duration `json:"ping_interval" mapstructure:"ping_interval" ini:"ping_interval" yaml:"ping_interval"`
MaxPingsOutstanding int `json:"max_pings_outstanding" mapstructure:"max_pings_outstanding" ini:"max_pings_outstanding" yaml:"max_pings_outstanding"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type OTEL ¶
type OTEL struct {
// Enabled controls whether OpenTelemetry tracing is enabled.
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
// ServiceName is the OpenTelemetry service.name resource attribute.
ServiceName string `json:"service_name" mapstructure:"service_name" ini:"service_name" yaml:"service_name"`
// ExporterOTLPProtocol selects the OTLP transport protocol: grpc or http/protobuf.
ExporterOTLPProtocol OTLPProtocol `` /* 126-byte string literal not displayed */
// ExporterOTLPTracesEndpoint is the trace-specific OTLP endpoint URL.
ExporterOTLPTracesEndpoint string `` /* 154-byte string literal not displayed */
// ExporterOTLPHeaders are key-value headers sent with OTLP requests.
ExporterOTLPHeaders map[string]string `json:"exporter_otlp_headers" mapstructure:"exporter_otlp_headers" ini:"exporter_otlp_headers" yaml:"exporter_otlp_headers"`
// ExporterOTLPCompression controls OTLP payload compression: none or gzip.
ExporterOTLPCompression OTLPCompression `` /* 138-byte string literal not displayed */
// TracesSampler selects the OpenTelemetry trace sampler.
TracesSampler TracesSampler `json:"traces_sampler" mapstructure:"traces_sampler" ini:"traces_sampler" yaml:"traces_sampler"`
// TracesSamplerArg configures samplers that need an argument, such as traceidratio.
TracesSamplerArg string `json:"traces_sampler_arg" mapstructure:"traces_sampler_arg" ini:"traces_sampler_arg" yaml:"traces_sampler_arg"`
// BSPMaxQueueSize is the BatchSpanProcessor queue capacity.
BSPMaxQueueSize int `json:"bsp_max_queue_size" mapstructure:"bsp_max_queue_size" ini:"bsp_max_queue_size" yaml:"bsp_max_queue_size"`
// BSPMaxExportBatchSize is the maximum number of spans exported in one batch.
BSPMaxExportBatchSize int `` /* 138-byte string literal not displayed */
// BSPScheduleDelay is the maximum delay between two consecutive exports.
BSPScheduleDelay time.Duration `json:"bsp_schedule_delay" mapstructure:"bsp_schedule_delay" ini:"bsp_schedule_delay" yaml:"bsp_schedule_delay"`
// BSPExportTimeout is the maximum duration allowed for one export attempt.
BSPExportTimeout time.Duration `json:"bsp_export_timeout" mapstructure:"bsp_export_timeout" ini:"bsp_export_timeout" yaml:"bsp_export_timeout"`
}
OTEL represents OpenTelemetry tracing configuration using OTLP exporters. This configuration supports sending traces to Jaeger, Uptrace, or other OTLP-compatible backends.
type OTLPCompression ¶
type OTLPCompression string
OTLPCompression is the compression mode used by OTLP trace exporters.
const ( // OTLPCompressionNone sends OTLP trace payloads without compression. OTLPCompressionNone OTLPCompression = "none" // OTLPCompressionGzip compresses OTLP trace payloads with gzip. OTLPCompressionGzip OTLPCompression = "gzip" )
func (*OTLPCompression) UnmarshalText ¶
func (c *OTLPCompression) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the compression modes, in any letter case; any other text is a configuration error naming the key.
type OTLPProtocol ¶
type OTLPProtocol string
OTLPProtocol is the transport protocol used by OTLP trace exporters.
const ( // OTLPProtocolGRPC exports traces with OTLP over gRPC. OTLPProtocolGRPC OTLPProtocol = "grpc" // OTLPProtocolHTTPProtobuf exports traces with OTLP over HTTP using protobuf payloads. OTLPProtocolHTTPProtobuf OTLPProtocol = "http/protobuf" )
func (*OTLPProtocol) UnmarshalText ¶
func (p *OTLPProtocol) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the protocols, in any letter case; any other text is a configuration error naming the key.
type Postgres ¶
type Postgres struct {
Host string `json:"host" mapstructure:"host" ini:"host" yaml:"host"`
Port uint `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
Database string `json:"database" mapstructure:"database" ini:"database" yaml:"database"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
SSLMode string `json:"sslmode" mapstructure:"sslmode" ini:"sslmode" yaml:"sslmode"`
// Replicas lists read-replica endpoints as host:port entries (comma
// separated in ini), sharing every other connection setting with the
// primary. Same contract as the MySQL field: replicas make reads
// eligible for routing, moved only by PreferReplica models or WithReplica
// call sites; replication, health, and failover belong to the
// infrastructure.
Replicas []string `json:"replicas" mapstructure:"replicas" ini:"replicas" yaml:"replicas"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type ReadConcern ¶
type ReadConcern string
ReadConcern names the read concern level of the mongo client.
const ( ReadConcernLocal ReadConcern = "local" ReadConcernMajority ReadConcern = "majority" ReadConcernAvailable ReadConcern = "available" ReadConcernLinearizable ReadConcern = "linearizable" ReadConcernSnapshot ReadConcern = "snapshot" )
func (*ReadConcern) UnmarshalText ¶
func (c *ReadConcern) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the levels, in any letter case; any other text is a configuration error naming the key.
type ReconnectPolicy ¶
type ReconnectPolicy string
ReconnectPolicy names how the scylla session reconnects to a lost host.
const ( ReconnectPolicyConstant ReconnectPolicy = "constant" ReconnectPolicyExponential ReconnectPolicy = "exponential" )
func (*ReconnectPolicy) UnmarshalText ¶
func (p *ReconnectPolicy) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the policies, in any letter case; any other text is a configuration error naming the key.
type Redis ¶
type Redis struct {
Addr string `json:"addr" mapstructure:"addr" ini:"addr" yaml:"addr"`
Addrs []string `json:"addrs" mapstructure:"addrs" ini:"addrs" yaml:"addrs"`
DB int `json:"db" mapstructure:"db" ini:"db" yaml:"db"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
Namespace string `json:"namespace" mapstructure:"namespace" ini:"namespace" yaml:"namespace"`
PoolSize int `json:"pool_size" mapstructure:"pool_size" ini:"pool_size" yaml:"pool_size"`
Expiration time.Duration `json:"expiration" mapstructure:"expiration" ini:"expiration" yaml:"expiration"`
ClusterMode bool `json:"cluster_mode" mapstructure:"cluster_mode" ini:"cluster_mode" yaml:"cluster_mode"`
DialTimeout time.Duration `json:"dial_timeout" mapstructure:"dial_timeout" ini:"dial_timeout" yaml:"dial_timeout"`
ReadTimeout time.Duration `json:"read_timeout" mapstructure:"read_timeout" ini:"read_timeout" yaml:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout" mapstructure:"write_timeout" ini:"write_timeout" yaml:"write_timeout"`
MinIdleConns int `json:"min_idle_conns" mapstructure:"min_idle_conns" ini:"min_idle_conns" yaml:"min_idle_conns"`
MaxRetries int `json:"max_retries" mapstructure:"max_retries" ini:"max_retries" yaml:"max_retries"`
MinRetryBackoff time.Duration `json:"min_retry_backoff" mapstructure:"min_retry_backoff" ini:"min_retry_backoff" yaml:"min_retry_backoff"`
MaxRetryBackoff time.Duration `json:"max_retry_backoff" mapstructure:"max_retry_backoff" ini:"max_retry_backoff" yaml:"max_retry_backoff"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type RethinkDB ¶
type RethinkDB struct {
Hosts []string `json:"hosts" mapstructure:"hosts" ini:"hosts" yaml:"hosts"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
Database string `json:"database" mapstructure:"database" ini:"database" yaml:"database"`
DiscoveryHost bool `json:"discovery_host" mapstructure:"discovery_host" ini:"discovery_host" yaml:"discovery_host"`
MaxIdle int `json:"max_idle" mapstructure:"max_idle" ini:"max_idle" yaml:"max_idle"`
MaxOpen int `json:"max_open" mapstructure:"max_open" ini:"max_open" yaml:"max_open"`
NumRetries int `json:"num_retries" mapstructure:"num_retries" ini:"num_retries" yaml:"num_retries"`
ConnectTimeout time.Duration `json:"connect_timeout" mapstructure:"connect_timeout" ini:"connect_timeout" yaml:"connect_timeout"`
ReadTimeout time.Duration `json:"read_timeout" mapstructure:"read_timeout" ini:"read_timeout" yaml:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout" mapstructure:"write_timeout" ini:"write_timeout" yaml:"write_timeout"`
KeepAliveTime time.Duration `json:"keep_alive_time" mapstructure:"keep_alive_time" ini:"keep_alive_time" yaml:"keep_alive_time"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type RetryPolicy ¶
type RetryPolicy string
RetryPolicy names how a cassandra or scylla session retries a failed query.
const ( RetryPolicySimple RetryPolicy = "simple" RetryPolicyDowngradingConsistency RetryPolicy = "downgrading_consistency" RetryPolicyExponentialBackoff RetryPolicy = "exponential_backoff" )
func (*RetryPolicy) UnmarshalText ¶
func (p *RetryPolicy) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the policies, in any letter case; any other text is a configuration error naming the key.
type RocketMQ ¶
type RocketMQ struct {
NameServerAddrs []string `json:"name_server_addrs" mapstructure:"name_server_addrs" ini:"name_server_addrs" yaml:"name_server_addrs"`
AccessKey string `json:"access_key" mapstructure:"access_key" ini:"access_key" yaml:"access_key"`
SecretKey string `json:"secret_key" mapstructure:"secret_key" ini:"secret_key" yaml:"secret_key"`
Namespace string `json:"namespace" mapstructure:"namespace" ini:"namespace" yaml:"namespace"`
GroupName string `json:"group_name" mapstructure:"group_name" ini:"group_name" yaml:"group_name"`
// InstanceName names the process's clients to the broker. Empty leaves it
// to the client library, which names every process apart; a name set here
// has to differ between processes consuming in one group on one machine,
// or the broker counts them as one consumer.
InstanceName string `json:"instance_name" mapstructure:"instance_name" ini:"instance_name" yaml:"instance_name"`
NumRetries int `json:"num_retries" mapstructure:"num_retries" ini:"num_retries" yaml:"num_retries"`
SendMsgTimeout time.Duration `json:"send_msg_timeout" mapstructure:"send_msg_timeout" ini:"send_msg_timeout" yaml:"send_msg_timeout"`
VipChannelEnabled bool `json:"vip_channel_enabled" mapstructure:"vip_channel_enabled" ini:"vip_channel_enabled" yaml:"vip_channel_enabled"`
ConsumeOrderly bool `json:"consume_orderly" mapstructure:"consume_orderly" ini:"consume_orderly" yaml:"consume_orderly"`
MaxReconsumeTime int32 `json:"max_reconsume_times" mapstructure:"max_reconsume_times" ini:"max_reconsume_times" yaml:"max_reconsume_times"`
AutoCommit bool `json:"auto_commit" mapstructure:"auto_commit" ini:"auto_commit" yaml:"auto_commit"`
ConsumeConcurrentlyMaxSpan int `` /* 154-byte string literal not displayed */
ConsumeMessageBatchMaxSize int `` /* 158-byte string literal not displayed */
ConsumeFromWhere ConsumeFromWhere `json:"consume_from_where" mapstructure:"consume_from_where" ini:"consume_from_where" yaml:"consume_from_where"`
ConsumeTimestamp string `json:"consume_timestamp" mapstructure:"consume_timestamp" ini:"consume_timestamp" yaml:"consume_timestamp"`
TraceEnabled bool `json:"trace_enabled" mapstructure:"trace_enabled" ini:"trace_enabled" yaml:"trace_enabled"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Scylla ¶
type Scylla struct {
Hosts []string `json:"hosts" mapstructure:"hosts" ini:"hosts" yaml:"hosts"`
Username string `json:"username" mapstructure:"username" ini:"username" yaml:"username"`
Password string `json:"password" mapstructure:"password" ini:"password" yaml:"password"`
Keyspace string `json:"keyspace" mapstructure:"keyspace" ini:"keyspace" yaml:"keyspace"`
Consistency Consistency `json:"consistency" mapstructure:"consistency" ini:"consistency" yaml:"consistency"`
NumConns int `json:"num_conns" mapstructure:"num_conns" ini:"num_conns" yaml:"num_conns"`
ConnectTimeout time.Duration `json:"connect_timeout" mapstructure:"connect_timeout" ini:"connect_timeout" yaml:"connect_timeout"`
Timeout time.Duration `json:"timeout" mapstructure:"timeout" ini:"timeout" yaml:"timeout"`
PageSize int `json:"page_size" mapstructure:"page_size" ini:"page_size" yaml:"page_size"`
// RetryPolicy is how a failed query is retried (see RetryPolicy), empty
// keeping the driver's own default: simple and exponential_backoff retry
// it RetryNumRetries times, downgrading_consistency once, at one, or at
// local_one when Consistency is local_quorum, and not at all when
// Consistency is one, local_one or any.
RetryPolicy RetryPolicy `json:"retry_policy" mapstructure:"retry_policy" ini:"retry_policy" yaml:"retry_policy"`
RetryNumRetries int `json:"retry_num_retries" mapstructure:"retry_num_retries" ini:"retry_num_retries" yaml:"retry_num_retries"`
RetryMinInterval time.Duration `json:"retry_min_interval" mapstructure:"retry_min_interval" ini:"retry_min_interval" yaml:"retry_min_interval"`
RetryMaxInterval time.Duration `json:"retry_max_interval" mapstructure:"retry_max_interval" ini:"retry_max_interval" yaml:"retry_max_interval"`
ReconnectPolicy ReconnectPolicy `json:"reconnect_policy" mapstructure:"reconnect_policy" ini:"reconnect_policy" yaml:"reconnect_policy"`
// ReconnectMaxRetries is how many times ReconnectPolicy retries a lost
// connection, its first try aside; 0 is no retry, a connection still
// being tried once.
ReconnectMaxRetries int `json:"reconnect_max_retries" mapstructure:"reconnect_max_retries" ini:"reconnect_max_retries" yaml:"reconnect_max_retries"`
ReconnectInitialInterval time.Duration `` /* 142-byte string literal not displayed */
ReconnectMaxInterval time.Duration `` /* 126-byte string literal not displayed */
ReconnectConstantInterval time.Duration `` /* 146-byte string literal not displayed */
TracingEnabled bool `json:"tracing_enabled" mapstructure:"tracing_enabled" ini:"tracing_enabled" yaml:"tracing_enabled"`
TLSEnabled bool `json:"tls_enabled" mapstructure:"tls_enabled" ini:"tls_enabled" yaml:"tls_enabled"`
CertFile string `json:"cert_file" mapstructure:"cert_file" ini:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" mapstructure:"key_file" ini:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" mapstructure:"ca_file" ini:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify" ini:"insecure_skip_verify" yaml:"insecure_skip_verify"`
Enabled bool `json:"enabled" mapstructure:"enabled" ini:"enabled" yaml:"enabled"`
}
type Server ¶
type Server struct {
Mode Mode `json:"mode" mapstructure:"mode" ini:"mode" yaml:"mode"`
Listen string `json:"listen" mapstructure:"listen" ini:"listen" yaml:"listen"`
Port int `json:"port" mapstructure:"port" ini:"port" yaml:"port"`
Domain string `json:"domain" mapstructure:"domain" ini:"domain" yaml:"domain"`
// TrustedProxies lists the CIDR blocks, or lone addresses, of the
// proxies allowed to report a client address through X-Forwarded-For or
// X-Real-IP, to the HTTP and the gRPC listener alike.
//
// It is empty by default, and an empty list trusts no peer: the client
// address is then read off the connection, which the caller cannot
// rewrite. A deployment behind a load balancer or ingress names that
// network here — until it does, every client address it records, logs and
// rate-limits on is the one the request asked for.
TrustedProxies []string `json:"trusted_proxies" mapstructure:"trusted_proxies" ini:"trusted_proxies" yaml:"trusted_proxies"`
// ShutdownDelay is how long the process keeps serving after it is asked
// to stop, before the listener starts draining.
//
// It is zero by default, which begins the drain at once. A deployment
// whose load balancer routes by readiness sets it to that balancer's
// polling interval plus a margin: readiness starts failing the moment the
// process is told to stop — by a signal, or by a listener or a component
// that failed — and this window is what the balancer needs to notice and
// stop opening new connections here. Without it the process can refuse
// connections the balancer is still sending. A second signal ends the
// wait, and a process that must not wait on anything — work that will not
// stop once its lease is lost — skips it.
ShutdownDelay time.Duration `json:"shutdown_delay" mapstructure:"shutdown_delay" ini:"shutdown_delay" yaml:"shutdown_delay"`
ReadTimeout time.Duration `json:"read_timeout" mapstructure:"read_timeout" ini:"read_timeout" yaml:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout" mapstructure:"write_timeout" ini:"write_timeout" yaml:"write_timeout"`
IdleTimeout time.Duration `json:"idle_timeout" mapstructure:"idle_timeout" ini:"idle_timeout" yaml:"idle_timeout"`
// Circuit breaker
CircuitBreaker CircuitBreaker `json:"circuit_breaker" mapstructure:"circuit_breaker" ini:"circuit_breaker" yaml:"circuit_breaker"`
}
type TracesSampler ¶
type TracesSampler string
TracesSampler is the OpenTelemetry sampler name used for traces.
const ( // TracesSamplerAlwaysOn samples every trace. TracesSamplerAlwaysOn TracesSampler = "always_on" // TracesSamplerAlwaysOff drops every trace. TracesSamplerAlwaysOff TracesSampler = "always_off" // TracesSamplerTraceIDRatio samples root traces by trace ID ratio. TracesSamplerTraceIDRatio TracesSampler = "traceidratio" // TracesSamplerParentBasedAlwaysOn samples roots and honors upstream parent decisions. TracesSamplerParentBasedAlwaysOn TracesSampler = "parentbased_always_on" // TracesSamplerParentBasedAlwaysOff drops roots and honors upstream parent decisions. TracesSamplerParentBasedAlwaysOff TracesSampler = "parentbased_always_off" // TracesSamplerParentBasedTraceIDRatio samples roots by ratio and honors upstream parent decisions. TracesSamplerParentBasedTraceIDRatio TracesSampler = "parentbased_traceidratio" )
func (*TracesSampler) UnmarshalText ¶
func (s *TracesSampler) UnmarshalText(text []byte) (err error)
UnmarshalText reads text as one of the sampler names, in any letter case; any other text is a configuration error naming the key.
type WriteConcern ¶
type WriteConcern string
WriteConcern names the write concern of the mongo client: majority, journaled, the number of members that must acknowledge a write (the constants name the first ten; any non-negative number is accepted), or the name of a write concern the replica set itself defines.
const ( WriteConcernMajority WriteConcern = "majority" WriteConcernJournaled WriteConcern = "journaled" WriteConcernW0 WriteConcern = "0" WriteConcernW1 WriteConcern = "1" WriteConcernW2 WriteConcern = "2" WriteConcernW3 WriteConcern = "3" WriteConcernW4 WriteConcern = "4" WriteConcernW5 WriteConcern = "5" WriteConcernW6 WriteConcern = "6" WriteConcernW7 WriteConcern = "7" WriteConcernW8 WriteConcern = "8" WriteConcernW9 WriteConcern = "9" )
func (*WriteConcern) UnmarshalText ¶
func (c *WriteConcern) UnmarshalText(text []byte) error
UnmarshalText reads text as a write concern: majority or journaled in any letter case, a non-negative number, or the name of a write concern the replica set defines, kept as written. A negative or malformed number is a configuration error naming the key.
Source Files
¶
- app.go
- audit.go
- auth.go
- bytesize.go
- cache.go
- cassandra.go
- clickhouse.go
- config.go
- database.go
- debug.go
- decode.go
- elasticsearch.go
- etcd.go
- grpc.go
- influxdb.go
- kafka.go
- ldap.go
- load.go
- logger.go
- logmgmt.go
- middleware.go
- minio.go
- mongo.go
- mqtt.go
- mysql.go
- nats.go
- otel.go
- postgres.go
- redis.go
- rethinkdb.go
- rocketmq.go
- scylla.go
- server.go
- sqlite.go