1717 BrokerPublisher ,
1818 InMemoryBrokerPublisherQueue ,
1919 PostgreSqlBrokerPublisherQueue ,
20- QueuedBrokerPublisher ,
20+ QueuedBrokerPublisher , BrokerPublisherBuilder ,
2121)
22+ from minos .plugins .rabbitmq .common import RabbitMQBrokerBuilderMixin
2223
2324logger = logging .getLogger (__name__ )
2425
@@ -46,19 +47,19 @@ def _from_config(cls, config: MinosConfig, **kwargs) -> InMemoryQueuedRabbitMQBr
4647class RabbitMQBrokerPublisher (BrokerPublisher ):
4748 """RabbitMQ Broker Publisher class."""
4849
49- def __init__ (self , * args , broker_host : str , broker_port : int , ** kwargs ):
50+ def __init__ (self , * args , host : str , port : int , ** kwargs ):
5051 super ().__init__ (* args , ** kwargs )
51- self .broker_host = broker_host
52- self .broker_port = broker_port
53-
54- @classmethod
55- def _from_config (cls , config : MinosConfig , ** kwargs ) -> RabbitMQBrokerPublisher :
56- broker_config = config .get_interface_by_name ("broker" )
57- common_config = broker_config ["common" ]
58-
59- kwargs ["broker_host" ] = common_config ["host" ]
60- kwargs ["broker_port" ] = common_config ["port" ]
61- return cls (** kwargs )
52+ self .broker_host = host
53+ self .broker_port = port
54+
55+ # @classmethod
56+ # def _from_config(cls, config: MinosConfig, **kwargs) -> RabbitMQBrokerPublisher:
57+ # broker_config = config.get_interface_by_name("broker")
58+ # common_config = broker_config["common"]
59+ #
60+ # kwargs["broker_host"] = common_config["host"]
61+ # kwargs["broker_port"] = common_config["port"]
62+ # return cls(**kwargs)
6263
6364 async def _setup (self ) -> None :
6465 await super ()._setup ()
@@ -72,3 +73,10 @@ async def _send(self, message: BrokerMessage) -> None:
7273 channel = await self .connection .channel ()
7374 queue = await channel .declare_queue (message .topic )
7475 await channel .default_exchange .publish (Message (message .avro_bytes ), routing_key = queue .name )
76+
77+
78+ class RabbitMQBrokerPublisherBuilder (BrokerPublisherBuilder [RabbitMQBrokerPublisher ], RabbitMQBrokerBuilderMixin ):
79+ """RabbitMQ Broker Publisher Builder class."""
80+
81+
82+ RabbitMQBrokerPublisher .set_builder (RabbitMQBrokerPublisherBuilder )
0 commit comments