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:
@@ -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 })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user