feat(config): integrate etcd for service discovery and config management
- Add etcd-client dependency for distributed configuration storage - Implement EtcdConfig with priority: etcd > environment variables > defaults - Add ServiceRegistry for service registration with lease keep-alive - Integrate etcd-based service discovery for appks gRPC connections - Add service watcher for real-time service instance updates - Migrate Redis configuration from single URL to cluster node list - Update Dockerfile with default IMKS_HOST and IMKS_PORT environment variables - Add etcd bootstrap configuration through environment variables - Implement Redis cluster URL building with optional authentication
This commit is contained in:
+24
-39
@@ -1,71 +1,56 @@
|
||||
# =============================================================================
|
||||
# imks — IM 实时消息服务 环境变量配置
|
||||
# 复制此文件为 .env 并修改相应值
|
||||
#
|
||||
# 配置优先级: etcd > 环境变量 > 默认值
|
||||
# =============================================================================
|
||||
|
||||
# --- 部署模式 ---
|
||||
# Adapter 模式: "local" (单节点) | "redis" | "nats"
|
||||
IMKS_ADAPTER=local
|
||||
# --- etcd 连接(启动引导,必须从环境变量读取)---
|
||||
ETCD_ENDPOINTS=http://localhost:2379
|
||||
ETCD_KEY_PREFIX=/appks/
|
||||
|
||||
# 当前节点唯一标识(默认取主机名)
|
||||
# --- 服务自身 ---
|
||||
# 注册到 etcd 的地址
|
||||
# IMKS_ADDR=0.0.0.0:3000
|
||||
|
||||
# --- 部署模式 ---
|
||||
# Adapter: "local" (单节点) | "redis" | "nats"
|
||||
IMKS_ADAPTER=redis
|
||||
|
||||
# 当前节点唯一标识
|
||||
# IMKS_SERVER_ID=imks-node-1
|
||||
|
||||
# Redis 连接(IMKS_ADAPTER=redis 时必需)
|
||||
# IMKS_REDIS_URL=redis://localhost:6379
|
||||
# Redis Cluster 节点列表(逗号分隔 host:port)
|
||||
IMKS_REDIS_CLUSTER_NODES=localhost:6379,localhost:6380,localhost:6381,localhost:6382,localhost:6383,localhost:6384
|
||||
|
||||
# NATS 连接(IMKS_ADAPTER=nats 时必需)
|
||||
# Redis 密码(可选)
|
||||
# IMKS_REDIS_PASSWORD=
|
||||
|
||||
# NATS 连接(IMKS_ADAPTER=nats 时使用)
|
||||
# IMKS_NATS_URL=nats://localhost:4222
|
||||
|
||||
# --- WebTransport (QUIC) ---
|
||||
# 启用 WebTransport 服务(需要 TLS 证书)
|
||||
# IMKS_WT_ENABLED=false
|
||||
# IMKS_WT_PORT=3001
|
||||
# IMKS_WT_CERT_PATH=/path/to/cert.pem
|
||||
# IMKS_WT_KEY_PATH=/path/to/key.pem
|
||||
# IMKS_WT_CERT_PATH=/etc/imks/cert.pem
|
||||
# IMKS_WT_KEY_PATH=/etc/imks/key.pem
|
||||
|
||||
# --- 数据库 ---
|
||||
# PostgreSQL 连接字符串
|
||||
# DATABASE_URL=postgres://imks:password@localhost:5432/imks
|
||||
DATABASE_URL=postgres://localhost/imks
|
||||
|
||||
# 连接池配置
|
||||
# DATABASE_MAX_CONNECTIONS=10
|
||||
# DATABASE_MIN_CONNECTIONS=2
|
||||
# DATABASE_CONNECT_TIMEOUT=30
|
||||
# DATABASE_IDLE_TIMEOUT=600
|
||||
|
||||
# --- appks gRPC 连接 ---
|
||||
# appks 核心服务地址
|
||||
# fallback:imks 优先通过 etcd 发现 appks 地址
|
||||
# APPKS_GRPC_ADDR=http://localhost:50051
|
||||
|
||||
# 连接超时(秒)
|
||||
# APPKS_GRPC_TIMEOUT=10
|
||||
|
||||
# mTLS 配置(生产环境必需)
|
||||
# APPKS_GRPC_TLS_CA_CERT=/path/to/ca.pem
|
||||
# APPKS_GRPC_TLS_CLIENT_CERT=/path/to/client.pem
|
||||
# APPKS_GRPC_TLS_CLIENT_KEY=/path/to/client-key.pem
|
||||
# APPKS_GRPC_TLS_DOMAIN=appks.internal
|
||||
|
||||
# --- OpenTelemetry 可观测性 ---
|
||||
# 服务名
|
||||
# OTEL_SERVICE_NAME=imks
|
||||
# OTEL_SERVICE_VERSION=0.1.0
|
||||
|
||||
# OTLP 收集器地址
|
||||
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
|
||||
# 协议: grpc | http/protobuf
|
||||
# OTEL_EXPORTER_OTLP_PROTOCOL=grpc
|
||||
|
||||
# 启用/禁用 telemetry
|
||||
# OTEL_TRACES_ENABLED=true
|
||||
# OTEL_METRICS_ENABLED=true
|
||||
# OTEL_LOGS_ENABLED=true
|
||||
|
||||
# 日志级别: trace | debug | info | warn | error
|
||||
# --- 日志 ---
|
||||
RUST_LOG=info
|
||||
# 日志格式: json | pretty
|
||||
# LOG_FORMAT=json
|
||||
|
||||
# 部署环境标识
|
||||
# OTEL_RESOURCE_ATTRIBUTES_DEPLOYMENT=development
|
||||
|
||||
Reference in New Issue
Block a user