|
9 | 9 | connect, |
10 | 10 | ) |
11 | 11 |
|
12 | | -from minos.common import ( |
13 | | - MinosConfig, |
14 | | -) |
15 | 12 | from minos.networks import ( |
16 | 13 | BrokerMessage, |
17 | 14 | BrokerPublisher, |
18 | | - InMemoryBrokerPublisherQueue, |
19 | | - PostgreSqlBrokerPublisherQueue, |
20 | | - QueuedBrokerPublisher, BrokerPublisherBuilder, |
| 15 | + BrokerPublisherBuilder, |
| 16 | +) |
| 17 | +from minos.plugins.rabbitmq.common import ( |
| 18 | + RabbitMQBrokerBuilderMixin, |
21 | 19 | ) |
22 | | -from minos.plugins.rabbitmq.common import RabbitMQBrokerBuilderMixin |
23 | 20 |
|
24 | 21 | logger = logging.getLogger(__name__) |
25 | 22 |
|
26 | 23 |
|
27 | | -class PostgreSqlQueuedRabbitMQBrokerPublisher(QueuedBrokerPublisher): |
28 | | - """PostgreSql Queued RabbitMQ Broker Publisher class.""" |
29 | | - |
30 | | - @classmethod |
31 | | - def _from_config(cls, config: MinosConfig, **kwargs) -> PostgreSqlQueuedRabbitMQBrokerPublisher: |
32 | | - impl = RabbitMQBrokerPublisher.from_config(config, **kwargs) |
33 | | - queue = PostgreSqlBrokerPublisherQueue.from_config(config, **kwargs) |
34 | | - return cls(impl, queue, **kwargs) |
35 | | - |
36 | | - |
37 | | -class InMemoryQueuedRabbitMQBrokerPublisher(QueuedBrokerPublisher): |
38 | | - """In Memory Queued RabbitMQ Broker Publisher class.""" |
39 | | - |
40 | | - @classmethod |
41 | | - def _from_config(cls, config: MinosConfig, **kwargs) -> InMemoryQueuedRabbitMQBrokerPublisher: |
42 | | - impl = RabbitMQBrokerPublisher.from_config(config, **kwargs) |
43 | | - queue = InMemoryBrokerPublisherQueue.from_config(config, **kwargs) |
44 | | - return cls(impl, queue, **kwargs) |
45 | | - |
46 | | - |
47 | 24 | class RabbitMQBrokerPublisher(BrokerPublisher): |
48 | 25 | """RabbitMQ Broker Publisher class.""" |
49 | 26 |
|
50 | 27 | def __init__(self, *args, host: str, port: int, **kwargs): |
51 | 28 | super().__init__(*args, **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) |
| 29 | + self.host = host |
| 30 | + self.port = port |
63 | 31 |
|
64 | 32 | async def _setup(self) -> None: |
65 | 33 | await super()._setup() |
66 | | - self.connection = await connect(f"amqp://guest:guest@{self.broker_host}:{self.broker_port}/") |
| 34 | + self.connection = await connect(f"amqp://guest:guest@{self.host}:{self.port}/") |
67 | 35 |
|
68 | 36 | async def _destroy(self) -> None: |
69 | 37 | await self.connection.close() |
|
0 commit comments