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:
zhenyi
2026-06-11 16:22:23 +08:00
parent 1b300865d9
commit e72866db8d
9 changed files with 316 additions and 62 deletions
+7 -3
View File
@@ -12,14 +12,17 @@ pub struct RedisMessageBus {
}
impl RedisMessageBus {
pub async fn new(redis_url: &str) -> Result<Self, MessageBusError> {
/// Connect to a Redis cluster.
///
/// `cluster_url` should be in `redis-cluster://` format, e.g.:
/// `redis-cluster://host1:6379,host2:6379,host3:6379`
pub async fn new(cluster_url: &str) -> Result<Self, MessageBusError> {
let config =
Config::from_url(redis_url).map_err(|e| MessageBusError::Redis(e.to_string()))?;
Config::from_url(cluster_url).map_err(|e| MessageBusError::Redis(e.to_string()))?;
let client = Client::new(config.clone(), None, None, None);
let subscriber = SubscriberClient::new(config, None, None, None);
// connect() starts the connection task; result is checked by wait_for_connect()
let _ = client.connect().await;
let _ = subscriber.connect().await;
@@ -32,6 +35,7 @@ impl RedisMessageBus {
.await
.map_err(|e| MessageBusError::Redis(e.to_string()))?;
tracing::info!(cluster_url, "Redis cluster connected");
Ok(Self { client, subscriber })
}