33import redis .asyncio as redis
44from typing import Callable , Optional , Set , Dict , Any
55from mesh_lib .abstract import ITopic , IPubSub
6- from mesh_lib .shared .types import ServiceDiscoveryConfig
6+ from typing import Dict , Any
7+ from mesh_lib .shared .types import PubSubConfig
78
89class RedisTopicImpl (ITopic ):
910 def __init__ (self , manager : 'RedisPubSub' , topic_name : str ):
@@ -23,20 +24,17 @@ async def close(self):
2324 await self .manager .unsubscribe (self .topic_name )
2425
2526class RedisPubSub (IPubSub ):
26- def __init__ (self , config : ServiceDiscoveryConfig ):
27- self .config = config
27+ def __init__ (self , redis_config : Dict [ str , Any ] ):
28+ self .config = redis_config # Store it if needed, or just use it
2829 self .subscriptions : Dict [str , Set [Callable [[any ], None ]]] = {}
2930
3031 # Redis setup
31- # Note: shared/types.py defines ServiceDiscoveryConfig.redis_config as a dict
32- redis_args = {}
33- if "url" in config .redis_config :
34- self .publisher = redis .from_url (config .redis_config ["url" ])
35- self .subscriber = redis .from_url (config .redis_config ["url" ])
32+ if "url" in redis_config :
33+ self .publisher = redis .from_url (redis_config ["url" ])
34+ self .subscriber = redis .from_url (redis_config ["url" ])
3635 else :
37- host = config .redis_config .get ("host" , "localhost" )
38- port = config .redis_config .get ("port" , 6379 )
39- # Filter unknown args? reusing dict directly might pass unwanted args but redis-py usually fine.
36+ host = redis_config .get ("host" , "localhost" )
37+ port = redis_config .get ("port" , 6379 )
4038 # safe defaults
4139 self .publisher = redis .Redis (host = host , port = port )
4240 self .subscriber = redis .Redis (host = host , port = port )
0 commit comments