From 089c9d4081f64d3d54cd2d7bba1a8ccfda9cf2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Wed, 10 Nov 2021 11:58:42 +0100 Subject: [PATCH 01/24] ISSUE #434 * Add broker messages. --- minos/networks/__init__.py | 5 ++ minos/networks/broker_messages.py | 63 +++++++++++++++++++ minos/networks/brokers/command_replies.py | 22 ++++--- minos/networks/brokers/commands.py | 12 ++-- minos/networks/brokers/events.py | 10 +-- minos/networks/handlers/abc/handlers.py | 11 +--- .../handlers/command_replies/handlers.py | 5 +- minos/networks/handlers/commands/handlers.py | 24 +++---- minos/networks/handlers/events/handlers.py | 20 +++--- tests/services/sagas.py | 11 ---- .../test_brokers/test_command_replies.py | 16 ++--- .../test_brokers/test_commands.py | 11 ++-- .../test_networks/test_brokers/test_events.py | 5 +- .../test_brokers/test_producers.py | 10 ++- .../test_handlers/test_abc/test_handlers.py | 20 ++---- .../test_command_replies/test_handlers.py | 13 ++-- .../test_commands/test_handlers.py | 31 ++++----- .../test_events/test_handlers.py | 13 ++-- .../test_handlers/test_messages.py | 28 ++++----- tests/utils.py | 11 ++-- 20 files changed, 189 insertions(+), 152 deletions(-) create mode 100644 minos/networks/broker_messages.py delete mode 100644 tests/services/sagas.py diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index d82ad291..a1f90368 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -2,6 +2,11 @@ __email__ = "devs@clariteia.com" __version__ = "0.1.1" +from .broker_messages import ( + PublishRequest, + PublishResponse, + PublishResponseStatus, +) from .brokers import ( REPLY_TOPIC_CONTEXT_VAR, Broker, diff --git a/minos/networks/broker_messages.py b/minos/networks/broker_messages.py new file mode 100644 index 00000000..543c000b --- /dev/null +++ b/minos/networks/broker_messages.py @@ -0,0 +1,63 @@ +from __future__ import ( + annotations, +) + +from enum import ( + IntEnum, +) +from typing import ( + Any, + Optional, +) +from uuid import ( + UUID, +) + +from minos.common import ( + DeclarativeModel, +) + + +class PublishRequest(DeclarativeModel): + """Publish request class.""" + + topic: str + data: Any + identifier: Optional[UUID] + reply_topic: Optional[str] + user: Optional[UUID] + + def __init__( + self, + topic: str, + data: Any, + identifier: Optional[UUID] = None, + reply_topic: Optional[str] = None, + user: Optional[UUID] = None, + *args, + **kwargs + ): + super().__init__(topic, data, identifier, reply_topic, user, *args, **kwargs) + + +class PublishResponse(DeclarativeModel): + """Publish response class.""" + + topic: str + data: Any + identifier: Optional[UUID] + status: PublishResponseStatus + service_name: str + + @property + def ok(self) -> bool: + """TODO""" + return self.status == PublishResponseStatus.SUCCESS + + +class PublishResponseStatus(IntEnum): + """Publish status class.""" + + SUCCESS = 200 + ERROR = 400 + SYSTEM_ERROR = 500 diff --git a/minos/networks/brokers/command_replies.py b/minos/networks/brokers/command_replies.py index 9390f4f9..03b0f2c7 100644 --- a/minos/networks/brokers/command_replies.py +++ b/minos/networks/brokers/command_replies.py @@ -11,11 +11,13 @@ ) from minos.common import ( - CommandReply, - CommandStatus, MinosConfig, ) +from ..broker_messages import ( + PublishResponse, + PublishResponseStatus, +) from .abc import ( Broker, ) @@ -28,21 +30,25 @@ class CommandReplyBroker(Broker): ACTION = "commandReply" + def __init__(self, *args, service_name: str, **kwargs): + super().__init__(*args, **kwargs) + self.service_name = service_name + @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyBroker: - return cls(*args, **config.broker.queue._asdict(), **kwargs) + return cls(*args, service_name=config.service.name, **config.broker.queue._asdict(), **kwargs) # noinspection PyMethodOverriding - async def send(self, data: Any, topic: str, saga: UUID, status: CommandStatus, **kwargs) -> int: + async def send(self, data: Any, topic: str, saga: UUID, status: PublishResponseStatus, **kwargs) -> int: """Send a ``CommandReply``. :param data: The data to be send. :param topic: Topic in which the message will be published. :param saga: Saga identifier. - :param status: Command status. + :param status: command status. :return: This method does not return anything. """ - command_reply = CommandReply(topic, data, saga, status) - logger.info(f"Sending '{command_reply!s}'...") - return await self.enqueue(command_reply.topic, command_reply.avro_bytes) + request = PublishResponse(topic, data, saga, status, self.service_name) + logger.info(f"Sending '{request!s}'...") + return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/brokers/commands.py b/minos/networks/brokers/commands.py index be9fce93..c613925c 100644 --- a/minos/networks/brokers/commands.py +++ b/minos/networks/brokers/commands.py @@ -16,10 +16,12 @@ ) from minos.common import ( - Command, MinosConfig, ) +from ..broker_messages import ( + PublishRequest, +) from .abc import ( Broker, ) @@ -48,7 +50,7 @@ async def send( self, data: Any, topic: str, - saga: UUID, + saga: Optional[UUID] = None, reply_topic: Optional[str] = None, user: Optional[UUID] = None, **kwargs, @@ -68,6 +70,6 @@ async def send( if reply_topic is None: reply_topic = self.default_reply_topic - command = Command(topic, data, saga, reply_topic, user) - logger.info(f"Sending '{command!s}'...") - return await self.enqueue(command.topic, command.avro_bytes) + request = PublishRequest(topic, data, saga, reply_topic, user) + logger.info(f"Sending '{request!s}'...") + return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/brokers/events.py b/minos/networks/brokers/events.py index a134cf1a..d262937d 100644 --- a/minos/networks/brokers/events.py +++ b/minos/networks/brokers/events.py @@ -8,10 +8,12 @@ AggregateDiff, ) from minos.common import ( - Event, MinosConfig, ) +from ..broker_messages import ( + PublishRequest, +) from .abc import ( Broker, ) @@ -36,6 +38,6 @@ async def send(self, data: AggregateDiff, topic: str, **kwargs) -> int: :param topic: Topic in which the message will be published. :return: This method does not return anything. """ - event = Event(topic, data) - logger.info(f"Sending '{event!s}'...") - return await self.enqueue(event.topic, event.avro_bytes) + request = PublishRequest(topic, data) + logger.info(f"Sending '{request!s}'...") + return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/handlers/abc/handlers.py b/minos/networks/handlers/abc/handlers.py index 404f18fb..64c267c7 100644 --- a/minos/networks/handlers/abc/handlers.py +++ b/minos/networks/handlers/abc/handlers.py @@ -17,7 +17,6 @@ KeysView, NoReturn, Optional, - Type, ) from aiopg import ( @@ -31,10 +30,6 @@ Identifier, ) -from minos.common import ( - MinosModel, -) - from ...exceptions import ( MinosActionNotFoundException, ) @@ -59,8 +54,6 @@ class Handler(HandlerSetup): __slots__ = "_handlers", "_records", "_retry" - ENTRY_MODEL_CLS: Type[MinosModel] - def __init__(self, records: int, handlers: dict[str, Optional[Callable]], retry: int, **kwargs: Any): super().__init__(**kwargs) self._handlers = handlers @@ -170,7 +163,7 @@ def _queries(self) -> dict[str, str]: } def _build_entries(self, rows: list[tuple]) -> list[HandlerEntry]: - kwargs = {"callback_lookup": self.get_action, "data_cls": self.ENTRY_MODEL_CLS} + kwargs = {"callback_lookup": self.get_action} return [HandlerEntry(*row, **kwargs) for row in rows] async def _dispatch_entries(self, entries: list[HandlerEntry]) -> None: @@ -186,7 +179,7 @@ async def _dispatch_one(self, entry: HandlerEntry) -> None: entry.exception = exc @abstractmethod - async def dispatch_one(self, entry: HandlerEntry[ENTRY_MODEL_CLS]) -> None: + async def dispatch_one(self, entry: HandlerEntry) -> None: """Dispatch one row. :param entry: Entry to be dispatched. diff --git a/minos/networks/handlers/command_replies/handlers.py b/minos/networks/handlers/command_replies/handlers.py index 3e497343..112c5996 100644 --- a/minos/networks/handlers/command_replies/handlers.py +++ b/minos/networks/handlers/command_replies/handlers.py @@ -13,7 +13,6 @@ ) from minos.common import ( - CommandReply, MinosConfig, MinosSagaManager, ) @@ -31,8 +30,6 @@ class CommandReplyHandler(Handler): """Command Reply Handler class.""" - ENTRY_MODEL_CLS = CommandReply - @inject def __init__(self, saga_manager: MinosSagaManager = Provide["saga_manager"], **kwargs: Any): super().__init__(**kwargs) @@ -45,7 +42,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyHandl # noinspection PyProtectedMember return cls(*args, handlers=handlers, **config.broker.queue._asdict(), **kwargs) - async def dispatch_one(self, entry: HandlerEntry[CommandReply]) -> None: + async def dispatch_one(self, entry: HandlerEntry) -> None: """Dispatch one row. :param entry: Entry to be dispatched. diff --git a/minos/networks/handlers/commands/handlers.py b/minos/networks/handlers/commands/handlers.py index 898cc723..cc091ed2 100644 --- a/minos/networks/handlers/commands/handlers.py +++ b/minos/networks/handlers/commands/handlers.py @@ -21,12 +21,14 @@ ) from minos.common import ( - Command, - CommandStatus, MinosBroker, MinosConfig, ) +from ...broker_messages import ( + PublishRequest, + PublishResponseStatus, +) from ...decorators import ( EnrouteBuilder, ) @@ -51,8 +53,6 @@ class CommandHandler(Handler): """Command Handler class.""" - ENTRY_MODEL_CLS = Command - @inject def __init__(self, broker: MinosBroker = Provide["command_reply_broker"], **kwargs: Any): super().__init__(**kwargs) @@ -71,7 +71,7 @@ def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[ handlers = {decorator.topic: fn for decorator, fn in decorators.items()} return handlers - async def dispatch_one(self, entry: HandlerEntry[Command]) -> None: + async def dispatch_one(self, entry: HandlerEntry) -> None: """Dispatch one row. :param entry: Entry to be dispatched. @@ -83,20 +83,20 @@ async def dispatch_one(self, entry: HandlerEntry[Command]) -> None: command = entry.data items, status = await fn(command) - await self.broker.send(items, topic=command.reply_topic, saga=command.saga, status=status) + await self.broker.send(items, topic=command.reply_topic, saga=command.identifier, status=status) @staticmethod def get_callback( fn: Callable[[HandlerRequest], Union[Optional[HandlerRequest], Awaitable[Optional[HandlerRequest]]]] - ) -> Callable[[Command], Awaitable[Tuple[Any, CommandStatus]]]: + ) -> Callable[[PublishRequest], Awaitable[Tuple[Any, PublishResponseStatus]]]: """Get the handler function to be used by the Command Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Command Handler API. """ - async def _fn(command: Command) -> Tuple[Any, CommandStatus]: - request = HandlerRequest(command) + async def _fn(raw: PublishRequest) -> Tuple[Any, PublishResponseStatus]: + request = HandlerRequest(raw) token = USER_CONTEXT_VAR.set(request.user) try: @@ -105,13 +105,13 @@ async def _fn(command: Command) -> Tuple[Any, CommandStatus]: response = await response if isinstance(response, Response): response = await response.content() - return response, CommandStatus.SUCCESS + return response, PublishResponseStatus.SUCCESS except ResponseException as exc: logger.warning(f"Raised an application exception: {exc!s}") - return repr(exc), CommandStatus.ERROR + return repr(exc), PublishResponseStatus.ERROR except Exception as exc: logger.exception(f"Raised a system exception: {exc!r}") - return repr(exc), CommandStatus.SYSTEM_ERROR + return repr(exc), PublishResponseStatus.SYSTEM_ERROR finally: USER_CONTEXT_VAR.reset(token) diff --git a/minos/networks/handlers/events/handlers.py b/minos/networks/handlers/events/handlers.py index d92fd8d3..9984336f 100644 --- a/minos/networks/handlers/events/handlers.py +++ b/minos/networks/handlers/events/handlers.py @@ -22,10 +22,12 @@ ) from minos.common import ( - Event, MinosConfig, ) +from ...broker_messages import ( + PublishRequest, +) from ...decorators import ( EnrouteBuilder, ) @@ -49,8 +51,6 @@ class EventHandler(Handler): """Event Handler class.""" - ENTRY_MODEL_CLS = Event - @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventHandler: handlers = cls._handlers_from_config(config, **kwargs) @@ -64,7 +64,7 @@ def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[ handlers = {decorator.topic: fn for decorator, fn in handlers.items()} return handlers - async def _dispatch_entries(self, entries: list[HandlerEntry[Event]]) -> None: + async def _dispatch_entries(self, entries: list[HandlerEntry]) -> None: grouped = defaultdict(list) for entry in entries: grouped[uuid_getter(entry)].append(entry) @@ -75,11 +75,11 @@ async def _dispatch_entries(self, entries: list[HandlerEntry[Event]]) -> None: futures = (self._dispatch_group(group) for group in grouped.values()) await gather(*futures) - async def _dispatch_group(self, entries: list[HandlerEntry[Event]]): + async def _dispatch_group(self, entries: list[HandlerEntry]): for entry in entries: await self._dispatch_one(entry) - async def dispatch_one(self, entry: HandlerEntry[Event]) -> None: + async def dispatch_one(self, entry: HandlerEntry) -> None: """Dispatch one row. :param entry: Entry to be dispatched. @@ -91,16 +91,18 @@ async def dispatch_one(self, entry: HandlerEntry[Event]) -> None: await fn(entry.data) @staticmethod - def get_callback(fn: Callable[[HandlerRequest], Optional[Awaitable[None]]]) -> Callable[[Event], Awaitable[None]]: + def get_callback( + fn: Callable[[HandlerRequest], Optional[Awaitable[None]]] + ) -> Callable[[PublishRequest], Awaitable[None]]: """Get the handler function to be used by the Event Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Event Handler API. """ - async def _fn(event: Event) -> None: + async def _fn(raw: PublishRequest) -> None: try: - request = HandlerRequest(event) + request = HandlerRequest(raw) response = fn(request) if isawaitable(response): await response diff --git a/tests/services/sagas.py b/tests/services/sagas.py deleted file mode 100644 index eb1e37ee..00000000 --- a/tests/services/sagas.py +++ /dev/null @@ -1,11 +0,0 @@ -from minos.common import ( - CommandReply, -) - - -class SagaService(object): - async def add_order(self, topic: str, command: CommandReply): - return "add_order_saga" - - async def delete_order(self, topic: str, command: CommandReply): - return "delete_order_saga" diff --git a/tests/test_networks/test_brokers/test_command_replies.py b/tests/test_networks/test_brokers/test_command_replies.py index f281bccc..d39277db 100644 --- a/tests/test_networks/test_brokers/test_command_replies.py +++ b/tests/test_networks/test_brokers/test_command_replies.py @@ -6,15 +6,13 @@ uuid4, ) -from minos.common import ( - CommandReply, - CommandStatus, -) from minos.common.testing import ( PostgresAsyncTestCase, ) from minos.networks import ( CommandReplyBroker, + PublishResponse, + PublishResponseStatus, ) from tests.utils import ( BASE_PATH, @@ -38,7 +36,9 @@ async def test_send(self): reply_topic = "fakeReply" async with CommandReplyBroker.from_config(config=self.config) as broker: broker.enqueue = mock - identifier = await broker.send(FakeModel("foo"), saga=saga, topic=reply_topic, status=CommandStatus.SUCCESS) + identifier = await broker.send( + FakeModel("foo"), saga=saga, topic=reply_topic, status=PublishResponseStatus.SUCCESS + ) self.assertEqual(56, identifier) self.assertEqual(1, mock.call_count) @@ -46,8 +46,10 @@ async def test_send(self): args = mock.call_args.args self.assertEqual(reply_topic, args[0]) - expected = CommandReply(reply_topic, FakeModel("foo"), saga, CommandStatus.SUCCESS) - observed = CommandReply.from_avro_bytes(args[1]) + expected = PublishResponse( + reply_topic, FakeModel("foo"), saga, PublishResponseStatus.SUCCESS, self.config.service.name + ) + observed = PublishResponse.from_avro_bytes(args[1]) self.assertEqual(expected, observed) diff --git a/tests/test_networks/test_brokers/test_commands.py b/tests/test_networks/test_brokers/test_commands.py index 8b0cbed8..cb629fd5 100644 --- a/tests/test_networks/test_brokers/test_commands.py +++ b/tests/test_networks/test_brokers/test_commands.py @@ -7,7 +7,7 @@ ) from minos.common import ( - Command, + Model, ) from minos.common.testing import ( PostgresAsyncTestCase, @@ -15,6 +15,7 @@ from minos.networks import ( REPLY_TOPIC_CONTEXT_VAR, CommandBroker, + PublishRequest, ) from tests.utils import ( BASE_PATH, @@ -49,7 +50,7 @@ async def test_send(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(Command("fake", FakeModel("foo"), saga, "ekaf"), Command.from_avro_bytes(args[1])) + self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "ekaf"), Model.from_avro_bytes(args[1])) async def test_send_with_default_reply_topic(self): mock = AsyncMock(return_value=56) @@ -64,7 +65,7 @@ async def test_send_with_default_reply_topic(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(Command("fake", FakeModel("foo"), saga, "OrderReply"), Command.from_avro_bytes(args[1])) + self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "OrderReply"), Model.from_avro_bytes(args[1])) async def test_send_with_reply_topic_context_var(self): mock = AsyncMock(return_value=56) @@ -81,7 +82,7 @@ async def test_send_with_reply_topic_context_var(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(Command("fake", FakeModel("foo"), saga, "onetwothree"), Command.from_avro_bytes(args[1])) + self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "onetwothree"), Model.from_avro_bytes(args[1])) async def test_send_with_user(self): mock = AsyncMock(return_value=56) @@ -97,7 +98,7 @@ async def test_send_with_user(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(Command("fake", FakeModel("foo"), saga, "ekaf", user), Command.from_avro_bytes(args[1])) + self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "ekaf", user), Model.from_avro_bytes(args[1])) if __name__ == "__main__": diff --git a/tests/test_networks/test_brokers/test_events.py b/tests/test_networks/test_brokers/test_events.py index c0b5cfee..51285171 100644 --- a/tests/test_networks/test_brokers/test_events.py +++ b/tests/test_networks/test_brokers/test_events.py @@ -4,13 +4,14 @@ ) from minos.common import ( - Event, + Model, ) from minos.common.testing import ( PostgresAsyncTestCase, ) from minos.networks import ( EventBroker, + PublishRequest, ) from tests.utils import ( BASE_PATH, @@ -38,7 +39,7 @@ async def test_send(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(Event("fake", FAKE_AGGREGATE_DIFF), Event.from_avro_bytes(args[1])) + self.assertEqual(PublishRequest("fake", FAKE_AGGREGATE_DIFF), Model.from_avro_bytes(args[1])) if __name__ == "__main__": diff --git a/tests/test_networks/test_brokers/test_producers.py b/tests/test_networks/test_brokers/test_producers.py index 9f92f8ac..15431d69 100644 --- a/tests/test_networks/test_brokers/test_producers.py +++ b/tests/test_networks/test_brokers/test_producers.py @@ -14,9 +14,6 @@ import aiopg -from minos.common import ( - CommandStatus, -) from minos.common.testing import ( PostgresAsyncTestCase, ) @@ -26,6 +23,7 @@ Consumer, EventBroker, Producer, + PublishResponseStatus, ) from tests.utils import ( BASE_PATH, @@ -140,7 +138,7 @@ async def test_concurrency_dispatcher(self): for x in range(0, 20): async with command_reply_broker: - await command_reply_broker.send(model, "TestDeleteReply", saga, CommandStatus.SUCCESS) + await command_reply_broker.send(model, "TestDeleteReply", saga, PublishResponseStatus.SUCCESS) async with command_broker: await command_broker.send(model, "CommandBroker-Delete", saga, "TestDeleteReply") @@ -187,8 +185,8 @@ async def test_if_commands_retry_was_incremented(self): saga = uuid4() async with CommandReplyBroker.from_config(config=self.config) as broker: - queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, CommandStatus.SUCCESS) - queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, CommandStatus.SUCCESS) + queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, PublishResponseStatus.SUCCESS) + queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, PublishResponseStatus.SUCCESS) async with self.producer: self.producer.publish = AsyncMock(return_value=False) diff --git a/tests/test_networks/test_handlers/test_abc/test_handlers.py b/tests/test_networks/test_handlers/test_abc/test_handlers.py index 2f916f0d..a70754b3 100644 --- a/tests/test_networks/test_handlers/test_abc/test_handlers.py +++ b/tests/test_networks/test_handlers/test_abc/test_handlers.py @@ -31,6 +31,7 @@ Handler, HandlerResponse, MinosActionNotFoundException, + PublishRequest, ) from minos.networks.handlers import ( HandlerEntry, @@ -127,11 +128,7 @@ async def test_dispatch_forever_without_topics(self): self.assertEqual(0, mock.call_count) async def test_dispatch(self): - from minos.common import ( - Event, - ) - - instance = Event("AddOrder", FAKE_AGGREGATE_DIFF) + instance = PublishRequest("AddOrder", FAKE_AGGREGATE_DIFF) async with self.handler: queue_id = await self._insert_one(instance) @@ -141,13 +138,9 @@ async def test_dispatch(self): self.assertEqual(1, self.handler.call_count) async def test_dispatch_wrong(self): - from minos.common import ( - Event, - ) - instance_1 = namedtuple("FakeCommand", ("topic", "avro_bytes"))("AddOrder", bytes(b"Test")) - instance_2 = Event("DeleteOrder", FAKE_AGGREGATE_DIFF) - instance_3 = Event("NoActionTopic", FAKE_AGGREGATE_DIFF) + instance_2 = PublishRequest("DeleteOrder", FAKE_AGGREGATE_DIFF) + instance_3 = PublishRequest("NoActionTopic", FAKE_AGGREGATE_DIFF) async with self.handler: queue_id_1 = await self._insert_one(instance_1) @@ -159,16 +152,13 @@ async def test_dispatch_wrong(self): self.assertFalse(await self._is_processed(queue_id_3)) async def test_dispatch_concurrent(self): - from minos.common import ( - Command, - ) from tests.utils import ( FakeModel, ) saga = uuid4() - instance = Command("AddOrder", [FakeModel("foo")], saga, "UpdateTicket") + instance = PublishRequest("AddOrder", [FakeModel("foo")], saga, "UpdateTicket") instance_wrong = namedtuple("FakeCommand", ("topic", "avro_bytes"))("AddOrder", bytes(b"Test")) async with self.handler: diff --git a/tests/test_networks/test_handlers/test_command_replies/test_handlers.py b/tests/test_networks/test_handlers/test_command_replies/test_handlers.py index d5c9d02a..2f62c3c6 100644 --- a/tests/test_networks/test_handlers/test_command_replies/test_handlers.py +++ b/tests/test_networks/test_handlers/test_command_replies/test_handlers.py @@ -7,16 +7,14 @@ uuid4, ) -from minos.common import ( - CommandReply, - CommandStatus, -) from minos.common.testing import ( PostgresAsyncTestCase, ) from minos.networks import ( CommandReplyHandler, HandlerEntry, + PublishResponse, + PublishResponseStatus, ) from tests.utils import ( BASE_PATH, @@ -43,16 +41,15 @@ def test_from_config(self): self.assertEqual(self.config.broker.queue.password, handler.password) self.assertEqual(saga_manager, handler.saga_manager) - def test_entry_model_cls(self): - self.assertEqual(CommandReply, CommandReplyHandler.ENTRY_MODEL_CLS) - async def test_dispatch(self): saga_manager = FakeSagaManager() mock = AsyncMock() saga_manager._load_and_run = mock saga = uuid4() - command = CommandReply("TicketAdded", [FakeModel("foo")], saga, CommandStatus.SUCCESS) + command = PublishResponse( + "TicketAdded", [FakeModel("foo")], saga, PublishResponseStatus.SUCCESS, self.config.service.name + ) entry = HandlerEntry(1, "TicketAdded", 0, command.avro_bytes, 1) async with CommandReplyHandler.from_config(config=self.config, saga_manager=saga_manager) as handler: diff --git a/tests/test_networks/test_handlers/test_commands/test_handlers.py b/tests/test_networks/test_handlers/test_commands/test_handlers.py index 88d2252b..a8b3f353 100644 --- a/tests/test_networks/test_handlers/test_commands/test_handlers.py +++ b/tests/test_networks/test_handlers/test_commands/test_handlers.py @@ -8,10 +8,6 @@ uuid4, ) -from minos.common import ( - Command, - CommandStatus, -) from minos.common.testing import ( PostgresAsyncTestCase, ) @@ -22,6 +18,8 @@ HandlerRequest, HandlerResponse, HandlerResponseException, + PublishRequest, + PublishResponseStatus, Request, Response, ) @@ -58,7 +56,7 @@ def setUp(self) -> None: self.broker = FakeBroker() self.handler = CommandHandler.from_config(config=self.config, broker=self.broker) self.user = uuid4() - self.command = Command("AddOrder", FakeModel("foo"), self.user, "UpdateTicket") + self.request = PublishRequest("AddOrder", FakeModel("foo"), self.user, "UpdateTicket") def test_from_config(self): broker = FakeBroker() @@ -75,13 +73,10 @@ def test_from_config(self): self.assertEqual(self.config.broker.queue.password, handler.password) self.assertEqual(broker, handler.broker) - def test_entry_model_cls(self): - self.assertEqual(Command, CommandHandler.ENTRY_MODEL_CLS) - async def test_dispatch(self): callback_mock = AsyncMock(return_value=Response("add_order")) lookup_mock = MagicMock(return_value=callback_mock) - entry = HandlerEntry(1, "AddOrder", 0, self.command.avro_bytes, 1, callback_lookup=lookup_mock) + entry = HandlerEntry(1, "AddOrder", 0, self.request.avro_bytes, 1, callback_lookup=lookup_mock) async with self.handler: await self.handler.dispatch_one(entry) @@ -92,9 +87,9 @@ async def test_dispatch(self): self.assertEqual(1, self.broker.call_count) self.assertEqual("add_order", self.broker.items) self.assertEqual("UpdateTicket", self.broker.topic) - self.assertEqual(self.command.saga, self.broker.saga) + self.assertEqual(self.request.identifier, self.broker.identifier) self.assertEqual(None, self.broker.reply_topic) - self.assertEqual(CommandStatus.SUCCESS, self.broker.status) + self.assertEqual(PublishResponseStatus.SUCCESS, self.broker.status) self.assertEqual(1, callback_mock.call_count) observed = callback_mock.call_args[0][0] @@ -103,21 +98,21 @@ async def test_dispatch(self): async def test_get_callback(self): fn = self.handler.get_callback(_Cls._fn) - self.assertEqual((FakeModel("foo"), CommandStatus.SUCCESS), await fn(self.command)) + self.assertEqual((FakeModel("foo"), PublishResponseStatus.SUCCESS), await fn(self.request)) async def test_get_callback_none(self): fn = self.handler.get_callback(_Cls._fn_none) - self.assertEqual((None, CommandStatus.SUCCESS), await fn(self.command)) + self.assertEqual((None, PublishResponseStatus.SUCCESS), await fn(self.request)) async def test_get_callback_raises_response(self): fn = self.handler.get_callback(_Cls._fn_raises_response) - expected = (repr(HandlerResponseException("foo")), CommandStatus.ERROR) - self.assertEqual(expected, await fn(self.command)) + expected = (repr(HandlerResponseException("foo")), PublishResponseStatus.ERROR) + self.assertEqual(expected, await fn(self.request)) async def test_get_callback_raises_exception(self): fn = self.handler.get_callback(_Cls._fn_raises_exception) - expected = (repr(ValueError()), CommandStatus.SYSTEM_ERROR) - self.assertEqual(expected, await fn(self.command)) + expected = (repr(ValueError()), PublishResponseStatus.SYSTEM_ERROR) + self.assertEqual(expected, await fn(self.request)) async def test_get_callback_with_user(self): async def _fn(request) -> None: @@ -127,7 +122,7 @@ async def _fn(request) -> None: mock = AsyncMock(side_effect=_fn) handler = self.handler.get_callback(mock) - await handler(self.command) + await handler(self.request) self.assertEqual(1, mock.call_count) diff --git a/tests/test_networks/test_handlers/test_events/test_handlers.py b/tests/test_networks/test_handlers/test_events/test_handlers.py index e6552891..830f4d86 100644 --- a/tests/test_networks/test_handlers/test_events/test_handlers.py +++ b/tests/test_networks/test_handlers/test_events/test_handlers.py @@ -22,7 +22,6 @@ FieldDiffContainer, ) from minos.common import ( - Event, current_datetime, ) from minos.common.testing import ( @@ -33,6 +32,7 @@ HandlerEntry, HandlerRequest, HandlerResponseException, + PublishRequest, Request, ) from tests.utils import ( @@ -61,7 +61,7 @@ class TestEventHandler(PostgresAsyncTestCase): def setUp(self) -> None: super().setUp() self.handler = EventHandler.from_config(config=self.config) - self.event = Event("TicketAdded", FAKE_AGGREGATE_DIFF) + self.event = PublishRequest("TicketAdded", FAKE_AGGREGATE_DIFF) def test_from_config(self): self.assertIsInstance(self.handler, EventHandler) @@ -83,15 +83,12 @@ async def test_handlers(self): ) self.assertEqual("ticket_deleted", await self.handler.handlers["TicketDeleted"](None)) - def test_entry_model_cls(self): - self.assertEqual(Event, EventHandler.ENTRY_MODEL_CLS) - async def test_dispatch_one(self): callback_mock = AsyncMock() lookup_mock = MagicMock(return_value=callback_mock) topic = "TicketAdded" - event = Event(topic, FAKE_AGGREGATE_DIFF) + event = PublishRequest(topic, FAKE_AGGREGATE_DIFF) entry = HandlerEntry(1, topic, 0, event.avro_bytes, 1, callback_lookup=lookup_mock) async with self.handler: @@ -130,11 +127,11 @@ async def _fn2(request): for i in range(1, 6): events.extend( [ - Event( + PublishRequest( "TicketAdded", AggregateDiff(uuid1, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), ), - Event( + PublishRequest( "TicketAdded", AggregateDiff(uuid2, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), ), diff --git a/tests/test_networks/test_handlers/test_messages.py b/tests/test_networks/test_handlers/test_messages.py index d5411717..776c8a69 100644 --- a/tests/test_networks/test_handlers/test_messages.py +++ b/tests/test_networks/test_handlers/test_messages.py @@ -3,12 +3,10 @@ uuid4, ) -from minos.common import ( - Command, -) from minos.networks import ( HandlerRequest, HandlerResponse, + PublishRequest, ) from tests.utils import ( FakeModel, @@ -19,38 +17,38 @@ class TestHandlerRequest(unittest.IsolatedAsyncioTestCase): def setUp(self) -> None: self.data = [FakeModel("foo"), FakeModel("bar")] self.saga = uuid4() - self.command = Command("FooCreated", self.data, self.saga, "AddOrderReply") + self.raw = PublishRequest("FooCreated", self.data, self.saga, "AddOrderReply") def test_repr(self): - request = HandlerRequest(self.command) - expected = f"HandlerRequest({self.command!r})" + request = HandlerRequest(self.raw) + expected = f"HandlerRequest({self.raw!r})" self.assertEqual(expected, repr(request)) def test_eq_true(self): - self.assertEqual(HandlerRequest(self.command), HandlerRequest(self.command)) + self.assertEqual(HandlerRequest(self.raw), HandlerRequest(self.raw)) def test_eq_false(self): - another = HandlerRequest(Command("FooUpdated", self.data, self.saga, "AddOrderReply")) - self.assertNotEqual(HandlerRequest(self.command), another) + another = HandlerRequest(PublishRequest("FooUpdated", self.data, self.saga, "AddOrderReply")) + self.assertNotEqual(HandlerRequest(self.raw), another) def test_no_user(self): - request = HandlerRequest(self.command) + request = HandlerRequest(self.raw) self.assertEqual(None, request.user) def test_command(self): - request = HandlerRequest(self.command) - self.assertEqual(self.command, request.raw) + request = HandlerRequest(self.raw) + self.assertEqual(self.raw, request.raw) async def test_content(self): - request = HandlerRequest(self.command) + request = HandlerRequest(self.raw) self.assertEqual(self.data, await request.content()) async def test_content_single(self): - request = HandlerRequest(Command("FooCreated", self.data[0], self.saga, "AddOrderReply")) + request = HandlerRequest(PublishRequest("FooCreated", self.data[0], self.saga, "AddOrderReply")) self.assertEqual(self.data[0], await request.content()) async def test_content_simple(self): - request = HandlerRequest(Command("FooCreated", 1234, self.saga, "AddOrderReply")) + request = HandlerRequest(PublishRequest("FooCreated", 1234, self.saga, "AddOrderReply")) self.assertEqual(1234, await request.content()) diff --git a/tests/utils.py b/tests/utils.py index 3b19c1b0..a0273084 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -32,8 +32,6 @@ InMemoryTransactionRepository, ) from minos.common import ( - CommandReply, - CommandStatus, Lock, MinosBroker, MinosModel, @@ -43,6 +41,7 @@ ) from minos.networks import ( EnrouteDecorator, + PublishResponseStatus, Request, Response, WrappedRequest, @@ -187,7 +186,7 @@ class FakeSagaManager(MinosSagaManager): async def _run_new(self, name: str, **kwargs) -> None: """For testing purposes.""" - async def _load_and_run(self, reply: CommandReply, **kwargs) -> None: + async def _load_and_run(self, reply, **kwargs) -> None: """For testing purposes.""" @@ -199,7 +198,7 @@ def __init__(self): self.call_count = 0 self.items = None self.topic = None - self.saga = None + self.identifier = None self.reply_topic = None self.status = None @@ -209,14 +208,14 @@ async def send( topic: str = None, saga: str = None, reply_topic: str = None, - status: CommandStatus = None, + status: PublishResponseStatus = None, **kwargs, ) -> None: """For testing purposes.""" self.call_count += 1 self.items = items self.topic = topic - self.saga = saga + self.identifier = saga self.reply_topic = reply_topic self.status = status From 7f43180c96ee8e2796f8a8f6b2c547b8d2a5fde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Wed, 10 Nov 2021 12:35:21 +0100 Subject: [PATCH 02/24] ISSUE #434 * Refactor `minos.networks.brokers` structure. --- minos/networks/__init__.py | 41 ++++++++----------- minos/networks/brokers/__init__.py | 38 +++++++++++------ .../messages.py} | 34 +++++++-------- minos/networks/brokers/publishers/__init__.py | 19 +++++++++ .../networks/brokers/{ => publishers}/abc.py | 0 .../{ => publishers}/command_replies.py | 10 ++--- .../brokers/{ => publishers}/commands.py | 13 ++---- .../brokers/{ => publishers}/events.py | 6 +-- .../brokers/{ => publishers}/producers.py | 8 ++-- .../brokers/{ => publishers}/services.py | 0 .../subscribers}/__init__.py | 0 .../subscribers}/abc/__init__.py | 0 .../subscribers}/abc/handlers.py | 4 +- .../subscribers}/abc/setups.py | 0 .../subscribers}/command_replies/__init__.py | 0 .../subscribers}/command_replies/handlers.py | 0 .../subscribers}/command_replies/services.py | 0 .../subscribers}/commands/__init__.py | 0 .../subscribers}/commands/handlers.py | 22 +++++----- .../subscribers}/commands/services.py | 0 .../subscribers}/consumers.py | 2 +- .../subscribers}/dynamic/__init__.py | 0 .../subscribers}/dynamic/handlers.py | 4 +- .../subscribers}/dynamic/pools.py | 2 +- .../subscribers}/entries.py | 0 .../subscribers}/events/__init__.py | 0 .../subscribers}/events/handlers.py | 16 ++++---- .../subscribers}/events/services.py | 0 .../subscribers}/messages.py | 7 +++- .../subscribers}/services.py | 0 tests/test_networks/test_brokers/__init__.py | 1 - .../test_publishers}/__init__.py | 0 .../{ => test_publishers}/test_abc.py | 0 .../test_command_replies.py | 19 ++++++--- .../{ => test_publishers}/test_commands.py | 21 +++++++--- .../{ => test_publishers}/test_events.py | 4 +- .../{ => test_publishers}/test_producers.py | 8 ++-- .../{ => test_publishers}/test_services.py | 0 .../test_subscribers}/__init__.py | 0 .../test_subscribers/test_abc}/__init__.py | 0 .../test_abc/test_handlers.py | 14 +++---- .../test_subscribers}/test_abc/test_setups.py | 0 .../test_command_replies}/__init__.py | 0 .../test_command_replies/test_handlers.py | 12 ++++-- .../test_command_replies/test_services.py | 0 .../test_commands}/__init__.py | 0 .../test_commands/test_handlers.py | 16 ++++---- .../test_commands/test_services.py | 0 .../test_subscribers}/test_consumers.py | 0 .../test_dynamic}/__init__.py | 0 .../test_dynamic/test_handlers.py | 0 .../test_dynamic/test_pools.py | 0 .../test_subscribers/test_events/__init__.py | 1 + .../test_events/test_handlers.py | 10 ++--- .../test_events/test_services.py | 0 .../test_subscribers}/test_messages.py | 14 ++++--- .../test_subscribers}/test_services.py | 0 tests/utils.py | 4 +- 58 files changed, 200 insertions(+), 150 deletions(-) rename minos/networks/{broker_messages.py => brokers/messages.py} (56%) create mode 100644 minos/networks/brokers/publishers/__init__.py rename minos/networks/brokers/{ => publishers}/abc.py (100%) rename minos/networks/brokers/{ => publishers}/command_replies.py (84%) rename minos/networks/brokers/{ => publishers}/commands.py (86%) rename minos/networks/brokers/{ => publishers}/events.py (90%) rename minos/networks/brokers/{ => publishers}/producers.py (99%) rename minos/networks/brokers/{ => publishers}/services.py (100%) rename minos/networks/{handlers => brokers/subscribers}/__init__.py (100%) rename minos/networks/{handlers => brokers/subscribers}/abc/__init__.py (100%) rename minos/networks/{handlers => brokers/subscribers}/abc/handlers.py (99%) rename minos/networks/{handlers => brokers/subscribers}/abc/setups.py (100%) rename minos/networks/{handlers => brokers/subscribers}/command_replies/__init__.py (100%) rename minos/networks/{handlers => brokers/subscribers}/command_replies/handlers.py (100%) rename minos/networks/{handlers => brokers/subscribers}/command_replies/services.py (100%) rename minos/networks/{handlers => brokers/subscribers}/commands/__init__.py (100%) rename minos/networks/{handlers => brokers/subscribers}/commands/handlers.py (86%) rename minos/networks/{handlers => brokers/subscribers}/commands/services.py (100%) rename minos/networks/{handlers => brokers/subscribers}/consumers.py (99%) rename minos/networks/{handlers => brokers/subscribers}/dynamic/__init__.py (100%) rename minos/networks/{handlers => brokers/subscribers}/dynamic/handlers.py (98%) rename minos/networks/{handlers => brokers/subscribers}/dynamic/pools.py (99%) rename minos/networks/{handlers => brokers/subscribers}/entries.py (100%) rename minos/networks/{handlers => brokers/subscribers}/events/__init__.py (100%) rename minos/networks/{handlers => brokers/subscribers}/events/handlers.py (93%) rename minos/networks/{handlers => brokers/subscribers}/events/services.py (100%) rename minos/networks/{handlers => brokers/subscribers}/messages.py (92%) rename minos/networks/{handlers => brokers/subscribers}/services.py (100%) rename tests/test_networks/{test_handlers/test_abc => test_brokers/test_publishers}/__init__.py (100%) rename tests/test_networks/test_brokers/{ => test_publishers}/test_abc.py (100%) rename tests/test_networks/test_brokers/{ => test_publishers}/test_command_replies.py (76%) rename tests/test_networks/test_brokers/{ => test_publishers}/test_commands.py (80%) rename tests/test_networks/test_brokers/{ => test_publishers}/test_events.py (89%) rename tests/test_networks/test_brokers/{ => test_publishers}/test_producers.py (97%) rename tests/test_networks/test_brokers/{ => test_publishers}/test_services.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/__init__.py (100%) rename tests/test_networks/{test_handlers/test_command_replies => test_brokers/test_subscribers/test_abc}/__init__.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_abc/test_handlers.py (94%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_abc/test_setups.py (100%) rename tests/test_networks/{test_handlers/test_commands => test_brokers/test_subscribers/test_command_replies}/__init__.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_command_replies/test_handlers.py (88%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_command_replies/test_services.py (100%) rename tests/test_networks/{test_handlers/test_dynamic => test_brokers/test_subscribers/test_commands}/__init__.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_commands/test_handlers.py (87%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_commands/test_services.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_consumers.py (100%) rename tests/test_networks/{test_handlers/test_events => test_brokers/test_subscribers/test_dynamic}/__init__.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_dynamic/test_handlers.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_dynamic/test_pools.py (100%) create mode 100644 tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_events/test_handlers.py (95%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_events/test_services.py (100%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_messages.py (76%) rename tests/test_networks/{test_handlers => test_brokers/test_subscribers}/test_services.py (100%) diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index a1f90368..f74faf2a 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -2,18 +2,31 @@ __email__ = "devs@clariteia.com" __version__ = "0.1.1" -from .broker_messages import ( - PublishRequest, - PublishResponse, - PublishResponseStatus, -) from .brokers import ( REPLY_TOPIC_CONTEXT_VAR, Broker, + BrokerMessage, + BrokerMessageStatus, BrokerSetup, CommandBroker, + CommandHandler, + CommandHandlerService, CommandReplyBroker, + CommandReplyHandler, + CommandReplyHandlerService, + Consumer, + ConsumerService, + DynamicHandler, + DynamicHandlerPool, EventBroker, + EventHandler, + EventHandlerService, + Handler, + HandlerEntry, + HandlerRequest, + HandlerResponse, + HandlerResponseException, + HandlerSetup, Producer, ProducerService, ) @@ -49,24 +62,6 @@ MinosNetworkException, MinosRedefinedEnrouteDecoratorException, ) -from .handlers import ( - CommandHandler, - CommandHandlerService, - CommandReplyHandler, - CommandReplyHandlerService, - Consumer, - ConsumerService, - DynamicHandler, - DynamicHandlerPool, - EventHandler, - EventHandlerService, - Handler, - HandlerEntry, - HandlerRequest, - HandlerResponse, - HandlerResponseException, - HandlerSetup, -) from .messages import ( USER_CONTEXT_VAR, Request, diff --git a/minos/networks/brokers/__init__.py b/minos/networks/brokers/__init__.py index 8980aa9e..6365d8c3 100644 --- a/minos/networks/brokers/__init__.py +++ b/minos/networks/brokers/__init__.py @@ -1,20 +1,32 @@ -from .abc import ( +from .messages import ( + REPLY_TOPIC_CONTEXT_VAR, + BrokerMessage, + BrokerMessageStatus, +) +from .publishers import ( Broker, BrokerSetup, -) -from .command_replies import ( - CommandReplyBroker, -) -from .commands import ( - REPLY_TOPIC_CONTEXT_VAR, CommandBroker, -) -from .events import ( + CommandReplyBroker, EventBroker, -) -from .producers import ( Producer, -) -from .services import ( ProducerService, ) +from .subscribers import ( + CommandHandler, + CommandHandlerService, + CommandReplyHandler, + CommandReplyHandlerService, + Consumer, + ConsumerService, + DynamicHandler, + DynamicHandlerPool, + EventHandler, + EventHandlerService, + Handler, + HandlerEntry, + HandlerRequest, + HandlerResponse, + HandlerResponseException, + HandlerSetup, +) diff --git a/minos/networks/broker_messages.py b/minos/networks/brokers/messages.py similarity index 56% rename from minos/networks/broker_messages.py rename to minos/networks/brokers/messages.py index 543c000b..263ba8e0 100644 --- a/minos/networks/broker_messages.py +++ b/minos/networks/brokers/messages.py @@ -2,11 +2,15 @@ annotations, ) +from contextvars import ( + ContextVar, +) from enum import ( IntEnum, ) from typing import ( Any, + Final, Optional, ) from uuid import ( @@ -17,46 +21,42 @@ DeclarativeModel, ) +REPLY_TOPIC_CONTEXT_VAR: Final[ContextVar[Optional[str]]] = ContextVar("reply_topic", default=None) + -class PublishRequest(DeclarativeModel): - """Publish request class.""" +class BrokerMessage(DeclarativeModel): + """Broker Message class.""" topic: str data: Any identifier: Optional[UUID] reply_topic: Optional[str] user: Optional[UUID] + status: Optional[BrokerMessageStatus] + service_name: Optional[str] def __init__( self, topic: str, data: Any, + *, identifier: Optional[UUID] = None, reply_topic: Optional[str] = None, user: Optional[UUID] = None, - *args, + status: Optional[BrokerMessageStatus] = None, + service_name: Optional[str] = None, **kwargs ): - super().__init__(topic, data, identifier, reply_topic, user, *args, **kwargs) - - -class PublishResponse(DeclarativeModel): - """Publish response class.""" - - topic: str - data: Any - identifier: Optional[UUID] - status: PublishResponseStatus - service_name: str + super().__init__(topic, data, identifier, reply_topic, user, status, service_name, **kwargs) @property def ok(self) -> bool: """TODO""" - return self.status == PublishResponseStatus.SUCCESS + return self.status == BrokerMessageStatus.SUCCESS -class PublishResponseStatus(IntEnum): - """Publish status class.""" +class BrokerMessageStatus(IntEnum): + """Broker status class.""" SUCCESS = 200 ERROR = 400 diff --git a/minos/networks/brokers/publishers/__init__.py b/minos/networks/brokers/publishers/__init__.py new file mode 100644 index 00000000..af2120b4 --- /dev/null +++ b/minos/networks/brokers/publishers/__init__.py @@ -0,0 +1,19 @@ +from .abc import ( + Broker, + BrokerSetup, +) +from .command_replies import ( + CommandReplyBroker, +) +from .commands import ( + CommandBroker, +) +from .events import ( + EventBroker, +) +from .producers import ( + Producer, +) +from .services import ( + ProducerService, +) diff --git a/minos/networks/brokers/abc.py b/minos/networks/brokers/publishers/abc.py similarity index 100% rename from minos/networks/brokers/abc.py rename to minos/networks/brokers/publishers/abc.py diff --git a/minos/networks/brokers/command_replies.py b/minos/networks/brokers/publishers/command_replies.py similarity index 84% rename from minos/networks/brokers/command_replies.py rename to minos/networks/brokers/publishers/command_replies.py index 03b0f2c7..842f4dee 100644 --- a/minos/networks/brokers/command_replies.py +++ b/minos/networks/brokers/publishers/command_replies.py @@ -14,9 +14,9 @@ MinosConfig, ) -from ..broker_messages import ( - PublishResponse, - PublishResponseStatus, +from ..messages import ( + BrokerMessage, + BrokerMessageStatus, ) from .abc import ( Broker, @@ -39,7 +39,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyBroke return cls(*args, service_name=config.service.name, **config.broker.queue._asdict(), **kwargs) # noinspection PyMethodOverriding - async def send(self, data: Any, topic: str, saga: UUID, status: PublishResponseStatus, **kwargs) -> int: + async def send(self, data: Any, topic: str, saga: UUID, status: BrokerMessageStatus, **kwargs) -> int: """Send a ``CommandReply``. :param data: The data to be send. @@ -49,6 +49,6 @@ async def send(self, data: Any, topic: str, saga: UUID, status: PublishResponseS :return: This method does not return anything. """ - request = PublishResponse(topic, data, saga, status, self.service_name) + request = BrokerMessage(topic, data, identifier=saga, status=status, service_name=self.service_name) logger.info(f"Sending '{request!s}'...") return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/brokers/commands.py b/minos/networks/brokers/publishers/commands.py similarity index 86% rename from minos/networks/brokers/commands.py rename to minos/networks/brokers/publishers/commands.py index c613925c..718d68ab 100644 --- a/minos/networks/brokers/commands.py +++ b/minos/networks/brokers/publishers/commands.py @@ -3,12 +3,8 @@ ) import logging -from contextvars import ( - ContextVar, -) from typing import ( Any, - Final, Optional, ) from uuid import ( @@ -19,8 +15,9 @@ MinosConfig, ) -from ..broker_messages import ( - PublishRequest, +from ..messages import ( + REPLY_TOPIC_CONTEXT_VAR, + BrokerMessage, ) from .abc import ( Broker, @@ -28,8 +25,6 @@ logger = logging.getLogger(__name__) -REPLY_TOPIC_CONTEXT_VAR: Final[ContextVar[Optional[str]]] = ContextVar("reply_topic", default=None) - class CommandBroker(Broker): """Minos Command Broker Class.""" @@ -70,6 +65,6 @@ async def send( if reply_topic is None: reply_topic = self.default_reply_topic - request = PublishRequest(topic, data, saga, reply_topic, user) + request = BrokerMessage(topic, data, identifier=saga, reply_topic=reply_topic, user=user) logger.info(f"Sending '{request!s}'...") return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/brokers/events.py b/minos/networks/brokers/publishers/events.py similarity index 90% rename from minos/networks/brokers/events.py rename to minos/networks/brokers/publishers/events.py index d262937d..0629e2fe 100644 --- a/minos/networks/brokers/events.py +++ b/minos/networks/brokers/publishers/events.py @@ -11,8 +11,8 @@ MinosConfig, ) -from ..broker_messages import ( - PublishRequest, +from ..messages import ( + BrokerMessage, ) from .abc import ( Broker, @@ -38,6 +38,6 @@ async def send(self, data: AggregateDiff, topic: str, **kwargs) -> int: :param topic: Topic in which the message will be published. :return: This method does not return anything. """ - request = PublishRequest(topic, data) + request = BrokerMessage(topic, data) logger.info(f"Sending '{request!s}'...") return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/brokers/producers.py b/minos/networks/brokers/publishers/producers.py similarity index 99% rename from minos/networks/brokers/producers.py rename to minos/networks/brokers/publishers/producers.py index 6be4290d..75d41a8d 100644 --- a/minos/networks/brokers/producers.py +++ b/minos/networks/brokers/publishers/producers.py @@ -34,12 +34,12 @@ MinosConfig, ) -from ..handlers import ( - Consumer, -) -from ..utils import ( +from ...utils import ( consume_queue, ) +from ..subscribers import ( + Consumer, +) from .abc import ( BrokerSetup, ) diff --git a/minos/networks/brokers/services.py b/minos/networks/brokers/publishers/services.py similarity index 100% rename from minos/networks/brokers/services.py rename to minos/networks/brokers/publishers/services.py diff --git a/minos/networks/handlers/__init__.py b/minos/networks/brokers/subscribers/__init__.py similarity index 100% rename from minos/networks/handlers/__init__.py rename to minos/networks/brokers/subscribers/__init__.py diff --git a/minos/networks/handlers/abc/__init__.py b/minos/networks/brokers/subscribers/abc/__init__.py similarity index 100% rename from minos/networks/handlers/abc/__init__.py rename to minos/networks/brokers/subscribers/abc/__init__.py diff --git a/minos/networks/handlers/abc/handlers.py b/minos/networks/brokers/subscribers/abc/handlers.py similarity index 99% rename from minos/networks/handlers/abc/handlers.py rename to minos/networks/brokers/subscribers/abc/handlers.py index 64c267c7..9ed4de4e 100644 --- a/minos/networks/handlers/abc/handlers.py +++ b/minos/networks/brokers/subscribers/abc/handlers.py @@ -30,10 +30,10 @@ Identifier, ) -from ...exceptions import ( +from ....exceptions import ( MinosActionNotFoundException, ) -from ...utils import ( +from ....utils import ( consume_queue, ) from ..entries import ( diff --git a/minos/networks/handlers/abc/setups.py b/minos/networks/brokers/subscribers/abc/setups.py similarity index 100% rename from minos/networks/handlers/abc/setups.py rename to minos/networks/brokers/subscribers/abc/setups.py diff --git a/minos/networks/handlers/command_replies/__init__.py b/minos/networks/brokers/subscribers/command_replies/__init__.py similarity index 100% rename from minos/networks/handlers/command_replies/__init__.py rename to minos/networks/brokers/subscribers/command_replies/__init__.py diff --git a/minos/networks/handlers/command_replies/handlers.py b/minos/networks/brokers/subscribers/command_replies/handlers.py similarity index 100% rename from minos/networks/handlers/command_replies/handlers.py rename to minos/networks/brokers/subscribers/command_replies/handlers.py diff --git a/minos/networks/handlers/command_replies/services.py b/minos/networks/brokers/subscribers/command_replies/services.py similarity index 100% rename from minos/networks/handlers/command_replies/services.py rename to minos/networks/brokers/subscribers/command_replies/services.py diff --git a/minos/networks/handlers/commands/__init__.py b/minos/networks/brokers/subscribers/commands/__init__.py similarity index 100% rename from minos/networks/handlers/commands/__init__.py rename to minos/networks/brokers/subscribers/commands/__init__.py diff --git a/minos/networks/handlers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py similarity index 86% rename from minos/networks/handlers/commands/handlers.py rename to minos/networks/brokers/subscribers/commands/handlers.py index cc091ed2..551b6830 100644 --- a/minos/networks/handlers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -25,18 +25,18 @@ MinosConfig, ) -from ...broker_messages import ( - PublishRequest, - PublishResponseStatus, -) -from ...decorators import ( +from ....decorators import ( EnrouteBuilder, ) -from ...messages import ( +from ....messages import ( USER_CONTEXT_VAR, Response, ResponseException, ) +from ...messages import ( + BrokerMessage, + BrokerMessageStatus, +) from ..abc import ( Handler, ) @@ -88,14 +88,14 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: @staticmethod def get_callback( fn: Callable[[HandlerRequest], Union[Optional[HandlerRequest], Awaitable[Optional[HandlerRequest]]]] - ) -> Callable[[PublishRequest], Awaitable[Tuple[Any, PublishResponseStatus]]]: + ) -> Callable[[BrokerMessage], Awaitable[Tuple[Any, BrokerMessageStatus]]]: """Get the handler function to be used by the Command Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Command Handler API. """ - async def _fn(raw: PublishRequest) -> Tuple[Any, PublishResponseStatus]: + async def _fn(raw: BrokerMessage) -> Tuple[Any, BrokerMessageStatus]: request = HandlerRequest(raw) token = USER_CONTEXT_VAR.set(request.user) @@ -105,13 +105,13 @@ async def _fn(raw: PublishRequest) -> Tuple[Any, PublishResponseStatus]: response = await response if isinstance(response, Response): response = await response.content() - return response, PublishResponseStatus.SUCCESS + return response, BrokerMessageStatus.SUCCESS except ResponseException as exc: logger.warning(f"Raised an application exception: {exc!s}") - return repr(exc), PublishResponseStatus.ERROR + return repr(exc), BrokerMessageStatus.ERROR except Exception as exc: logger.exception(f"Raised a system exception: {exc!r}") - return repr(exc), PublishResponseStatus.SYSTEM_ERROR + return repr(exc), BrokerMessageStatus.SYSTEM_ERROR finally: USER_CONTEXT_VAR.reset(token) diff --git a/minos/networks/handlers/commands/services.py b/minos/networks/brokers/subscribers/commands/services.py similarity index 100% rename from minos/networks/handlers/commands/services.py rename to minos/networks/brokers/subscribers/commands/services.py diff --git a/minos/networks/handlers/consumers.py b/minos/networks/brokers/subscribers/consumers.py similarity index 99% rename from minos/networks/handlers/consumers.py rename to minos/networks/brokers/subscribers/consumers.py index b18ceb48..351531c1 100644 --- a/minos/networks/handlers/consumers.py +++ b/minos/networks/brokers/subscribers/consumers.py @@ -28,7 +28,7 @@ MinosConfig, ) -from ..decorators import ( +from ...decorators import ( EnrouteAnalyzer, ) from .abc import ( diff --git a/minos/networks/handlers/dynamic/__init__.py b/minos/networks/brokers/subscribers/dynamic/__init__.py similarity index 100% rename from minos/networks/handlers/dynamic/__init__.py rename to minos/networks/brokers/subscribers/dynamic/__init__.py diff --git a/minos/networks/handlers/dynamic/handlers.py b/minos/networks/brokers/subscribers/dynamic/handlers.py similarity index 98% rename from minos/networks/handlers/dynamic/handlers.py rename to minos/networks/brokers/subscribers/dynamic/handlers.py index a2664334..e1b04dd9 100644 --- a/minos/networks/handlers/dynamic/handlers.py +++ b/minos/networks/brokers/subscribers/dynamic/handlers.py @@ -26,10 +26,10 @@ MinosConfig, ) -from ...exceptions import ( +from ....exceptions import ( MinosHandlerNotFoundEnoughEntriesException, ) -from ...utils import ( +from ....utils import ( consume_queue, ) from ..abc import ( diff --git a/minos/networks/handlers/dynamic/pools.py b/minos/networks/brokers/subscribers/dynamic/pools.py similarity index 99% rename from minos/networks/handlers/dynamic/pools.py rename to minos/networks/brokers/subscribers/dynamic/pools.py index 6cbd6b6c..51022371 100644 --- a/minos/networks/handlers/dynamic/pools.py +++ b/minos/networks/brokers/subscribers/dynamic/pools.py @@ -30,7 +30,7 @@ MinosPool, ) -from ...brokers import ( +from ...messages import ( REPLY_TOPIC_CONTEXT_VAR, ) from ..consumers import ( diff --git a/minos/networks/handlers/entries.py b/minos/networks/brokers/subscribers/entries.py similarity index 100% rename from minos/networks/handlers/entries.py rename to minos/networks/brokers/subscribers/entries.py diff --git a/minos/networks/handlers/events/__init__.py b/minos/networks/brokers/subscribers/events/__init__.py similarity index 100% rename from minos/networks/handlers/events/__init__.py rename to minos/networks/brokers/subscribers/events/__init__.py diff --git a/minos/networks/handlers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py similarity index 93% rename from minos/networks/handlers/events/handlers.py rename to minos/networks/brokers/subscribers/events/handlers.py index 9984336f..d0970076 100644 --- a/minos/networks/handlers/events/handlers.py +++ b/minos/networks/brokers/subscribers/events/handlers.py @@ -25,12 +25,15 @@ MinosConfig, ) -from ...broker_messages import ( - PublishRequest, -) -from ...decorators import ( +from ....decorators import ( EnrouteBuilder, ) +from ....messages import ( + ResponseException, +) +from ...messages import ( + BrokerMessage, +) from ..abc import ( Handler, ) @@ -39,7 +42,6 @@ ) from ..messages import ( HandlerRequest, - ResponseException, ) logger = logging.getLogger(__name__) @@ -93,14 +95,14 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: @staticmethod def get_callback( fn: Callable[[HandlerRequest], Optional[Awaitable[None]]] - ) -> Callable[[PublishRequest], Awaitable[None]]: + ) -> Callable[[BrokerMessage], Awaitable[None]]: """Get the handler function to be used by the Event Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Event Handler API. """ - async def _fn(raw: PublishRequest) -> None: + async def _fn(raw: BrokerMessage) -> None: try: request = HandlerRequest(raw) response = fn(request) diff --git a/minos/networks/handlers/events/services.py b/minos/networks/brokers/subscribers/events/services.py similarity index 100% rename from minos/networks/handlers/events/services.py rename to minos/networks/brokers/subscribers/events/services.py diff --git a/minos/networks/handlers/messages.py b/minos/networks/brokers/subscribers/messages.py similarity index 92% rename from minos/networks/handlers/messages.py rename to minos/networks/brokers/subscribers/messages.py index 91a8be26..1cca0f83 100644 --- a/minos/networks/handlers/messages.py +++ b/minos/networks/brokers/subscribers/messages.py @@ -10,11 +10,14 @@ UUID, ) -from ..messages import ( +from ...messages import ( Request, Response, ResponseException, ) +from ..messages import ( + BrokerMessage, +) class HandlerRequest(Request): @@ -22,7 +25,7 @@ class HandlerRequest(Request): __slots__ = "raw" - def __init__(self, raw: Any): + def __init__(self, raw: BrokerMessage): self.raw = raw def __eq__(self, other: HandlerRequest) -> bool: diff --git a/minos/networks/handlers/services.py b/minos/networks/brokers/subscribers/services.py similarity index 100% rename from minos/networks/handlers/services.py rename to minos/networks/brokers/subscribers/services.py diff --git a/tests/test_networks/test_brokers/__init__.py b/tests/test_networks/test_brokers/__init__.py index 8b137891..e69de29b 100644 --- a/tests/test_networks/test_brokers/__init__.py +++ b/tests/test_networks/test_brokers/__init__.py @@ -1 +0,0 @@ - diff --git a/tests/test_networks/test_handlers/test_abc/__init__.py b/tests/test_networks/test_brokers/test_publishers/__init__.py similarity index 100% rename from tests/test_networks/test_handlers/test_abc/__init__.py rename to tests/test_networks/test_brokers/test_publishers/__init__.py diff --git a/tests/test_networks/test_brokers/test_abc.py b/tests/test_networks/test_brokers/test_publishers/test_abc.py similarity index 100% rename from tests/test_networks/test_brokers/test_abc.py rename to tests/test_networks/test_brokers/test_publishers/test_abc.py diff --git a/tests/test_networks/test_brokers/test_command_replies.py b/tests/test_networks/test_brokers/test_publishers/test_command_replies.py similarity index 76% rename from tests/test_networks/test_brokers/test_command_replies.py rename to tests/test_networks/test_brokers/test_publishers/test_command_replies.py index d39277db..fecda921 100644 --- a/tests/test_networks/test_brokers/test_command_replies.py +++ b/tests/test_networks/test_brokers/test_publishers/test_command_replies.py @@ -6,13 +6,16 @@ uuid4, ) +from minos.common import ( + Model, +) from minos.common.testing import ( PostgresAsyncTestCase, ) from minos.networks import ( + BrokerMessage, + BrokerMessageStatus, CommandReplyBroker, - PublishResponse, - PublishResponseStatus, ) from tests.utils import ( BASE_PATH, @@ -37,7 +40,7 @@ async def test_send(self): async with CommandReplyBroker.from_config(config=self.config) as broker: broker.enqueue = mock identifier = await broker.send( - FakeModel("foo"), saga=saga, topic=reply_topic, status=PublishResponseStatus.SUCCESS + FakeModel("foo"), saga=saga, topic=reply_topic, status=BrokerMessageStatus.SUCCESS ) self.assertEqual(56, identifier) @@ -46,10 +49,14 @@ async def test_send(self): args = mock.call_args.args self.assertEqual(reply_topic, args[0]) - expected = PublishResponse( - reply_topic, FakeModel("foo"), saga, PublishResponseStatus.SUCCESS, self.config.service.name + expected = BrokerMessage( + reply_topic, + FakeModel("foo"), + identifier=saga, + status=BrokerMessageStatus.SUCCESS, + service_name=self.config.service.name, ) - observed = PublishResponse.from_avro_bytes(args[1]) + observed = Model.from_avro_bytes(args[1]) self.assertEqual(expected, observed) diff --git a/tests/test_networks/test_brokers/test_commands.py b/tests/test_networks/test_brokers/test_publishers/test_commands.py similarity index 80% rename from tests/test_networks/test_brokers/test_commands.py rename to tests/test_networks/test_brokers/test_publishers/test_commands.py index cb629fd5..50af26c0 100644 --- a/tests/test_networks/test_brokers/test_commands.py +++ b/tests/test_networks/test_brokers/test_publishers/test_commands.py @@ -14,8 +14,8 @@ ) from minos.networks import ( REPLY_TOPIC_CONTEXT_VAR, + BrokerMessage, CommandBroker, - PublishRequest, ) from tests.utils import ( BASE_PATH, @@ -50,7 +50,9 @@ async def test_send(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "ekaf"), Model.from_avro_bytes(args[1])) + self.assertEqual( + BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="ekaf"), Model.from_avro_bytes(args[1]) + ) async def test_send_with_default_reply_topic(self): mock = AsyncMock(return_value=56) @@ -65,7 +67,10 @@ async def test_send_with_default_reply_topic(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "OrderReply"), Model.from_avro_bytes(args[1])) + self.assertEqual( + BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="OrderReply"), + Model.from_avro_bytes(args[1]), + ) async def test_send_with_reply_topic_context_var(self): mock = AsyncMock(return_value=56) @@ -82,7 +87,10 @@ async def test_send_with_reply_topic_context_var(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "onetwothree"), Model.from_avro_bytes(args[1])) + self.assertEqual( + BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="onetwothree"), + Model.from_avro_bytes(args[1]), + ) async def test_send_with_user(self): mock = AsyncMock(return_value=56) @@ -98,7 +106,10 @@ async def test_send_with_user(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(PublishRequest("fake", FakeModel("foo"), saga, "ekaf", user), Model.from_avro_bytes(args[1])) + self.assertEqual( + BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="ekaf", user=user), + Model.from_avro_bytes(args[1]), + ) if __name__ == "__main__": diff --git a/tests/test_networks/test_brokers/test_events.py b/tests/test_networks/test_brokers/test_publishers/test_events.py similarity index 89% rename from tests/test_networks/test_brokers/test_events.py rename to tests/test_networks/test_brokers/test_publishers/test_events.py index 51285171..e4309a54 100644 --- a/tests/test_networks/test_brokers/test_events.py +++ b/tests/test_networks/test_brokers/test_publishers/test_events.py @@ -10,8 +10,8 @@ PostgresAsyncTestCase, ) from minos.networks import ( + BrokerMessage, EventBroker, - PublishRequest, ) from tests.utils import ( BASE_PATH, @@ -39,7 +39,7 @@ async def test_send(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(PublishRequest("fake", FAKE_AGGREGATE_DIFF), Model.from_avro_bytes(args[1])) + self.assertEqual(BrokerMessage("fake", FAKE_AGGREGATE_DIFF), Model.from_avro_bytes(args[1])) if __name__ == "__main__": diff --git a/tests/test_networks/test_brokers/test_producers.py b/tests/test_networks/test_brokers/test_publishers/test_producers.py similarity index 97% rename from tests/test_networks/test_brokers/test_producers.py rename to tests/test_networks/test_brokers/test_publishers/test_producers.py index 15431d69..72cc1149 100644 --- a/tests/test_networks/test_brokers/test_producers.py +++ b/tests/test_networks/test_brokers/test_publishers/test_producers.py @@ -18,12 +18,12 @@ PostgresAsyncTestCase, ) from minos.networks import ( + BrokerMessageStatus, CommandBroker, CommandReplyBroker, Consumer, EventBroker, Producer, - PublishResponseStatus, ) from tests.utils import ( BASE_PATH, @@ -138,7 +138,7 @@ async def test_concurrency_dispatcher(self): for x in range(0, 20): async with command_reply_broker: - await command_reply_broker.send(model, "TestDeleteReply", saga, PublishResponseStatus.SUCCESS) + await command_reply_broker.send(model, "TestDeleteReply", saga, BrokerMessageStatus.SUCCESS) async with command_broker: await command_broker.send(model, "CommandBroker-Delete", saga, "TestDeleteReply") @@ -185,8 +185,8 @@ async def test_if_commands_retry_was_incremented(self): saga = uuid4() async with CommandReplyBroker.from_config(config=self.config) as broker: - queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, PublishResponseStatus.SUCCESS) - queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, PublishResponseStatus.SUCCESS) + queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) + queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) async with self.producer: self.producer.publish = AsyncMock(return_value=False) diff --git a/tests/test_networks/test_brokers/test_services.py b/tests/test_networks/test_brokers/test_publishers/test_services.py similarity index 100% rename from tests/test_networks/test_brokers/test_services.py rename to tests/test_networks/test_brokers/test_publishers/test_services.py diff --git a/tests/test_networks/test_handlers/__init__.py b/tests/test_networks/test_brokers/test_subscribers/__init__.py similarity index 100% rename from tests/test_networks/test_handlers/__init__.py rename to tests/test_networks/test_brokers/test_subscribers/__init__.py diff --git a/tests/test_networks/test_handlers/test_command_replies/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_abc/__init__.py similarity index 100% rename from tests/test_networks/test_handlers/test_command_replies/__init__.py rename to tests/test_networks/test_brokers/test_subscribers/test_abc/__init__.py diff --git a/tests/test_networks/test_handlers/test_abc/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py similarity index 94% rename from tests/test_networks/test_handlers/test_abc/test_handlers.py rename to tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py index a70754b3..4796f88d 100644 --- a/tests/test_networks/test_handlers/test_abc/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py @@ -27,14 +27,12 @@ PostgresAsyncTestCase, ) from minos.networks import ( + BrokerMessage, EnrouteBuilder, Handler, + HandlerEntry, HandlerResponse, MinosActionNotFoundException, - PublishRequest, -) -from minos.networks.handlers import ( - HandlerEntry, ) from tests.utils import ( BASE_PATH, @@ -128,7 +126,7 @@ async def test_dispatch_forever_without_topics(self): self.assertEqual(0, mock.call_count) async def test_dispatch(self): - instance = PublishRequest("AddOrder", FAKE_AGGREGATE_DIFF) + instance = BrokerMessage("AddOrder", FAKE_AGGREGATE_DIFF) async with self.handler: queue_id = await self._insert_one(instance) @@ -139,8 +137,8 @@ async def test_dispatch(self): async def test_dispatch_wrong(self): instance_1 = namedtuple("FakeCommand", ("topic", "avro_bytes"))("AddOrder", bytes(b"Test")) - instance_2 = PublishRequest("DeleteOrder", FAKE_AGGREGATE_DIFF) - instance_3 = PublishRequest("NoActionTopic", FAKE_AGGREGATE_DIFF) + instance_2 = BrokerMessage("DeleteOrder", FAKE_AGGREGATE_DIFF) + instance_3 = BrokerMessage("NoActionTopic", FAKE_AGGREGATE_DIFF) async with self.handler: queue_id_1 = await self._insert_one(instance_1) @@ -158,7 +156,7 @@ async def test_dispatch_concurrent(self): saga = uuid4() - instance = PublishRequest("AddOrder", [FakeModel("foo")], saga, "UpdateTicket") + instance = BrokerMessage("AddOrder", [FakeModel("foo")], identifier=saga, reply_topic="UpdateTicket") instance_wrong = namedtuple("FakeCommand", ("topic", "avro_bytes"))("AddOrder", bytes(b"Test")) async with self.handler: diff --git a/tests/test_networks/test_handlers/test_abc/test_setups.py b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_setups.py similarity index 100% rename from tests/test_networks/test_handlers/test_abc/test_setups.py rename to tests/test_networks/test_brokers/test_subscribers/test_abc/test_setups.py diff --git a/tests/test_networks/test_handlers/test_commands/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py similarity index 100% rename from tests/test_networks/test_handlers/test_commands/__init__.py rename to tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py diff --git a/tests/test_networks/test_handlers/test_command_replies/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py similarity index 88% rename from tests/test_networks/test_handlers/test_command_replies/test_handlers.py rename to tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py index 2f62c3c6..a3b1dc09 100644 --- a/tests/test_networks/test_handlers/test_command_replies/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py @@ -11,10 +11,10 @@ PostgresAsyncTestCase, ) from minos.networks import ( + BrokerMessage, + BrokerMessageStatus, CommandReplyHandler, HandlerEntry, - PublishResponse, - PublishResponseStatus, ) from tests.utils import ( BASE_PATH, @@ -47,8 +47,12 @@ async def test_dispatch(self): saga_manager._load_and_run = mock saga = uuid4() - command = PublishResponse( - "TicketAdded", [FakeModel("foo")], saga, PublishResponseStatus.SUCCESS, self.config.service.name + command = BrokerMessage( + "TicketAdded", + [FakeModel("foo")], + identifier=saga, + status=BrokerMessageStatus.SUCCESS, + service_name=self.config.service.name, ) entry = HandlerEntry(1, "TicketAdded", 0, command.avro_bytes, 1) diff --git a/tests/test_networks/test_handlers/test_command_replies/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py similarity index 100% rename from tests/test_networks/test_handlers/test_command_replies/test_services.py rename to tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py diff --git a/tests/test_networks/test_handlers/test_dynamic/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_commands/__init__.py similarity index 100% rename from tests/test_networks/test_handlers/test_dynamic/__init__.py rename to tests/test_networks/test_brokers/test_subscribers/test_commands/__init__.py diff --git a/tests/test_networks/test_handlers/test_commands/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py similarity index 87% rename from tests/test_networks/test_handlers/test_commands/test_handlers.py rename to tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py index a8b3f353..3268f36e 100644 --- a/tests/test_networks/test_handlers/test_commands/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py @@ -13,13 +13,13 @@ ) from minos.networks import ( USER_CONTEXT_VAR, + BrokerMessage, + BrokerMessageStatus, CommandHandler, HandlerEntry, HandlerRequest, HandlerResponse, HandlerResponseException, - PublishRequest, - PublishResponseStatus, Request, Response, ) @@ -56,7 +56,7 @@ def setUp(self) -> None: self.broker = FakeBroker() self.handler = CommandHandler.from_config(config=self.config, broker=self.broker) self.user = uuid4() - self.request = PublishRequest("AddOrder", FakeModel("foo"), self.user, "UpdateTicket") + self.request = BrokerMessage("AddOrder", FakeModel("foo"), identifier=self.user, reply_topic="UpdateTicket") def test_from_config(self): broker = FakeBroker() @@ -89,7 +89,7 @@ async def test_dispatch(self): self.assertEqual("UpdateTicket", self.broker.topic) self.assertEqual(self.request.identifier, self.broker.identifier) self.assertEqual(None, self.broker.reply_topic) - self.assertEqual(PublishResponseStatus.SUCCESS, self.broker.status) + self.assertEqual(BrokerMessageStatus.SUCCESS, self.broker.status) self.assertEqual(1, callback_mock.call_count) observed = callback_mock.call_args[0][0] @@ -98,20 +98,20 @@ async def test_dispatch(self): async def test_get_callback(self): fn = self.handler.get_callback(_Cls._fn) - self.assertEqual((FakeModel("foo"), PublishResponseStatus.SUCCESS), await fn(self.request)) + self.assertEqual((FakeModel("foo"), BrokerMessageStatus.SUCCESS), await fn(self.request)) async def test_get_callback_none(self): fn = self.handler.get_callback(_Cls._fn_none) - self.assertEqual((None, PublishResponseStatus.SUCCESS), await fn(self.request)) + self.assertEqual((None, BrokerMessageStatus.SUCCESS), await fn(self.request)) async def test_get_callback_raises_response(self): fn = self.handler.get_callback(_Cls._fn_raises_response) - expected = (repr(HandlerResponseException("foo")), PublishResponseStatus.ERROR) + expected = (repr(HandlerResponseException("foo")), BrokerMessageStatus.ERROR) self.assertEqual(expected, await fn(self.request)) async def test_get_callback_raises_exception(self): fn = self.handler.get_callback(_Cls._fn_raises_exception) - expected = (repr(ValueError()), PublishResponseStatus.SYSTEM_ERROR) + expected = (repr(ValueError()), BrokerMessageStatus.SYSTEM_ERROR) self.assertEqual(expected, await fn(self.request)) async def test_get_callback_with_user(self): diff --git a/tests/test_networks/test_handlers/test_commands/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_services.py similarity index 100% rename from tests/test_networks/test_handlers/test_commands/test_services.py rename to tests/test_networks/test_brokers/test_subscribers/test_commands/test_services.py diff --git a/tests/test_networks/test_handlers/test_consumers.py b/tests/test_networks/test_brokers/test_subscribers/test_consumers.py similarity index 100% rename from tests/test_networks/test_handlers/test_consumers.py rename to tests/test_networks/test_brokers/test_subscribers/test_consumers.py diff --git a/tests/test_networks/test_handlers/test_events/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_dynamic/__init__.py similarity index 100% rename from tests/test_networks/test_handlers/test_events/__init__.py rename to tests/test_networks/test_brokers/test_subscribers/test_dynamic/__init__.py diff --git a/tests/test_networks/test_handlers/test_dynamic/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_dynamic/test_handlers.py similarity index 100% rename from tests/test_networks/test_handlers/test_dynamic/test_handlers.py rename to tests/test_networks/test_brokers/test_subscribers/test_dynamic/test_handlers.py diff --git a/tests/test_networks/test_handlers/test_dynamic/test_pools.py b/tests/test_networks/test_brokers/test_subscribers/test_dynamic/test_pools.py similarity index 100% rename from tests/test_networks/test_handlers/test_dynamic/test_pools.py rename to tests/test_networks/test_brokers/test_subscribers/test_dynamic/test_pools.py diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/test_networks/test_handlers/test_events/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py similarity index 95% rename from tests/test_networks/test_handlers/test_events/test_handlers.py rename to tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py index 830f4d86..785b8298 100644 --- a/tests/test_networks/test_handlers/test_events/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py @@ -28,11 +28,11 @@ PostgresAsyncTestCase, ) from minos.networks import ( + BrokerMessage, EventHandler, HandlerEntry, HandlerRequest, HandlerResponseException, - PublishRequest, Request, ) from tests.utils import ( @@ -61,7 +61,7 @@ class TestEventHandler(PostgresAsyncTestCase): def setUp(self) -> None: super().setUp() self.handler = EventHandler.from_config(config=self.config) - self.event = PublishRequest("TicketAdded", FAKE_AGGREGATE_DIFF) + self.event = BrokerMessage("TicketAdded", FAKE_AGGREGATE_DIFF) def test_from_config(self): self.assertIsInstance(self.handler, EventHandler) @@ -88,7 +88,7 @@ async def test_dispatch_one(self): lookup_mock = MagicMock(return_value=callback_mock) topic = "TicketAdded" - event = PublishRequest(topic, FAKE_AGGREGATE_DIFF) + event = BrokerMessage(topic, FAKE_AGGREGATE_DIFF) entry = HandlerEntry(1, topic, 0, event.avro_bytes, 1, callback_lookup=lookup_mock) async with self.handler: @@ -127,11 +127,11 @@ async def _fn2(request): for i in range(1, 6): events.extend( [ - PublishRequest( + BrokerMessage( "TicketAdded", AggregateDiff(uuid1, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), ), - PublishRequest( + BrokerMessage( "TicketAdded", AggregateDiff(uuid2, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), ), diff --git a/tests/test_networks/test_handlers/test_events/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py similarity index 100% rename from tests/test_networks/test_handlers/test_events/test_services.py rename to tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py diff --git a/tests/test_networks/test_handlers/test_messages.py b/tests/test_networks/test_brokers/test_subscribers/test_messages.py similarity index 76% rename from tests/test_networks/test_handlers/test_messages.py rename to tests/test_networks/test_brokers/test_subscribers/test_messages.py index 776c8a69..79c396eb 100644 --- a/tests/test_networks/test_handlers/test_messages.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_messages.py @@ -4,9 +4,9 @@ ) from minos.networks import ( + BrokerMessage, HandlerRequest, HandlerResponse, - PublishRequest, ) from tests.utils import ( FakeModel, @@ -17,7 +17,7 @@ class TestHandlerRequest(unittest.IsolatedAsyncioTestCase): def setUp(self) -> None: self.data = [FakeModel("foo"), FakeModel("bar")] self.saga = uuid4() - self.raw = PublishRequest("FooCreated", self.data, self.saga, "AddOrderReply") + self.raw = BrokerMessage("FooCreated", self.data, identifier=self.saga, reply_topic="AddOrderReply") def test_repr(self): request = HandlerRequest(self.raw) @@ -28,7 +28,9 @@ def test_eq_true(self): self.assertEqual(HandlerRequest(self.raw), HandlerRequest(self.raw)) def test_eq_false(self): - another = HandlerRequest(PublishRequest("FooUpdated", self.data, self.saga, "AddOrderReply")) + another = HandlerRequest( + BrokerMessage("FooUpdated", self.data, identifier=self.saga, reply_topic="AddOrderReply") + ) self.assertNotEqual(HandlerRequest(self.raw), another) def test_no_user(self): @@ -44,11 +46,13 @@ async def test_content(self): self.assertEqual(self.data, await request.content()) async def test_content_single(self): - request = HandlerRequest(PublishRequest("FooCreated", self.data[0], self.saga, "AddOrderReply")) + request = HandlerRequest( + BrokerMessage("FooCreated", self.data[0], identifier=self.saga, reply_topic="AddOrderReply") + ) self.assertEqual(self.data[0], await request.content()) async def test_content_simple(self): - request = HandlerRequest(PublishRequest("FooCreated", 1234, self.saga, "AddOrderReply")) + request = HandlerRequest(BrokerMessage("FooCreated", 1234, identifier=self.saga, reply_topic="AddOrderReply")) self.assertEqual(1234, await request.content()) diff --git a/tests/test_networks/test_handlers/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_services.py similarity index 100% rename from tests/test_networks/test_handlers/test_services.py rename to tests/test_networks/test_brokers/test_subscribers/test_services.py diff --git a/tests/utils.py b/tests/utils.py index a0273084..9b1d5139 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -40,8 +40,8 @@ current_datetime, ) from minos.networks import ( + BrokerMessageStatus, EnrouteDecorator, - PublishResponseStatus, Request, Response, WrappedRequest, @@ -208,7 +208,7 @@ async def send( topic: str = None, saga: str = None, reply_topic: str = None, - status: PublishResponseStatus = None, + status: BrokerMessageStatus = None, **kwargs, ) -> None: """For testing purposes.""" From 4187c8b69261cc0042dac816e13dd94604e3ede8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Wed, 10 Nov 2021 14:58:11 +0100 Subject: [PATCH 03/24] ISSUE #435 * Add support for `minos.common.MinosConfig.services`. --- minos/networks/discovery/connectors.py | 11 +- minos/networks/handlers/commands/handlers.py | 2 +- minos/networks/handlers/consumers.py | 13 +- minos/networks/handlers/events/handlers.py | 2 +- minos/networks/rest/handlers.py | 2 +- minos/networks/scheduling/schedulers.py | 2 +- poetry.lock | 178 +++++++++--------- pyproject.toml | 2 +- tests/test_config.yml | 7 +- .../test_handlers/test_abc/test_handlers.py | 2 +- .../test_handlers/test_consumers.py | 1 - 11 files changed, 109 insertions(+), 113 deletions(-) diff --git a/minos/networks/discovery/connectors.py b/minos/networks/discovery/connectors.py index 9774020e..66f56b3b 100644 --- a/minos/networks/discovery/connectors.py +++ b/minos/networks/discovery/connectors.py @@ -78,12 +78,13 @@ def _client_cls_from_config(config: MinosConfig) -> Type[DiscoveryClient]: @staticmethod def _endpoints_from_config(config: MinosConfig) -> list[dict[str, Any]]: - command_decorators = EnrouteAnalyzer(config.commands.service, config).get_rest_command_query() - query_decorators = EnrouteAnalyzer(config.queries.service, config).get_rest_command_query() + endpoints = list() + for name in config.services: + decorators = EnrouteAnalyzer(name, config).get_rest_command_query() + endpoints += [ + {"url": decorator.url, "method": decorator.method} for decorator in set(chain(*decorators.values())) + ] - endpoints = chain(chain(*command_decorators.values()), chain(*query_decorators.values())) - endpoints = set(endpoints) - endpoints = [{"url": decorator.url, "method": decorator.method} for decorator in endpoints] endpoints.sort(key=itemgetter("url", "method")) return endpoints diff --git a/minos/networks/handlers/commands/handlers.py b/minos/networks/handlers/commands/handlers.py index 898cc723..7a9e5342 100644 --- a/minos/networks/handlers/commands/handlers.py +++ b/minos/networks/handlers/commands/handlers.py @@ -66,7 +66,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandHandler: @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: - builder = EnrouteBuilder(config.commands.service, config.queries.service) + builder = EnrouteBuilder(*config.services) decorators = builder.get_broker_command_query(config=config, **kwargs) handlers = {decorator.topic: fn for decorator, fn in decorators.items()} return handlers diff --git a/minos/networks/handlers/consumers.py b/minos/networks/handlers/consumers.py index b18ceb48..56626a4b 100644 --- a/minos/networks/handlers/consumers.py +++ b/minos/networks/handlers/consumers.py @@ -68,16 +68,9 @@ def __init__( def _from_config(cls, config: MinosConfig, **kwargs) -> Consumer: topics = set() - # commands - decorators = EnrouteAnalyzer(config.commands.service, config).get_broker_command_query_event() - topics |= {decorator.topic for decorator in chain(*decorators.values())} - - # queries - decorators = EnrouteAnalyzer(config.queries.service, config).get_broker_command_query_event() - topics |= {decorator.topic for decorator in chain(*decorators.values())} - - # replies - topics |= {f"{config.service.name}Reply"} + for name in config.services: + decorators = EnrouteAnalyzer(name).get_broker_command_query_event() + topics |= {decorator.topic for decorator in chain(*decorators.values())} # noinspection PyProtectedMember return cls( diff --git a/minos/networks/handlers/events/handlers.py b/minos/networks/handlers/events/handlers.py index d92fd8d3..bc921edd 100644 --- a/minos/networks/handlers/events/handlers.py +++ b/minos/networks/handlers/events/handlers.py @@ -59,7 +59,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventHandler: @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: - builder = EnrouteBuilder(config.commands.service, config.queries.service) + builder = EnrouteBuilder(*config.services) handlers = builder.get_broker_event(config=config, **kwargs) handlers = {decorator.topic: fn for decorator, fn in handlers.items()} return handlers diff --git a/minos/networks/rest/handlers.py b/minos/networks/rest/handlers.py index 3319c263..e9bb1173 100644 --- a/minos/networks/rest/handlers.py +++ b/minos/networks/rest/handlers.py @@ -68,7 +68,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> RestHandler: @staticmethod def _endpoints_from_config(config: MinosConfig, **kwargs) -> dict[(str, str), Callable]: - builder = EnrouteBuilder(config.commands.service, config.queries.service) + builder = EnrouteBuilder(*config.services) decorators = builder.get_rest_command_query(config=config, **kwargs) endpoints = {(decorator.url, decorator.method): fn for decorator, fn in decorators.items()} return endpoints diff --git a/minos/networks/scheduling/schedulers.py b/minos/networks/scheduling/schedulers.py index 12e82626..82448695 100644 --- a/minos/networks/scheduling/schedulers.py +++ b/minos/networks/scheduling/schedulers.py @@ -58,7 +58,7 @@ def _from_config(cls, config: MinosConfig, **kwargs) -> PeriodicTaskScheduler: @staticmethod def _tasks_from_config(config: MinosConfig, **kwargs) -> set[PeriodicTask]: - builder = EnrouteBuilder(config.commands.service, config.queries.service) + builder = EnrouteBuilder(*config.services) decorators = builder.get_periodic_event(config=config, **kwargs) tasks = {PeriodicTask(decorator.crontab, fn) for decorator, fn in decorators.items()} return tasks diff --git a/poetry.lock b/poetry.lock index ff7a1b57..df7d8514 100644 --- a/poetry.lock +++ b/poetry.lock @@ -141,7 +141,7 @@ pytz = ">=2015.7" [[package]] name = "backports.entry-points-selectable" -version = "1.1.0" +version = "1.1.1" description = "Compatibility shim providing selectable entry points for older implementations" category = "dev" optional = false @@ -149,7 +149,7 @@ python-versions = ">=2.7" [package.extras] docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=4.6)", "pytest-flake8", "pytest-cov", "pytest-black (>=0.3.7)", "pytest-mypy", "pytest-checkdocs (>=2.4)", "pytest-enabler (>=1.0.1)"] +testing = ["pytest", "pytest-flake8", "pytest-cov", "pytest-black (>=0.3.7)", "pytest-mypy", "pytest-checkdocs (>=2.4)", "pytest-enabler (>=1.0.1)"] [[package]] name = "black" @@ -238,7 +238,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "colorlog" -version = "6.5.0" +version = "6.6.0" description = "Add colours to the output of Python's logging module." category = "main" optional = false @@ -351,7 +351,7 @@ python-versions = ">=3.6" [[package]] name = "identify" -version = "2.3.4" +version = "2.3.5" description = "File identification library for Python" category = "dev" optional = false @@ -370,7 +370,7 @@ python-versions = ">=3.5" [[package]] name = "imagesize" -version = "1.2.0" +version = "1.3.0" description = "Getting image size from png/jpeg/jpeg2000/gif file" category = "dev" optional = false @@ -386,7 +386,7 @@ python-versions = "*" [[package]] name = "isort" -version = "5.10.0" +version = "5.10.1" description = "A Python utility / library to sort Python imports." category = "dev" optional = false @@ -400,7 +400,7 @@ plugins = ["setuptools"] [[package]] name = "jinja2" -version = "3.0.2" +version = "3.0.3" description = "A very fast and expressive template engine." category = "dev" optional = false @@ -464,7 +464,7 @@ python-versions = "*" [[package]] name = "minos-microservice-aggregate" -version = "0.1.0" +version = "0.1.1" description = "Python Package for Minos Microservices containing all the Aggregate stuff" category = "main" optional = false @@ -475,21 +475,28 @@ minos-microservice-common = ">=0.2.0,<0.3.0" [[package]] name = "minos-microservice-common" -version = "0.2.0" +version = "0.2.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = false [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" -PyYAML = ">=5.4.1,<6.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" +PyYAML = "^5.4.1" + +[package.source] +type = "git" +url = "https://github.com/Clariteia/minos_microservice_common.git" +reference = "issue-649-minos-config-services" +resolved_reference = "a1c1a7f6ae4d516fd5f58323c648e33ee5733094" [[package]] name = "mistune" @@ -685,7 +692,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" [[package]] name = "regex" -version = "2021.11.2" +version = "2021.11.10" description = "Alternative regular expression module, to replace re." category = "dev" optional = false @@ -940,7 +947,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "b789a5f877c56cb58a1902f9a86059c98f09bd4672bea07cc37e149248d44612" +content-hash = "e698df0c8fcaf0d14f5825b708db307acce9b73459b41912889ad9a90eb3e4d3" [metadata.files] aiohttp = [ @@ -1077,8 +1084,8 @@ babel = [ {file = "Babel-2.9.1.tar.gz", hash = "sha256:bc0c176f9f6a994582230df350aa6e05ba2ebe4b3ac317eab29d9be5d2768da0"}, ] "backports.entry-points-selectable" = [ - {file = "backports.entry_points_selectable-1.1.0-py2.py3-none-any.whl", hash = "sha256:a6d9a871cde5e15b4c4a53e3d43ba890cc6861ec1332c9c2428c92f977192acc"}, - {file = "backports.entry_points_selectable-1.1.0.tar.gz", hash = "sha256:988468260ec1c196dab6ae1149260e2f5472c9110334e5d51adcb77867361f6a"}, + {file = "backports.entry_points_selectable-1.1.1-py2.py3-none-any.whl", hash = "sha256:7fceed9532a7aa2bd888654a7314f864a3c16a4e710b34a58cfc0f08114c663b"}, + {file = "backports.entry_points_selectable-1.1.1.tar.gz", hash = "sha256:914b21a479fde881635f7af5adc7f6e38d6b274be32269070c53b698c60d5386"}, ] black = [ {file = "black-19.10b0-py36-none-any.whl", hash = "sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b"}, @@ -1161,8 +1168,8 @@ colorama = [ {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, ] colorlog = [ - {file = "colorlog-6.5.0-py2.py3-none-any.whl", hash = "sha256:d334b1b8dae5989b786232f05586a7a0111feb24ff9cfc8310c3347a91388717"}, - {file = "colorlog-6.5.0.tar.gz", hash = "sha256:cf62a8e389d5660d0d22be17937b25b9abef9497ddc940197d1773aa1f604339"}, + {file = "colorlog-6.6.0-py2.py3-none-any.whl", hash = "sha256:351c51e866c86c3217f08e4b067a7974a678be78f07f85fc2d55b8babde6d94e"}, + {file = "colorlog-6.6.0.tar.gz", hash = "sha256:344f73204009e4c83c5b6beb00b3c45dc70fcdae3c80db919e0a4171d006fde8"}, ] coverage = [ {file = "coverage-5.5-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:b6d534e4b2ab35c9f93f46229363e17f63c53ad01330df9f2d6bd1187e5eaacf"}, @@ -1372,28 +1379,28 @@ frozenlist = [ {file = "frozenlist-1.2.0.tar.gz", hash = "sha256:68201be60ac56aff972dc18085800b6ee07973c49103a8aba669dee3d71079de"}, ] identify = [ - {file = "identify-2.3.4-py2.py3-none-any.whl", hash = "sha256:4de55a93e0ba72bf917c840b3794eb1055a67272a1732351c557c88ec42011b1"}, - {file = "identify-2.3.4.tar.gz", hash = "sha256:595283a1c3a078ac5774ad4dc4d1bdd0c1602f60bcf11ae673b64cb2b1945762"}, + {file = "identify-2.3.5-py2.py3-none-any.whl", hash = "sha256:ba945bddb4322394afcf3f703fa68eda08a6acc0f99d9573eb2be940aa7b9bba"}, + {file = "identify-2.3.5.tar.gz", hash = "sha256:6f0368ba0f21c199645a331beb7425d5374376e71bc149e9cb55e45cb45f832d"}, ] idna = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, ] imagesize = [ - {file = "imagesize-1.2.0-py2.py3-none-any.whl", hash = "sha256:6965f19a6a2039c7d48bca7dba2473069ff854c36ae6f19d2cde309d998228a1"}, - {file = "imagesize-1.2.0.tar.gz", hash = "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1"}, + {file = "imagesize-1.3.0-py2.py3-none-any.whl", hash = "sha256:1db2f82529e53c3e929e8926a1fa9235aa82d0bd0c580359c67ec31b2fddaa8c"}, + {file = "imagesize-1.3.0.tar.gz", hash = "sha256:cd1750d452385ca327479d45b64d9c7729ecf0b3969a58148298c77092261f9d"}, ] iniconfig = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, ] isort = [ - {file = "isort-5.10.0-py3-none-any.whl", hash = "sha256:1a18ccace2ed8910bd9458b74a3ecbafd7b2f581301b0ab65cfdd4338272d76f"}, - {file = "isort-5.10.0.tar.gz", hash = "sha256:e52ff6d38012b131628cf0f26c51e7bd3a7c81592eefe3ac71411e692f1b9345"}, + {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"}, + {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"}, ] jinja2 = [ - {file = "Jinja2-3.0.2-py3-none-any.whl", hash = "sha256:8569982d3f0889eed11dd620c706d39b60c36d6d25843961f33f77fb6bc6b20c"}, - {file = "Jinja2-3.0.2.tar.gz", hash = "sha256:827a0e32839ab1600d4eb1c4c33ec5a8edfbc5cb42dafa13b81f182f97784b45"}, + {file = "Jinja2-3.0.3-py3-none-any.whl", hash = "sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8"}, + {file = "Jinja2-3.0.3.tar.gz", hash = "sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"}, ] kafka-python = [ {file = "kafka-python-2.0.2.tar.gz", hash = "sha256:04dfe7fea2b63726cd6f3e79a2d86e709d608d74406638c5da33a01d45a9d7e3"}, @@ -1503,13 +1510,10 @@ mccabe = [ {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] minos-microservice-aggregate = [ - {file = "minos_microservice_aggregate-0.1.0-py3-none-any.whl", hash = "sha256:1141288d0c2f46fae88330e8140c9fc2e5e0a9bac5fa23f1111c2e0210a01c15"}, - {file = "minos_microservice_aggregate-0.1.0.tar.gz", hash = "sha256:51c6c76a5fa84a08a91aedfc7e207a957814787bc34dc9f64673ea1d505edf16"}, -] -minos-microservice-common = [ - {file = "minos_microservice_common-0.2.0-py3-none-any.whl", hash = "sha256:a5f57f3af35ce40c36ed15c0d390af42e109db8bb204dff6115f517980c3e3bb"}, - {file = "minos_microservice_common-0.2.0.tar.gz", hash = "sha256:a33fd6ba6146da1361f562e5a69fc8b9f68148705e0ebe704c03474aa58f116e"}, + {file = "minos_microservice_aggregate-0.1.1-py3-none-any.whl", hash = "sha256:077315ed09a5478e4c85dd7caa9f2876d6089d0eb3a0e69bfbe4bafa934db2ab"}, + {file = "minos_microservice_aggregate-0.1.1.tar.gz", hash = "sha256:9ef4e17479254eb4bd59c9fd3b3295a806a81e858c6228637611314edd5c663c"}, ] +minos-microservice-common = [] mistune = [ {file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"}, {file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"}, @@ -1743,55 +1747,55 @@ pyyaml = [ {file = "PyYAML-5.4.1.tar.gz", hash = "sha256:607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"}, ] regex = [ - {file = "regex-2021.11.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:897c539f0f3b2c3a715be651322bef2167de1cdc276b3f370ae81a3bda62df71"}, - {file = "regex-2021.11.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:886f459db10c0f9d17c87d6594e77be915f18d343ee138e68d259eb385f044a8"}, - {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:075b0fdbaea81afcac5a39a0d1bb91de887dd0d93bf692a5dd69c430e7fc58cb"}, - {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c6238d30dcff141de076344cf7f52468de61729c2f70d776fce12f55fe8df790"}, - {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7fab29411d75c2eb48070020a40f80255936d7c31357b086e5931c107d48306e"}, - {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0148988af0182a0a4e5020e7c168014f2c55a16d11179610f7883dd48ac0ebe"}, - {file = "regex-2021.11.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be30cd315db0168063a1755fa20a31119da91afa51da2907553493516e165640"}, - {file = "regex-2021.11.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e9cec3a62d146e8e122d159ab93ac32c988e2ec0dcb1e18e9e53ff2da4fbd30c"}, - {file = "regex-2021.11.2-cp310-cp310-win32.whl", hash = "sha256:41c66bd6750237a8ed23028a6c9173dc0c92dc24c473e771d3bfb9ee817700c3"}, - {file = "regex-2021.11.2-cp310-cp310-win_amd64.whl", hash = "sha256:0075fe4e2c2720a685fef0f863edd67740ff78c342cf20b2a79bc19388edf5db"}, - {file = "regex-2021.11.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:0ed3465acf8c7c10aa2e0f3d9671da410ead63b38a77283ef464cbb64275df58"}, - {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ab1fea8832976ad0bebb11f652b692c328043057d35e9ebc78ab0a7a30cf9a70"}, - {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cb1e44d860345ab5d4f533b6c37565a22f403277f44c4d2d5e06c325da959883"}, - {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9486ebda015913909bc28763c6b92fcc3b5e5a67dee4674bceed112109f5dfb8"}, - {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:20605bfad484e1341b2cbfea0708e4b211d233716604846baa54b94821f487cb"}, - {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f20f9f430c33597887ba9bd76635476928e76cad2981643ca8be277b8e97aa96"}, - {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1d85ca137756d62c8138c971453cafe64741adad1f6a7e63a22a5a8abdbd19fa"}, - {file = "regex-2021.11.2-cp36-cp36m-win32.whl", hash = "sha256:af23b9ca9a874ef0ec20e44467b8edd556c37b0f46f93abfa93752ea7c0e8d1e"}, - {file = "regex-2021.11.2-cp36-cp36m-win_amd64.whl", hash = "sha256:070336382ca92c16c45b4066c4ba9fa83fb0bd13d5553a82e07d344df8d58a84"}, - {file = "regex-2021.11.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:ef4e53e2fdc997d91f5b682f81f7dc9661db9a437acce28745d765d251902d85"}, - {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:35ed5714467fc606551db26f80ee5d6aa1f01185586a7bccd96f179c4b974a11"}, - {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ee36d5113b6506b97f45f2e8447cb9af146e60e3f527d93013d19f6d0405f3b"}, - {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4fba661a4966adbd2c3c08d3caad6822ecb6878f5456588e2475ae23a6e47929"}, - {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77f9d16f7970791f17ecce7e7f101548314ed1ee2583d4268601f30af3170856"}, - {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f6a28e87ba69f3a4f30d775b179aac55be1ce59f55799328a0d9b6df8f16b39d"}, - {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:9267e4fba27e6dd1008c4f2983cc548c98b4be4444e3e342db11296c0f45512f"}, - {file = "regex-2021.11.2-cp37-cp37m-win32.whl", hash = "sha256:d4bfe3bc3976ccaeb4ae32f51e631964e2f0e85b2b752721b7a02de5ce3b7f27"}, - {file = "regex-2021.11.2-cp37-cp37m-win_amd64.whl", hash = "sha256:2bb7cae741de1aa03e3dd3a7d98c304871eb155921ca1f0d7cc11f5aade913fd"}, - {file = "regex-2021.11.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:23f93e74409c210de4de270d4bf88fb8ab736a7400f74210df63a93728cf70d6"}, - {file = "regex-2021.11.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:d8ee91e1c295beb5c132ebd78616814de26fedba6aa8687ea460c7f5eb289b72"}, - {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e3ff69ab203b54ce5c480c3ccbe959394ea5beef6bd5ad1785457df7acea92e"}, - {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e3c00cb5c71da655e1e5161481455479b613d500dd1bd252aa01df4f037c641f"}, - {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4abf35e16f4b639daaf05a2602c1b1d47370e01babf9821306aa138924e3fe92"}, - {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bb11c982a849dc22782210b01d0c1b98eb3696ce655d58a54180774e4880ac66"}, - {file = "regex-2021.11.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07e3755e0f070bc31567dfe447a02011bfa8444239b3e9e5cca6773a22133839"}, - {file = "regex-2021.11.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:0621c90f28d17260b41838b22c81a79ff436141b322960eb49c7b3f91d1cbab6"}, - {file = "regex-2021.11.2-cp38-cp38-win32.whl", hash = "sha256:8fbe1768feafd3d0156556677b8ff234c7bf94a8110e906b2d73506f577a3269"}, - {file = "regex-2021.11.2-cp38-cp38-win_amd64.whl", hash = "sha256:f9ee98d658a146cb6507be720a0ce1b44f2abef8fb43c2859791d91aace17cd5"}, - {file = "regex-2021.11.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b3794cea825f101fe0df9af8a00f9fad8e119c91e39a28636b95ee2b45b6c2e5"}, - {file = "regex-2021.11.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3576e173e7b4f88f683b4de7db0c2af1b209bb48b2bf1c827a6f3564fad59a97"}, - {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:48b4f4810117a9072a5aa70f7fea5f86fa9efbe9a798312e0a05044bd707cc33"}, - {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f5930d334c2f607711d54761956aedf8137f83f1b764b9640be21d25a976f3a4"}, - {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:956187ff49db7014ceb31e88fcacf4cf63371e6e44d209cf8816cd4a2d61e11a"}, - {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17e095f7f96a4b9f24b93c2c915f31a5201a6316618d919b0593afb070a5270e"}, - {file = "regex-2021.11.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a56735c35a3704603d9d7b243ee06139f0837bcac2171d9ba1d638ce1df0742a"}, - {file = "regex-2021.11.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:adf35d88d9cffc202e6046e4c32e1e11a1d0238b2fcf095c94f109e510ececea"}, - {file = "regex-2021.11.2-cp39-cp39-win32.whl", hash = "sha256:30fe317332de0e50195665bc61a27d46e903d682f94042c36b3f88cb84bd7958"}, - {file = "regex-2021.11.2-cp39-cp39-win_amd64.whl", hash = "sha256:85289c25f658e3260b00178757c87f033f3d4b3e40aa4abdd4dc875ff11a94fb"}, - {file = "regex-2021.11.2.tar.gz", hash = "sha256:5e85dcfc5d0f374955015ae12c08365b565c6f1eaf36dd182476a4d8e5a1cdb7"}, + {file = "regex-2021.11.10-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9345b6f7ee578bad8e475129ed40123d265464c4cfead6c261fd60fc9de00bcf"}, + {file = "regex-2021.11.10-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:416c5f1a188c91e3eb41e9c8787288e707f7d2ebe66e0a6563af280d9b68478f"}, + {file = "regex-2021.11.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0538c43565ee6e703d3a7c3bdfe4037a5209250e8502c98f20fea6f5fdf2965"}, + {file = "regex-2021.11.10-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ee1227cf08b6716c85504aebc49ac827eb88fcc6e51564f010f11a406c0a667"}, + {file = "regex-2021.11.10-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6650f16365f1924d6014d2ea770bde8555b4a39dc9576abb95e3cd1ff0263b36"}, + {file = "regex-2021.11.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:30ab804ea73972049b7a2a5c62d97687d69b5a60a67adca07eb73a0ddbc9e29f"}, + {file = "regex-2021.11.10-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:68a067c11463de2a37157930d8b153005085e42bcb7ad9ca562d77ba7d1404e0"}, + {file = "regex-2021.11.10-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:162abfd74e88001d20cb73ceaffbfe601469923e875caf9118333b1a4aaafdc4"}, + {file = "regex-2021.11.10-cp310-cp310-win32.whl", hash = "sha256:98ba568e8ae26beb726aeea2273053c717641933836568c2a0278a84987b2a1a"}, + {file = "regex-2021.11.10-cp310-cp310-win_amd64.whl", hash = "sha256:780b48456a0f0ba4d390e8b5f7c661fdd218934388cde1a974010a965e200e12"}, + {file = "regex-2021.11.10-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:dba70f30fd81f8ce6d32ddeef37d91c8948e5d5a4c63242d16a2b2df8143aafc"}, + {file = "regex-2021.11.10-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e1f54b9b4b6c53369f40028d2dd07a8c374583417ee6ec0ea304e710a20f80a0"}, + {file = "regex-2021.11.10-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fbb9dc00e39f3e6c0ef48edee202f9520dafb233e8b51b06b8428cfcb92abd30"}, + {file = "regex-2021.11.10-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:666abff54e474d28ff42756d94544cdfd42e2ee97065857413b72e8a2d6a6345"}, + {file = "regex-2021.11.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5537f71b6d646f7f5f340562ec4c77b6e1c915f8baae822ea0b7e46c1f09b733"}, + {file = "regex-2021.11.10-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ed2e07c6a26ed4bea91b897ee2b0835c21716d9a469a96c3e878dc5f8c55bb23"}, + {file = "regex-2021.11.10-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ca5f18a75e1256ce07494e245cdb146f5a9267d3c702ebf9b65c7f8bd843431e"}, + {file = "regex-2021.11.10-cp36-cp36m-win32.whl", hash = "sha256:93a5051fcf5fad72de73b96f07d30bc29665697fb8ecdfbc474f3452c78adcf4"}, + {file = "regex-2021.11.10-cp36-cp36m-win_amd64.whl", hash = "sha256:b483c9d00a565633c87abd0aaf27eb5016de23fed952e054ecc19ce32f6a9e7e"}, + {file = "regex-2021.11.10-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:fff55f3ce50a3ff63ec8e2a8d3dd924f1941b250b0aac3d3d42b687eeff07a8e"}, + {file = "regex-2021.11.10-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e32d2a2b02ccbef10145df9135751abea1f9f076e67a4e261b05f24b94219e36"}, + {file = "regex-2021.11.10-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:53db2c6be8a2710b359bfd3d3aa17ba38f8aa72a82309a12ae99d3c0c3dcd74d"}, + {file = "regex-2021.11.10-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2207ae4f64ad3af399e2d30dde66f0b36ae5c3129b52885f1bffc2f05ec505c8"}, + {file = "regex-2021.11.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d5ca078bb666c4a9d1287a379fe617a6dccd18c3e8a7e6c7e1eb8974330c626a"}, + {file = "regex-2021.11.10-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dd33eb9bdcfbabab3459c9ee651d94c842bc8a05fabc95edf4ee0c15a072495e"}, + {file = "regex-2021.11.10-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:05b7d6d7e64efe309972adab77fc2af8907bb93217ec60aa9fe12a0dad35874f"}, + {file = "regex-2021.11.10-cp37-cp37m-win32.whl", hash = "sha256:e71255ba42567d34a13c03968736c5d39bb4a97ce98188fafb27ce981115beec"}, + {file = "regex-2021.11.10-cp37-cp37m-win_amd64.whl", hash = "sha256:07856afef5ffcc052e7eccf3213317fbb94e4a5cd8177a2caa69c980657b3cb4"}, + {file = "regex-2021.11.10-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:ba05430e819e58544e840a68b03b28b6d328aff2e41579037e8bab7653b37d83"}, + {file = "regex-2021.11.10-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7f301b11b9d214f83ddaf689181051e7f48905568b0c7017c04c06dfd065e244"}, + {file = "regex-2021.11.10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aaa4e0705ef2b73dd8e36eeb4c868f80f8393f5f4d855e94025ce7ad8525f50"}, + {file = "regex-2021.11.10-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:788aef3549f1924d5c38263104dae7395bf020a42776d5ec5ea2b0d3d85d6646"}, + {file = "regex-2021.11.10-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f8af619e3be812a2059b212064ea7a640aff0568d972cd1b9e920837469eb3cb"}, + {file = "regex-2021.11.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:85bfa6a5413be0ee6c5c4a663668a2cad2cbecdee367630d097d7823041bdeec"}, + {file = "regex-2021.11.10-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f23222527b307970e383433daec128d769ff778d9b29343fb3496472dc20dabe"}, + {file = "regex-2021.11.10-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:da1a90c1ddb7531b1d5ff1e171b4ee61f6345119be7351104b67ff413843fe94"}, + {file = "regex-2021.11.10-cp38-cp38-win32.whl", hash = "sha256:0617383e2fe465732af4509e61648b77cbe3aee68b6ac8c0b6fe934db90be5cc"}, + {file = "regex-2021.11.10-cp38-cp38-win_amd64.whl", hash = "sha256:a3feefd5e95871872673b08636f96b61ebef62971eab044f5124fb4dea39919d"}, + {file = "regex-2021.11.10-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f7f325be2804246a75a4f45c72d4ce80d2443ab815063cdf70ee8fb2ca59ee1b"}, + {file = "regex-2021.11.10-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:537ca6a3586931b16a85ac38c08cc48f10fc870a5b25e51794c74df843e9966d"}, + {file = "regex-2021.11.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eef2afb0fd1747f33f1ee3e209bce1ed582d1896b240ccc5e2697e3275f037c7"}, + {file = "regex-2021.11.10-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:432bd15d40ed835a51617521d60d0125867f7b88acf653e4ed994a1f8e4995dc"}, + {file = "regex-2021.11.10-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b43c2b8a330a490daaef5a47ab114935002b13b3f9dc5da56d5322ff218eeadb"}, + {file = "regex-2021.11.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:962b9a917dd7ceacbe5cd424556914cb0d636001e393b43dc886ba31d2a1e449"}, + {file = "regex-2021.11.10-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fa8c626d6441e2d04b6ee703ef2d1e17608ad44c7cb75258c09dd42bacdfc64b"}, + {file = "regex-2021.11.10-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3c5fb32cc6077abad3bbf0323067636d93307c9fa93e072771cf9a64d1c0f3ef"}, + {file = "regex-2021.11.10-cp39-cp39-win32.whl", hash = "sha256:3b5df18db1fccd66de15aa59c41e4f853b5df7550723d26aa6cb7f40e5d9da5a"}, + {file = "regex-2021.11.10-cp39-cp39-win_amd64.whl", hash = "sha256:83ee89483672b11f8952b158640d0c0ff02dc43d9cb1b70c1564b49abe92ce29"}, + {file = "regex-2021.11.10.tar.gz", hash = "sha256:f341ee2df0999bfdf7a95e448075effe0db212a59387de1a70690e4acb03d4c6"}, ] requests = [ {file = "requests-2.26.0-py2.py3-none-any.whl", hash = "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24"}, diff --git a/pyproject.toml b/pyproject.toml index 59516d17..861f804c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ aiomisc = "^14.0.3" aiopg = "^1.2.1" aiohttp = "^3.7.4" dependency-injector = "^4.32.2" -minos-microservice-common = "^0.2.0" +minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-649-minos-config-services" } minos-microservice-aggregate = "^0.1.0" crontab = "^0.23.0" diff --git a/tests/test_config.yml b/tests/test_config.yml index 8e74c31f..167e46a0 100644 --- a/tests/test_config.yml +++ b/tests/test_config.yml @@ -1,6 +1,9 @@ service: name: Order aggregate: tests.utils.Order +services: + - tests.services.commands.CommandService + - tests.services.queries.QueryService rest: host: localhost port: 8080 @@ -27,10 +30,6 @@ broker: port: 5432 records: 10 retry: 2 -commands: - service: tests.services.commands.CommandService -queries: - service: tests.services.queries.QueryService saga: storage: path: "./order.lmdb" diff --git a/tests/test_networks/test_handlers/test_abc/test_handlers.py b/tests/test_networks/test_handlers/test_abc/test_handlers.py index 2f916f0d..30d25738 100644 --- a/tests/test_networks/test_handlers/test_abc/test_handlers.py +++ b/tests/test_networks/test_handlers/test_abc/test_handlers.py @@ -65,7 +65,7 @@ class TestHandler(PostgresAsyncTestCase): CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" def handlers(self): - decorators = EnrouteBuilder(self.config.commands.service).get_broker_command_query() + decorators = EnrouteBuilder(*self.config.services).get_broker_command_query() handlers = {decorator.topic: fn for decorator, fn in decorators.items()} return handlers diff --git a/tests/test_networks/test_handlers/test_consumers.py b/tests/test_networks/test_handlers/test_consumers.py index a31ca353..3ce31c4a 100644 --- a/tests/test_networks/test_handlers/test_consumers.py +++ b/tests/test_networks/test_handlers/test_consumers.py @@ -40,7 +40,6 @@ def test_from_config(self): "AddOrder", "DeleteOrder", "GetOrder", - "OrderReply", "TicketAdded", "TicketDeleted", "UpdateOrder", From 3884cea22a4d4a4102aead86a6c6d1db8c5b3d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Wed, 10 Nov 2021 16:04:38 +0100 Subject: [PATCH 04/24] ISSUE #435 * Fix bug. --- minos/networks/handlers/consumers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minos/networks/handlers/consumers.py b/minos/networks/handlers/consumers.py index 56626a4b..2d7149db 100644 --- a/minos/networks/handlers/consumers.py +++ b/minos/networks/handlers/consumers.py @@ -69,7 +69,7 @@ def _from_config(cls, config: MinosConfig, **kwargs) -> Consumer: topics = set() for name in config.services: - decorators = EnrouteAnalyzer(name).get_broker_command_query_event() + decorators = EnrouteAnalyzer(name, config).get_broker_command_query_event() topics |= {decorator.topic for decorator in chain(*decorators.values())} # noinspection PyProtectedMember From d00281ae5a4ec73309d7545fcae2a42fd6cd4299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Wed, 10 Nov 2021 16:38:55 +0100 Subject: [PATCH 05/24] ISSUE #434 * Remove `CommandReplyHandler`, `CommandReplyHandlerService` and `CommandReplyBroker` --- minos/networks/__init__.py | 3 - minos/networks/brokers/__init__.py | 3 - minos/networks/brokers/publishers/__init__.py | 3 - .../brokers/publishers/command_replies.py | 54 --------------- .../networks/brokers/subscribers/__init__.py | 4 -- .../subscribers/command_replies/__init__.py | 6 -- .../subscribers/command_replies/handlers.py | 52 -------------- .../subscribers/command_replies/services.py | 52 -------------- .../brokers/subscribers/commands/handlers.py | 2 +- .../test_publishers/test_command_replies.py | 64 ----------------- .../test_publishers/test_producers.py | 17 +++-- .../test_command_replies/__init__.py | 1 - .../test_command_replies/test_handlers.py | 68 ------------------- .../test_command_replies/test_services.py | 62 ----------------- 14 files changed, 9 insertions(+), 382 deletions(-) delete mode 100644 minos/networks/brokers/publishers/command_replies.py delete mode 100644 minos/networks/brokers/subscribers/command_replies/__init__.py delete mode 100644 minos/networks/brokers/subscribers/command_replies/handlers.py delete mode 100644 minos/networks/brokers/subscribers/command_replies/services.py delete mode 100644 tests/test_networks/test_brokers/test_publishers/test_command_replies.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index f74faf2a..c0c65582 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -11,9 +11,6 @@ CommandBroker, CommandHandler, CommandHandlerService, - CommandReplyBroker, - CommandReplyHandler, - CommandReplyHandlerService, Consumer, ConsumerService, DynamicHandler, diff --git a/minos/networks/brokers/__init__.py b/minos/networks/brokers/__init__.py index 6365d8c3..b66b3d29 100644 --- a/minos/networks/brokers/__init__.py +++ b/minos/networks/brokers/__init__.py @@ -7,7 +7,6 @@ Broker, BrokerSetup, CommandBroker, - CommandReplyBroker, EventBroker, Producer, ProducerService, @@ -15,8 +14,6 @@ from .subscribers import ( CommandHandler, CommandHandlerService, - CommandReplyHandler, - CommandReplyHandlerService, Consumer, ConsumerService, DynamicHandler, diff --git a/minos/networks/brokers/publishers/__init__.py b/minos/networks/brokers/publishers/__init__.py index af2120b4..a34a1a40 100644 --- a/minos/networks/brokers/publishers/__init__.py +++ b/minos/networks/brokers/publishers/__init__.py @@ -2,9 +2,6 @@ Broker, BrokerSetup, ) -from .command_replies import ( - CommandReplyBroker, -) from .commands import ( CommandBroker, ) diff --git a/minos/networks/brokers/publishers/command_replies.py b/minos/networks/brokers/publishers/command_replies.py deleted file mode 100644 index 842f4dee..00000000 --- a/minos/networks/brokers/publishers/command_replies.py +++ /dev/null @@ -1,54 +0,0 @@ -from __future__ import ( - annotations, -) - -import logging -from typing import ( - Any, -) -from uuid import ( - UUID, -) - -from minos.common import ( - MinosConfig, -) - -from ..messages import ( - BrokerMessage, - BrokerMessageStatus, -) -from .abc import ( - Broker, -) - -logger = logging.getLogger(__name__) - - -class CommandReplyBroker(Broker): - """Minos Command Broker Class.""" - - ACTION = "commandReply" - - def __init__(self, *args, service_name: str, **kwargs): - super().__init__(*args, **kwargs) - self.service_name = service_name - - @classmethod - def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyBroker: - return cls(*args, service_name=config.service.name, **config.broker.queue._asdict(), **kwargs) - - # noinspection PyMethodOverriding - async def send(self, data: Any, topic: str, saga: UUID, status: BrokerMessageStatus, **kwargs) -> int: - """Send a ``CommandReply``. - - :param data: The data to be send. - :param topic: Topic in which the message will be published. - :param saga: Saga identifier. - :param status: command status. - :return: This method does not return anything. - """ - - request = BrokerMessage(topic, data, identifier=saga, status=status, service_name=self.service_name) - logger.info(f"Sending '{request!s}'...") - return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/brokers/subscribers/__init__.py b/minos/networks/brokers/subscribers/__init__.py index 021aad98..166b87fe 100644 --- a/minos/networks/brokers/subscribers/__init__.py +++ b/minos/networks/brokers/subscribers/__init__.py @@ -2,10 +2,6 @@ Handler, HandlerSetup, ) -from .command_replies import ( - CommandReplyHandler, - CommandReplyHandlerService, -) from .commands import ( CommandHandler, CommandHandlerService, diff --git a/minos/networks/brokers/subscribers/command_replies/__init__.py b/minos/networks/brokers/subscribers/command_replies/__init__.py deleted file mode 100644 index 99238638..00000000 --- a/minos/networks/brokers/subscribers/command_replies/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from .handlers import ( - CommandReplyHandler, -) -from .services import ( - CommandReplyHandlerService, -) diff --git a/minos/networks/brokers/subscribers/command_replies/handlers.py b/minos/networks/brokers/subscribers/command_replies/handlers.py deleted file mode 100644 index 112c5996..00000000 --- a/minos/networks/brokers/subscribers/command_replies/handlers.py +++ /dev/null @@ -1,52 +0,0 @@ -from __future__ import ( - annotations, -) - -import logging -from typing import ( - Any, -) - -from dependency_injector.wiring import ( - Provide, - inject, -) - -from minos.common import ( - MinosConfig, - MinosSagaManager, -) - -from ..abc import ( - Handler, -) -from ..entries import ( - HandlerEntry, -) - -logger = logging.getLogger(__name__) - - -class CommandReplyHandler(Handler): - """Command Reply Handler class.""" - - @inject - def __init__(self, saga_manager: MinosSagaManager = Provide["saga_manager"], **kwargs: Any): - super().__init__(**kwargs) - - self.saga_manager = saga_manager - - @classmethod - def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyHandler: - handlers = {f"{config.service.name}Reply": None} - # noinspection PyProtectedMember - return cls(*args, handlers=handlers, **config.broker.queue._asdict(), **kwargs) - - async def dispatch_one(self, entry: HandlerEntry) -> None: - """Dispatch one row. - - :param entry: Entry to be dispatched. - :return: This method does not return anything. - """ - logger.info(f"Dispatching '{entry!s}'...") - await self.saga_manager.run(reply=entry.data, pause_on_disk=True, raise_on_error=False, return_execution=False) diff --git a/minos/networks/brokers/subscribers/command_replies/services.py b/minos/networks/brokers/subscribers/command_replies/services.py deleted file mode 100644 index a4c7e376..00000000 --- a/minos/networks/brokers/subscribers/command_replies/services.py +++ /dev/null @@ -1,52 +0,0 @@ -import logging - -from aiomisc import ( - Service, -) -from cached_property import ( - cached_property, -) - -from .handlers import ( - CommandReplyHandler, -) - -logger = logging.getLogger(__name__) - - -class CommandReplyHandlerService(Service): - """Minos QueueDispatcherService class.""" - - def __init__(self, **kwargs): - super().__init__(**kwargs) - self._init_kwargs = kwargs - - async def start(self) -> None: - """Method to be called at the startup by the internal ``aiomisc`` loigc. - - :return: This method does not return anything. - """ - await self.dispatcher.setup() - - try: - self.start_event.set() - except RuntimeError: - logger.warning("Runtime is not properly setup.") - - await self.dispatcher.dispatch_forever() - - async def stop(self, err: Exception = None) -> None: - """Stop the service execution. - - :param err: Optional exception that stopped the execution. - :return: This method does not return anything. - """ - await self.dispatcher.destroy() - - @cached_property - def dispatcher(self) -> CommandReplyHandler: - """Get the service dispatcher. - - :return: A ``CommandReplyHandler`` instance. - """ - return CommandReplyHandler.from_config(**self._init_kwargs) diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index 01896a4e..9408ac09 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -54,7 +54,7 @@ class CommandHandler(Handler): """Command Handler class.""" @inject - def __init__(self, broker: MinosBroker = Provide["command_reply_broker"], **kwargs: Any): + def __init__(self, broker: MinosBroker = Provide["command_broker"], **kwargs: Any): super().__init__(**kwargs) self.broker = broker diff --git a/tests/test_networks/test_brokers/test_publishers/test_command_replies.py b/tests/test_networks/test_brokers/test_publishers/test_command_replies.py deleted file mode 100644 index fecda921..00000000 --- a/tests/test_networks/test_brokers/test_publishers/test_command_replies.py +++ /dev/null @@ -1,64 +0,0 @@ -import unittest -from unittest.mock import ( - AsyncMock, -) -from uuid import ( - uuid4, -) - -from minos.common import ( - Model, -) -from minos.common.testing import ( - PostgresAsyncTestCase, -) -from minos.networks import ( - BrokerMessage, - BrokerMessageStatus, - CommandReplyBroker, -) -from tests.utils import ( - BASE_PATH, - FakeModel, -) - - -class TestCommandReplyBroker(PostgresAsyncTestCase): - CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" - - def test_from_config_default(self): - broker = CommandReplyBroker.from_config(config=self.config) - self.assertIsInstance(broker, CommandReplyBroker) - - def test_action(self): - self.assertEqual("commandReply", CommandReplyBroker.ACTION) - - async def test_send(self): - mock = AsyncMock(return_value=56) - saga = uuid4() - reply_topic = "fakeReply" - async with CommandReplyBroker.from_config(config=self.config) as broker: - broker.enqueue = mock - identifier = await broker.send( - FakeModel("foo"), saga=saga, topic=reply_topic, status=BrokerMessageStatus.SUCCESS - ) - - self.assertEqual(56, identifier) - self.assertEqual(1, mock.call_count) - - args = mock.call_args.args - self.assertEqual(reply_topic, args[0]) - - expected = BrokerMessage( - reply_topic, - FakeModel("foo"), - identifier=saga, - status=BrokerMessageStatus.SUCCESS, - service_name=self.config.service.name, - ) - observed = Model.from_avro_bytes(args[1]) - self.assertEqual(expected, observed) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_networks/test_brokers/test_publishers/test_producers.py b/tests/test_networks/test_brokers/test_publishers/test_producers.py index 72cc1149..135238c1 100644 --- a/tests/test_networks/test_brokers/test_publishers/test_producers.py +++ b/tests/test_networks/test_brokers/test_publishers/test_producers.py @@ -20,7 +20,6 @@ from minos.networks import ( BrokerMessageStatus, CommandBroker, - CommandReplyBroker, Consumer, EventBroker, Producer, @@ -133,13 +132,9 @@ async def test_concurrency_dispatcher(self): saga = uuid4() command_broker = CommandBroker.from_config(config=self.config) - command_reply_broker = CommandReplyBroker.from_config(config=self.config) event_broker = EventBroker.from_config(config=self.config) for x in range(0, 20): - async with command_reply_broker: - await command_reply_broker.send(model, "TestDeleteReply", saga, BrokerMessageStatus.SUCCESS) - async with command_broker: await command_broker.send(model, "CommandBroker-Delete", saga, "TestDeleteReply") @@ -151,7 +146,7 @@ async def test_concurrency_dispatcher(self): await cur.execute("SELECT COUNT(*) FROM producer_queue") records = await cur.fetchone() - assert records[0] == 60 + assert records[0] == 40 async with self.producer: await asyncio.gather(*(self.producer.dispatch() for _ in range(6))) @@ -184,9 +179,13 @@ async def test_if_commands_retry_was_incremented(self): model = FakeModel("foo") saga = uuid4() - async with CommandReplyBroker.from_config(config=self.config) as broker: - queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) - queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) + async with CommandBroker.from_config(config=self.config) as broker: + queue_id_1 = await broker.send( + model, "TestDeleteOrderReply", identifier=saga, status=BrokerMessageStatus.SUCCESS + ) + queue_id_2 = await broker.send( + model, "TestDeleteOrderReply", identifier=saga, status=BrokerMessageStatus.SUCCESS + ) async with self.producer: self.producer.publish = AsyncMock(return_value=False) diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py deleted file mode 100644 index 8b137891..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py deleted file mode 100644 index a3b1dc09..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py +++ /dev/null @@ -1,68 +0,0 @@ -import unittest -from unittest.mock import ( - AsyncMock, - call, -) -from uuid import ( - uuid4, -) - -from minos.common.testing import ( - PostgresAsyncTestCase, -) -from minos.networks import ( - BrokerMessage, - BrokerMessageStatus, - CommandReplyHandler, - HandlerEntry, -) -from tests.utils import ( - BASE_PATH, - FakeModel, - FakeSagaManager, -) - - -class TestCommandReplyHandler(PostgresAsyncTestCase): - CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" - - def test_from_config(self): - saga_manager = FakeSagaManager() - handler = CommandReplyHandler.from_config(config=self.config, saga_manager=saga_manager) - self.assertIsInstance(handler, CommandReplyHandler) - handlers = {"OrderReply": None} - self.assertEqual(handlers, handler.handlers) - self.assertEqual(self.config.broker.queue.records, handler._records) - self.assertEqual(self.config.broker.queue.retry, handler._retry) - self.assertEqual(self.config.broker.queue.host, handler.host) - self.assertEqual(self.config.broker.queue.port, handler.port) - self.assertEqual(self.config.broker.queue.database, handler.database) - self.assertEqual(self.config.broker.queue.user, handler.user) - self.assertEqual(self.config.broker.queue.password, handler.password) - self.assertEqual(saga_manager, handler.saga_manager) - - async def test_dispatch(self): - saga_manager = FakeSagaManager() - mock = AsyncMock() - saga_manager._load_and_run = mock - - saga = uuid4() - command = BrokerMessage( - "TicketAdded", - [FakeModel("foo")], - identifier=saga, - status=BrokerMessageStatus.SUCCESS, - service_name=self.config.service.name, - ) - entry = HandlerEntry(1, "TicketAdded", 0, command.avro_bytes, 1) - - async with CommandReplyHandler.from_config(config=self.config, saga_manager=saga_manager) as handler: - await handler.dispatch_one(entry) - - self.assertEqual(1, mock.call_count) - expected = call(command, pause_on_disk=True, raise_on_error=False, return_execution=False) - self.assertEqual(expected, mock.call_args) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py deleted file mode 100644 index a9fb60d0..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py +++ /dev/null @@ -1,62 +0,0 @@ -import unittest -from unittest.mock import ( - AsyncMock, -) - -from aiomisc import ( - Service, -) - -from minos.common.testing import ( - PostgresAsyncTestCase, -) -from minos.networks import ( - CommandReplyHandler, - CommandReplyHandlerService, -) -from tests.utils import ( - BASE_PATH, -) - - -class TestCommandReplyHandlerService(PostgresAsyncTestCase): - CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" - - def test_is_instance(self): - service = CommandReplyHandlerService(config=self.config) - self.assertIsInstance(service, Service) - - def test_dispatcher(self): - service = CommandReplyHandlerService(config=self.config) - self.assertIsInstance(service.dispatcher, CommandReplyHandler) - - async def test_start_stop(self): - service = CommandReplyHandlerService(config=self.config) - - setup_mock = AsyncMock() - destroy_mock = AsyncMock() - dispatch_forever_mock = AsyncMock() - - service.dispatcher.setup = setup_mock - service.dispatcher.destroy = destroy_mock - service.dispatcher.dispatch_forever = dispatch_forever_mock - - await service.start() - - self.assertEqual(1, setup_mock.call_count) - self.assertEqual(1, dispatch_forever_mock.call_count) - self.assertEqual(0, destroy_mock.call_count) - - setup_mock.reset_mock() - destroy_mock.reset_mock() - dispatch_forever_mock.reset_mock() - - await service.stop() - - self.assertEqual(0, setup_mock.call_count) - self.assertEqual(0, dispatch_forever_mock.call_count) - self.assertEqual(1, destroy_mock.call_count) - - -if __name__ == "__main__": - unittest.main() From 06cd8b39a02c3efd923e43a8ad37366e5a7ae155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Wed, 10 Nov 2021 16:53:36 +0100 Subject: [PATCH 06/24] ISSUE #434 * Remove `EventHandler` and `EventHandlerService`. --- minos/networks/__init__.py | 2 - minos/networks/brokers/__init__.py | 2 - .../networks/brokers/subscribers/__init__.py | 4 - .../brokers/subscribers/commands/handlers.py | 5 +- .../brokers/subscribers/events/__init__.py | 6 - .../brokers/subscribers/events/handlers.py | 116 ------------- .../brokers/subscribers/events/services.py | 52 ------ minos/networks/decorators/builders.py | 8 + .../test_commands/test_handlers.py | 40 ++++- .../test_subscribers/test_events/__init__.py | 1 - .../test_events/test_handlers.py | 162 ------------------ .../test_events/test_services.py | 62 ------- 12 files changed, 42 insertions(+), 418 deletions(-) delete mode 100644 minos/networks/brokers/subscribers/events/__init__.py delete mode 100644 minos/networks/brokers/subscribers/events/handlers.py delete mode 100644 minos/networks/brokers/subscribers/events/services.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index c0c65582..19cd8f73 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -16,8 +16,6 @@ DynamicHandler, DynamicHandlerPool, EventBroker, - EventHandler, - EventHandlerService, Handler, HandlerEntry, HandlerRequest, diff --git a/minos/networks/brokers/__init__.py b/minos/networks/brokers/__init__.py index b66b3d29..dfcb1ea0 100644 --- a/minos/networks/brokers/__init__.py +++ b/minos/networks/brokers/__init__.py @@ -18,8 +18,6 @@ ConsumerService, DynamicHandler, DynamicHandlerPool, - EventHandler, - EventHandlerService, Handler, HandlerEntry, HandlerRequest, diff --git a/minos/networks/brokers/subscribers/__init__.py b/minos/networks/brokers/subscribers/__init__.py index 166b87fe..d565de61 100644 --- a/minos/networks/brokers/subscribers/__init__.py +++ b/minos/networks/brokers/subscribers/__init__.py @@ -16,10 +16,6 @@ from .entries import ( HandlerEntry, ) -from .events import ( - EventHandler, - EventHandlerService, -) from .messages import ( HandlerRequest, HandlerResponse, diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index 9408ac09..fe9b0f4b 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -67,7 +67,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandHandler: @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: builder = EnrouteBuilder(*config.services) - decorators = builder.get_broker_command_query(config=config, **kwargs) + decorators = builder.get_broker_command_query_event(config=config, **kwargs) handlers = {decorator.topic: fn for decorator, fn in decorators.items()} return handlers @@ -83,7 +83,8 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: command = entry.data items, status = await fn(command) - await self.broker.send(items, topic=command.reply_topic, saga=command.identifier, status=status) + if command.reply_topic is not None: + await self.broker.send(items, topic=command.reply_topic, saga=command.identifier, status=status) @staticmethod def get_callback( diff --git a/minos/networks/brokers/subscribers/events/__init__.py b/minos/networks/brokers/subscribers/events/__init__.py deleted file mode 100644 index d5c144df..00000000 --- a/minos/networks/brokers/subscribers/events/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from .handlers import ( - EventHandler, -) -from .services import ( - EventHandlerService, -) diff --git a/minos/networks/brokers/subscribers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py deleted file mode 100644 index bd47feca..00000000 --- a/minos/networks/brokers/subscribers/events/handlers.py +++ /dev/null @@ -1,116 +0,0 @@ -from __future__ import ( - annotations, -) - -import logging -from asyncio import ( - gather, -) -from collections import ( - defaultdict, -) -from inspect import ( - isawaitable, -) -from operator import ( - attrgetter, -) -from typing import ( - Awaitable, - Callable, - Optional, -) - -from minos.common import ( - MinosConfig, -) - -from ....decorators import ( - EnrouteBuilder, -) -from ....messages import ( - ResponseException, -) -from ...messages import ( - BrokerMessage, -) -from ..abc import ( - Handler, -) -from ..entries import ( - HandlerEntry, -) -from ..messages import ( - HandlerRequest, -) - -logger = logging.getLogger(__name__) - -uuid_getter = attrgetter("data.data.uuid") -version_getter = attrgetter("data.data.version") - - -class EventHandler(Handler): - """Event Handler class.""" - - @classmethod - def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventHandler: - handlers = cls._handlers_from_config(config, **kwargs) - # noinspection PyProtectedMember - return cls(handlers=handlers, **config.broker.queue._asdict(), **kwargs) - - @staticmethod - def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: - builder = EnrouteBuilder(*config.services) - handlers = builder.get_broker_event(config=config, **kwargs) - handlers = {decorator.topic: fn for decorator, fn in handlers.items()} - return handlers - - async def _dispatch_entries(self, entries: list[HandlerEntry]) -> None: - grouped = defaultdict(list) - for entry in entries: - grouped[uuid_getter(entry)].append(entry) - - for group in grouped.values(): - group.sort(key=version_getter) - - futures = (self._dispatch_group(group) for group in grouped.values()) - await gather(*futures) - - async def _dispatch_group(self, entries: list[HandlerEntry]): - for entry in entries: - await self._dispatch_one(entry) - - async def dispatch_one(self, entry: HandlerEntry) -> None: - """Dispatch one row. - - :param entry: Entry to be dispatched. - :return: This method does not return anything. - """ - logger.info(f"Dispatching '{entry!s}'...") - - fn = self.get_callback(entry.callback) - await fn(entry.data) - - @staticmethod - def get_callback( - fn: Callable[[HandlerRequest], Optional[Awaitable[None]]] - ) -> Callable[[BrokerMessage], Awaitable[None]]: - """Get the handler function to be used by the Event Handler. - - :param fn: The action function. - :return: A wrapper function around the given one that is compatible with the Event Handler API. - """ - - async def _fn(raw: BrokerMessage) -> None: - try: - request = HandlerRequest(raw) - response = fn(request) - if isawaitable(response): - await response - except ResponseException as exc: - logger.warning(f"Raised an application exception: {exc!s}") - except Exception as exc: - logger.exception(f"Raised a system exception: {exc!r}") - - return _fn diff --git a/minos/networks/brokers/subscribers/events/services.py b/minos/networks/brokers/subscribers/events/services.py deleted file mode 100644 index ca5cc068..00000000 --- a/minos/networks/brokers/subscribers/events/services.py +++ /dev/null @@ -1,52 +0,0 @@ -import logging - -from aiomisc import ( - Service, -) -from cached_property import ( - cached_property, -) - -from .handlers import ( - EventHandler, -) - -logger = logging.getLogger(__name__) - - -class EventHandlerService(Service): - """Minos QueueDispatcherService class.""" - - def __init__(self, **kwargs): - super().__init__(**kwargs) - self._init_kwargs = kwargs - - async def start(self) -> None: - """Method to be called at the startup by the internal ``aiomisc`` loigc. - - :return: This method does not return anything. - """ - await self.dispatcher.setup() - - try: - self.start_event.set() - except RuntimeError: - logger.warning("Runtime is not properly setup.") - - await self.dispatcher.dispatch_forever() - - async def stop(self, err: Exception = None) -> None: - """Stop the service execution. - - :param err: Optional exception that stopped the execution. - :return: This method does not return anything. - """ - await self.dispatcher.destroy() - - @cached_property - def dispatcher(self) -> EventHandler: - """Get the service dispatcher. - - :return: A ``EventHandler`` instance. - """ - return EventHandler.from_config(**self._init_kwargs) diff --git a/minos/networks/decorators/builders.py b/minos/networks/decorators/builders.py index afcb88c7..64a74bc3 100644 --- a/minos/networks/decorators/builders.py +++ b/minos/networks/decorators/builders.py @@ -56,6 +56,14 @@ def get_rest_command_query(self, **kwargs) -> dict[RestEnrouteDecorator, Handler # noinspection PyTypeChecker return self._build("get_rest_command_query", **kwargs) + def get_broker_command_query_event(self, **kwargs): + """Get the broker handlers for commands, queries and events. + + :return: A dictionary with decorator classes as keys and callable handlers as values. + """ + # noinspection PyTypeChecker + return self._build("get_broker_command_query_event", **kwargs) + def get_broker_command_query(self, **kwargs) -> dict[BrokerEnrouteDecorator, Handler]: """Get the broker handlers for commands and queries. diff --git a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py index 3268f36e..baf14397 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py @@ -56,14 +56,17 @@ def setUp(self) -> None: self.broker = FakeBroker() self.handler = CommandHandler.from_config(config=self.config, broker=self.broker) self.user = uuid4() - self.request = BrokerMessage("AddOrder", FakeModel("foo"), identifier=self.user, reply_topic="UpdateTicket") + self.message = BrokerMessage("AddOrder", FakeModel("foo"), identifier=self.user, reply_topic="UpdateTicket") def test_from_config(self): broker = FakeBroker() handler = CommandHandler.from_config(config=self.config, broker=broker) self.assertIsInstance(handler, CommandHandler) - self.assertEqual({"GetOrder", "AddOrder", "DeleteOrder", "UpdateOrder"}, set(handler.handlers.keys())) + self.assertEqual( + {"GetOrder", "AddOrder", "DeleteOrder", "UpdateOrder", "TicketAdded", "TicketDeleted"}, + set(handler.handlers.keys()), + ) self.assertEqual(self.config.broker.queue.retry, handler._retry) self.assertEqual(self.config.broker.queue.host, handler.host) @@ -76,7 +79,7 @@ def test_from_config(self): async def test_dispatch(self): callback_mock = AsyncMock(return_value=Response("add_order")) lookup_mock = MagicMock(return_value=callback_mock) - entry = HandlerEntry(1, "AddOrder", 0, self.request.avro_bytes, 1, callback_lookup=lookup_mock) + entry = HandlerEntry(1, "AddOrder", 0, self.message.avro_bytes, 1, callback_lookup=lookup_mock) async with self.handler: await self.handler.dispatch_one(entry) @@ -87,7 +90,7 @@ async def test_dispatch(self): self.assertEqual(1, self.broker.call_count) self.assertEqual("add_order", self.broker.items) self.assertEqual("UpdateTicket", self.broker.topic) - self.assertEqual(self.request.identifier, self.broker.identifier) + self.assertEqual(self.message.identifier, self.broker.identifier) self.assertEqual(None, self.broker.reply_topic) self.assertEqual(BrokerMessageStatus.SUCCESS, self.broker.status) @@ -96,23 +99,42 @@ async def test_dispatch(self): self.assertIsInstance(observed, HandlerRequest) self.assertEqual(FakeModel("foo"), await observed.content()) + async def test_dispatch_without_reply(self): + message = BrokerMessage("AddOrder", FakeModel("foo")) + callback_mock = AsyncMock(return_value=Response("add_order")) + lookup_mock = MagicMock(return_value=callback_mock) + entry = HandlerEntry(1, "AddOrder", 0, message.avro_bytes, 1, callback_lookup=lookup_mock) + + async with self.handler: + await self.handler.dispatch_one(entry) + + self.assertEqual(1, lookup_mock.call_count) + self.assertEqual(call("AddOrder"), lookup_mock.call_args) + + self.assertEqual(0, self.broker.call_count) + + self.assertEqual(1, callback_mock.call_count) + observed = callback_mock.call_args[0][0] + self.assertIsInstance(observed, HandlerRequest) + self.assertEqual(FakeModel("foo"), await observed.content()) + async def test_get_callback(self): fn = self.handler.get_callback(_Cls._fn) - self.assertEqual((FakeModel("foo"), BrokerMessageStatus.SUCCESS), await fn(self.request)) + self.assertEqual((FakeModel("foo"), BrokerMessageStatus.SUCCESS), await fn(self.message)) async def test_get_callback_none(self): fn = self.handler.get_callback(_Cls._fn_none) - self.assertEqual((None, BrokerMessageStatus.SUCCESS), await fn(self.request)) + self.assertEqual((None, BrokerMessageStatus.SUCCESS), await fn(self.message)) async def test_get_callback_raises_response(self): fn = self.handler.get_callback(_Cls._fn_raises_response) expected = (repr(HandlerResponseException("foo")), BrokerMessageStatus.ERROR) - self.assertEqual(expected, await fn(self.request)) + self.assertEqual(expected, await fn(self.message)) async def test_get_callback_raises_exception(self): fn = self.handler.get_callback(_Cls._fn_raises_exception) expected = (repr(ValueError()), BrokerMessageStatus.SYSTEM_ERROR) - self.assertEqual(expected, await fn(self.request)) + self.assertEqual(expected, await fn(self.message)) async def test_get_callback_with_user(self): async def _fn(request) -> None: @@ -122,7 +144,7 @@ async def _fn(request) -> None: mock = AsyncMock(side_effect=_fn) handler = self.handler.get_callback(mock) - await handler(self.request) + await handler(self.message) self.assertEqual(1, mock.call_count) diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py deleted file mode 100644 index 8b137891..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py deleted file mode 100644 index 785b8298..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py +++ /dev/null @@ -1,162 +0,0 @@ -import unittest -from collections import ( - defaultdict, -) -from random import ( - shuffle, -) -from unittest.mock import ( - AsyncMock, - MagicMock, - call, -) -from uuid import ( - uuid4, -) - -import aiopg - -from minos.aggregate import ( - Action, - AggregateDiff, - FieldDiffContainer, -) -from minos.common import ( - current_datetime, -) -from minos.common.testing import ( - PostgresAsyncTestCase, -) -from minos.networks import ( - BrokerMessage, - EventHandler, - HandlerEntry, - HandlerRequest, - HandlerResponseException, - Request, -) -from tests.utils import ( - BASE_PATH, - FAKE_AGGREGATE_DIFF, -) - - -class _Cls: - @staticmethod - async def _fn(request: Request): - await request.content() - - @staticmethod - async def _fn_raises_response(request: Request): - raise HandlerResponseException("") - - @staticmethod - async def _fn_raises_exception(request: Request): - raise ValueError - - -class TestEventHandler(PostgresAsyncTestCase): - CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" - - def setUp(self) -> None: - super().setUp() - self.handler = EventHandler.from_config(config=self.config) - self.event = BrokerMessage("TicketAdded", FAKE_AGGREGATE_DIFF) - - def test_from_config(self): - self.assertIsInstance(self.handler, EventHandler) - - self.assertEqual({"TicketAdded", "TicketDeleted"}, set(self.handler.handlers.keys())) - - self.assertEqual(self.config.broker.queue.records, self.handler._records) - self.assertEqual(self.config.broker.queue.retry, self.handler._retry) - self.assertEqual(self.config.broker.queue.host, self.handler.host) - self.assertEqual(self.config.broker.queue.port, self.handler.port) - self.assertEqual(self.config.broker.queue.database, self.handler.database) - self.assertEqual(self.config.broker.queue.user, self.handler.user) - self.assertEqual(self.config.broker.queue.password, self.handler.password) - - async def test_handlers(self): - self.assertEqual( - {"query_service_ticket_added", "command_service_ticket_added"}, - set(await self.handler.handlers["TicketAdded"](None)), - ) - self.assertEqual("ticket_deleted", await self.handler.handlers["TicketDeleted"](None)) - - async def test_dispatch_one(self): - callback_mock = AsyncMock() - lookup_mock = MagicMock(return_value=callback_mock) - - topic = "TicketAdded" - event = BrokerMessage(topic, FAKE_AGGREGATE_DIFF) - entry = HandlerEntry(1, topic, 0, event.avro_bytes, 1, callback_lookup=lookup_mock) - - async with self.handler: - await self.handler.dispatch_one(entry) - - self.assertEqual(1, lookup_mock.call_count) - self.assertEqual(call("TicketAdded"), lookup_mock.call_args) - - self.assertEqual(1, callback_mock.call_count) - self.assertEqual(call(HandlerRequest(event)), callback_mock.call_args) - - async def test_get_callback(self): - fn = self.handler.get_callback(_Cls._fn) - await fn(self.event) - - async def test_get_callback_raises_response(self): - fn = self.handler.get_callback(_Cls._fn_raises_response) - await fn(self.event) - - async def test_get_callback_raises_exception(self): - fn = self.handler.get_callback(_Cls._fn_raises_exception) - await fn(self.event) - - async def test_dispatch_concurrent(self): - observed = defaultdict(list) - - async def _fn2(request): - diff = await request.content() - observed[diff.uuid].append(diff.version) - - self.handler.get_action = MagicMock(return_value=_fn2) - - uuid1, uuid2 = uuid4(), uuid4() - - events = list() - for i in range(1, 6): - events.extend( - [ - BrokerMessage( - "TicketAdded", - AggregateDiff(uuid1, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), - ), - BrokerMessage( - "TicketAdded", - AggregateDiff(uuid2, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), - ), - ] - ) - shuffle(events) - - async with self.handler: - for event in events: - await self._insert_one(event) - - await self.handler.dispatch() - - expected = {uuid1: list(range(1, 6)), uuid2: list(range(1, 6))} - self.assertEqual(expected, observed) - - async def _insert_one(self, instance): - async with aiopg.connect(**self.broker_queue_db) as connect: - async with connect.cursor() as cur: - await cur.execute( - "INSERT INTO consumer_queue (topic, partition, data) VALUES (%s, %s, %s) RETURNING id;", - (instance.topic, 0, instance.avro_bytes), - ) - return (await cur.fetchone())[0] - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py deleted file mode 100644 index 6c3c1ff2..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py +++ /dev/null @@ -1,62 +0,0 @@ -import unittest -from unittest.mock import ( - AsyncMock, -) - -from aiomisc import ( - Service, -) - -from minos.common.testing import ( - PostgresAsyncTestCase, -) -from minos.networks import ( - EventHandler, - EventHandlerService, -) -from tests.utils import ( - BASE_PATH, -) - - -class TestEventHandlerService(PostgresAsyncTestCase): - CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" - - def test_is_instance(self): - service = EventHandlerService(config=self.config) - self.assertIsInstance(service, Service) - - def test_dispatcher(self): - service = EventHandlerService(config=self.config) - self.assertIsInstance(service.dispatcher, EventHandler) - - async def test_start_stop(self): - service = EventHandlerService(config=self.config) - - setup_mock = AsyncMock() - destroy_mock = AsyncMock() - dispatch_forever_mock = AsyncMock() - - service.dispatcher.setup = setup_mock - service.dispatcher.destroy = destroy_mock - service.dispatcher.dispatch_forever = dispatch_forever_mock - - await service.start() - - self.assertEqual(1, setup_mock.call_count) - self.assertEqual(1, dispatch_forever_mock.call_count) - self.assertEqual(0, destroy_mock.call_count) - - setup_mock.reset_mock() - destroy_mock.reset_mock() - dispatch_forever_mock.reset_mock() - - await service.stop() - - self.assertEqual(0, setup_mock.call_count) - self.assertEqual(0, dispatch_forever_mock.call_count) - self.assertEqual(1, destroy_mock.call_count) - - -if __name__ == "__main__": - unittest.main() From f18c01ab55f209ea5c009ca4c9d78f10ad870e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Thu, 11 Nov 2021 09:16:06 +0100 Subject: [PATCH 07/24] Revert "ISSUE #434" This reverts commit 06cd8b39a02c3efd923e43a8ad37366e5a7ae155. --- minos/networks/__init__.py | 2 + minos/networks/brokers/__init__.py | 2 + .../networks/brokers/subscribers/__init__.py | 4 + .../brokers/subscribers/commands/handlers.py | 5 +- .../brokers/subscribers/events/__init__.py | 6 + .../brokers/subscribers/events/handlers.py | 116 +++++++++++++ .../brokers/subscribers/events/services.py | 52 ++++++ minos/networks/decorators/builders.py | 8 - .../test_commands/test_handlers.py | 40 +---- .../test_subscribers/test_events/__init__.py | 1 + .../test_events/test_handlers.py | 162 ++++++++++++++++++ .../test_events/test_services.py | 62 +++++++ 12 files changed, 418 insertions(+), 42 deletions(-) create mode 100644 minos/networks/brokers/subscribers/events/__init__.py create mode 100644 minos/networks/brokers/subscribers/events/handlers.py create mode 100644 minos/networks/brokers/subscribers/events/services.py create mode 100644 tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py create mode 100644 tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py create mode 100644 tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index 19cd8f73..c0c65582 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -16,6 +16,8 @@ DynamicHandler, DynamicHandlerPool, EventBroker, + EventHandler, + EventHandlerService, Handler, HandlerEntry, HandlerRequest, diff --git a/minos/networks/brokers/__init__.py b/minos/networks/brokers/__init__.py index dfcb1ea0..b66b3d29 100644 --- a/minos/networks/brokers/__init__.py +++ b/minos/networks/brokers/__init__.py @@ -18,6 +18,8 @@ ConsumerService, DynamicHandler, DynamicHandlerPool, + EventHandler, + EventHandlerService, Handler, HandlerEntry, HandlerRequest, diff --git a/minos/networks/brokers/subscribers/__init__.py b/minos/networks/brokers/subscribers/__init__.py index d565de61..166b87fe 100644 --- a/minos/networks/brokers/subscribers/__init__.py +++ b/minos/networks/brokers/subscribers/__init__.py @@ -16,6 +16,10 @@ from .entries import ( HandlerEntry, ) +from .events import ( + EventHandler, + EventHandlerService, +) from .messages import ( HandlerRequest, HandlerResponse, diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index fe9b0f4b..9408ac09 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -67,7 +67,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandHandler: @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: builder = EnrouteBuilder(*config.services) - decorators = builder.get_broker_command_query_event(config=config, **kwargs) + decorators = builder.get_broker_command_query(config=config, **kwargs) handlers = {decorator.topic: fn for decorator, fn in decorators.items()} return handlers @@ -83,8 +83,7 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: command = entry.data items, status = await fn(command) - if command.reply_topic is not None: - await self.broker.send(items, topic=command.reply_topic, saga=command.identifier, status=status) + await self.broker.send(items, topic=command.reply_topic, saga=command.identifier, status=status) @staticmethod def get_callback( diff --git a/minos/networks/brokers/subscribers/events/__init__.py b/minos/networks/brokers/subscribers/events/__init__.py new file mode 100644 index 00000000..d5c144df --- /dev/null +++ b/minos/networks/brokers/subscribers/events/__init__.py @@ -0,0 +1,6 @@ +from .handlers import ( + EventHandler, +) +from .services import ( + EventHandlerService, +) diff --git a/minos/networks/brokers/subscribers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py new file mode 100644 index 00000000..bd47feca --- /dev/null +++ b/minos/networks/brokers/subscribers/events/handlers.py @@ -0,0 +1,116 @@ +from __future__ import ( + annotations, +) + +import logging +from asyncio import ( + gather, +) +from collections import ( + defaultdict, +) +from inspect import ( + isawaitable, +) +from operator import ( + attrgetter, +) +from typing import ( + Awaitable, + Callable, + Optional, +) + +from minos.common import ( + MinosConfig, +) + +from ....decorators import ( + EnrouteBuilder, +) +from ....messages import ( + ResponseException, +) +from ...messages import ( + BrokerMessage, +) +from ..abc import ( + Handler, +) +from ..entries import ( + HandlerEntry, +) +from ..messages import ( + HandlerRequest, +) + +logger = logging.getLogger(__name__) + +uuid_getter = attrgetter("data.data.uuid") +version_getter = attrgetter("data.data.version") + + +class EventHandler(Handler): + """Event Handler class.""" + + @classmethod + def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventHandler: + handlers = cls._handlers_from_config(config, **kwargs) + # noinspection PyProtectedMember + return cls(handlers=handlers, **config.broker.queue._asdict(), **kwargs) + + @staticmethod + def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: + builder = EnrouteBuilder(*config.services) + handlers = builder.get_broker_event(config=config, **kwargs) + handlers = {decorator.topic: fn for decorator, fn in handlers.items()} + return handlers + + async def _dispatch_entries(self, entries: list[HandlerEntry]) -> None: + grouped = defaultdict(list) + for entry in entries: + grouped[uuid_getter(entry)].append(entry) + + for group in grouped.values(): + group.sort(key=version_getter) + + futures = (self._dispatch_group(group) for group in grouped.values()) + await gather(*futures) + + async def _dispatch_group(self, entries: list[HandlerEntry]): + for entry in entries: + await self._dispatch_one(entry) + + async def dispatch_one(self, entry: HandlerEntry) -> None: + """Dispatch one row. + + :param entry: Entry to be dispatched. + :return: This method does not return anything. + """ + logger.info(f"Dispatching '{entry!s}'...") + + fn = self.get_callback(entry.callback) + await fn(entry.data) + + @staticmethod + def get_callback( + fn: Callable[[HandlerRequest], Optional[Awaitable[None]]] + ) -> Callable[[BrokerMessage], Awaitable[None]]: + """Get the handler function to be used by the Event Handler. + + :param fn: The action function. + :return: A wrapper function around the given one that is compatible with the Event Handler API. + """ + + async def _fn(raw: BrokerMessage) -> None: + try: + request = HandlerRequest(raw) + response = fn(request) + if isawaitable(response): + await response + except ResponseException as exc: + logger.warning(f"Raised an application exception: {exc!s}") + except Exception as exc: + logger.exception(f"Raised a system exception: {exc!r}") + + return _fn diff --git a/minos/networks/brokers/subscribers/events/services.py b/minos/networks/brokers/subscribers/events/services.py new file mode 100644 index 00000000..ca5cc068 --- /dev/null +++ b/minos/networks/brokers/subscribers/events/services.py @@ -0,0 +1,52 @@ +import logging + +from aiomisc import ( + Service, +) +from cached_property import ( + cached_property, +) + +from .handlers import ( + EventHandler, +) + +logger = logging.getLogger(__name__) + + +class EventHandlerService(Service): + """Minos QueueDispatcherService class.""" + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self._init_kwargs = kwargs + + async def start(self) -> None: + """Method to be called at the startup by the internal ``aiomisc`` loigc. + + :return: This method does not return anything. + """ + await self.dispatcher.setup() + + try: + self.start_event.set() + except RuntimeError: + logger.warning("Runtime is not properly setup.") + + await self.dispatcher.dispatch_forever() + + async def stop(self, err: Exception = None) -> None: + """Stop the service execution. + + :param err: Optional exception that stopped the execution. + :return: This method does not return anything. + """ + await self.dispatcher.destroy() + + @cached_property + def dispatcher(self) -> EventHandler: + """Get the service dispatcher. + + :return: A ``EventHandler`` instance. + """ + return EventHandler.from_config(**self._init_kwargs) diff --git a/minos/networks/decorators/builders.py b/minos/networks/decorators/builders.py index 64a74bc3..afcb88c7 100644 --- a/minos/networks/decorators/builders.py +++ b/minos/networks/decorators/builders.py @@ -56,14 +56,6 @@ def get_rest_command_query(self, **kwargs) -> dict[RestEnrouteDecorator, Handler # noinspection PyTypeChecker return self._build("get_rest_command_query", **kwargs) - def get_broker_command_query_event(self, **kwargs): - """Get the broker handlers for commands, queries and events. - - :return: A dictionary with decorator classes as keys and callable handlers as values. - """ - # noinspection PyTypeChecker - return self._build("get_broker_command_query_event", **kwargs) - def get_broker_command_query(self, **kwargs) -> dict[BrokerEnrouteDecorator, Handler]: """Get the broker handlers for commands and queries. diff --git a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py index baf14397..3268f36e 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py @@ -56,17 +56,14 @@ def setUp(self) -> None: self.broker = FakeBroker() self.handler = CommandHandler.from_config(config=self.config, broker=self.broker) self.user = uuid4() - self.message = BrokerMessage("AddOrder", FakeModel("foo"), identifier=self.user, reply_topic="UpdateTicket") + self.request = BrokerMessage("AddOrder", FakeModel("foo"), identifier=self.user, reply_topic="UpdateTicket") def test_from_config(self): broker = FakeBroker() handler = CommandHandler.from_config(config=self.config, broker=broker) self.assertIsInstance(handler, CommandHandler) - self.assertEqual( - {"GetOrder", "AddOrder", "DeleteOrder", "UpdateOrder", "TicketAdded", "TicketDeleted"}, - set(handler.handlers.keys()), - ) + self.assertEqual({"GetOrder", "AddOrder", "DeleteOrder", "UpdateOrder"}, set(handler.handlers.keys())) self.assertEqual(self.config.broker.queue.retry, handler._retry) self.assertEqual(self.config.broker.queue.host, handler.host) @@ -79,7 +76,7 @@ def test_from_config(self): async def test_dispatch(self): callback_mock = AsyncMock(return_value=Response("add_order")) lookup_mock = MagicMock(return_value=callback_mock) - entry = HandlerEntry(1, "AddOrder", 0, self.message.avro_bytes, 1, callback_lookup=lookup_mock) + entry = HandlerEntry(1, "AddOrder", 0, self.request.avro_bytes, 1, callback_lookup=lookup_mock) async with self.handler: await self.handler.dispatch_one(entry) @@ -90,7 +87,7 @@ async def test_dispatch(self): self.assertEqual(1, self.broker.call_count) self.assertEqual("add_order", self.broker.items) self.assertEqual("UpdateTicket", self.broker.topic) - self.assertEqual(self.message.identifier, self.broker.identifier) + self.assertEqual(self.request.identifier, self.broker.identifier) self.assertEqual(None, self.broker.reply_topic) self.assertEqual(BrokerMessageStatus.SUCCESS, self.broker.status) @@ -99,42 +96,23 @@ async def test_dispatch(self): self.assertIsInstance(observed, HandlerRequest) self.assertEqual(FakeModel("foo"), await observed.content()) - async def test_dispatch_without_reply(self): - message = BrokerMessage("AddOrder", FakeModel("foo")) - callback_mock = AsyncMock(return_value=Response("add_order")) - lookup_mock = MagicMock(return_value=callback_mock) - entry = HandlerEntry(1, "AddOrder", 0, message.avro_bytes, 1, callback_lookup=lookup_mock) - - async with self.handler: - await self.handler.dispatch_one(entry) - - self.assertEqual(1, lookup_mock.call_count) - self.assertEqual(call("AddOrder"), lookup_mock.call_args) - - self.assertEqual(0, self.broker.call_count) - - self.assertEqual(1, callback_mock.call_count) - observed = callback_mock.call_args[0][0] - self.assertIsInstance(observed, HandlerRequest) - self.assertEqual(FakeModel("foo"), await observed.content()) - async def test_get_callback(self): fn = self.handler.get_callback(_Cls._fn) - self.assertEqual((FakeModel("foo"), BrokerMessageStatus.SUCCESS), await fn(self.message)) + self.assertEqual((FakeModel("foo"), BrokerMessageStatus.SUCCESS), await fn(self.request)) async def test_get_callback_none(self): fn = self.handler.get_callback(_Cls._fn_none) - self.assertEqual((None, BrokerMessageStatus.SUCCESS), await fn(self.message)) + self.assertEqual((None, BrokerMessageStatus.SUCCESS), await fn(self.request)) async def test_get_callback_raises_response(self): fn = self.handler.get_callback(_Cls._fn_raises_response) expected = (repr(HandlerResponseException("foo")), BrokerMessageStatus.ERROR) - self.assertEqual(expected, await fn(self.message)) + self.assertEqual(expected, await fn(self.request)) async def test_get_callback_raises_exception(self): fn = self.handler.get_callback(_Cls._fn_raises_exception) expected = (repr(ValueError()), BrokerMessageStatus.SYSTEM_ERROR) - self.assertEqual(expected, await fn(self.message)) + self.assertEqual(expected, await fn(self.request)) async def test_get_callback_with_user(self): async def _fn(request) -> None: @@ -144,7 +122,7 @@ async def _fn(request) -> None: mock = AsyncMock(side_effect=_fn) handler = self.handler.get_callback(mock) - await handler(self.message) + await handler(self.request) self.assertEqual(1, mock.call_count) diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/test_networks/test_brokers/test_subscribers/test_events/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py new file mode 100644 index 00000000..785b8298 --- /dev/null +++ b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py @@ -0,0 +1,162 @@ +import unittest +from collections import ( + defaultdict, +) +from random import ( + shuffle, +) +from unittest.mock import ( + AsyncMock, + MagicMock, + call, +) +from uuid import ( + uuid4, +) + +import aiopg + +from minos.aggregate import ( + Action, + AggregateDiff, + FieldDiffContainer, +) +from minos.common import ( + current_datetime, +) +from minos.common.testing import ( + PostgresAsyncTestCase, +) +from minos.networks import ( + BrokerMessage, + EventHandler, + HandlerEntry, + HandlerRequest, + HandlerResponseException, + Request, +) +from tests.utils import ( + BASE_PATH, + FAKE_AGGREGATE_DIFF, +) + + +class _Cls: + @staticmethod + async def _fn(request: Request): + await request.content() + + @staticmethod + async def _fn_raises_response(request: Request): + raise HandlerResponseException("") + + @staticmethod + async def _fn_raises_exception(request: Request): + raise ValueError + + +class TestEventHandler(PostgresAsyncTestCase): + CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" + + def setUp(self) -> None: + super().setUp() + self.handler = EventHandler.from_config(config=self.config) + self.event = BrokerMessage("TicketAdded", FAKE_AGGREGATE_DIFF) + + def test_from_config(self): + self.assertIsInstance(self.handler, EventHandler) + + self.assertEqual({"TicketAdded", "TicketDeleted"}, set(self.handler.handlers.keys())) + + self.assertEqual(self.config.broker.queue.records, self.handler._records) + self.assertEqual(self.config.broker.queue.retry, self.handler._retry) + self.assertEqual(self.config.broker.queue.host, self.handler.host) + self.assertEqual(self.config.broker.queue.port, self.handler.port) + self.assertEqual(self.config.broker.queue.database, self.handler.database) + self.assertEqual(self.config.broker.queue.user, self.handler.user) + self.assertEqual(self.config.broker.queue.password, self.handler.password) + + async def test_handlers(self): + self.assertEqual( + {"query_service_ticket_added", "command_service_ticket_added"}, + set(await self.handler.handlers["TicketAdded"](None)), + ) + self.assertEqual("ticket_deleted", await self.handler.handlers["TicketDeleted"](None)) + + async def test_dispatch_one(self): + callback_mock = AsyncMock() + lookup_mock = MagicMock(return_value=callback_mock) + + topic = "TicketAdded" + event = BrokerMessage(topic, FAKE_AGGREGATE_DIFF) + entry = HandlerEntry(1, topic, 0, event.avro_bytes, 1, callback_lookup=lookup_mock) + + async with self.handler: + await self.handler.dispatch_one(entry) + + self.assertEqual(1, lookup_mock.call_count) + self.assertEqual(call("TicketAdded"), lookup_mock.call_args) + + self.assertEqual(1, callback_mock.call_count) + self.assertEqual(call(HandlerRequest(event)), callback_mock.call_args) + + async def test_get_callback(self): + fn = self.handler.get_callback(_Cls._fn) + await fn(self.event) + + async def test_get_callback_raises_response(self): + fn = self.handler.get_callback(_Cls._fn_raises_response) + await fn(self.event) + + async def test_get_callback_raises_exception(self): + fn = self.handler.get_callback(_Cls._fn_raises_exception) + await fn(self.event) + + async def test_dispatch_concurrent(self): + observed = defaultdict(list) + + async def _fn2(request): + diff = await request.content() + observed[diff.uuid].append(diff.version) + + self.handler.get_action = MagicMock(return_value=_fn2) + + uuid1, uuid2 = uuid4(), uuid4() + + events = list() + for i in range(1, 6): + events.extend( + [ + BrokerMessage( + "TicketAdded", + AggregateDiff(uuid1, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), + ), + BrokerMessage( + "TicketAdded", + AggregateDiff(uuid2, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), + ), + ] + ) + shuffle(events) + + async with self.handler: + for event in events: + await self._insert_one(event) + + await self.handler.dispatch() + + expected = {uuid1: list(range(1, 6)), uuid2: list(range(1, 6))} + self.assertEqual(expected, observed) + + async def _insert_one(self, instance): + async with aiopg.connect(**self.broker_queue_db) as connect: + async with connect.cursor() as cur: + await cur.execute( + "INSERT INTO consumer_queue (topic, partition, data) VALUES (%s, %s, %s) RETURNING id;", + (instance.topic, 0, instance.avro_bytes), + ) + return (await cur.fetchone())[0] + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py new file mode 100644 index 00000000..6c3c1ff2 --- /dev/null +++ b/tests/test_networks/test_brokers/test_subscribers/test_events/test_services.py @@ -0,0 +1,62 @@ +import unittest +from unittest.mock import ( + AsyncMock, +) + +from aiomisc import ( + Service, +) + +from minos.common.testing import ( + PostgresAsyncTestCase, +) +from minos.networks import ( + EventHandler, + EventHandlerService, +) +from tests.utils import ( + BASE_PATH, +) + + +class TestEventHandlerService(PostgresAsyncTestCase): + CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" + + def test_is_instance(self): + service = EventHandlerService(config=self.config) + self.assertIsInstance(service, Service) + + def test_dispatcher(self): + service = EventHandlerService(config=self.config) + self.assertIsInstance(service.dispatcher, EventHandler) + + async def test_start_stop(self): + service = EventHandlerService(config=self.config) + + setup_mock = AsyncMock() + destroy_mock = AsyncMock() + dispatch_forever_mock = AsyncMock() + + service.dispatcher.setup = setup_mock + service.dispatcher.destroy = destroy_mock + service.dispatcher.dispatch_forever = dispatch_forever_mock + + await service.start() + + self.assertEqual(1, setup_mock.call_count) + self.assertEqual(1, dispatch_forever_mock.call_count) + self.assertEqual(0, destroy_mock.call_count) + + setup_mock.reset_mock() + destroy_mock.reset_mock() + dispatch_forever_mock.reset_mock() + + await service.stop() + + self.assertEqual(0, setup_mock.call_count) + self.assertEqual(0, dispatch_forever_mock.call_count) + self.assertEqual(1, destroy_mock.call_count) + + +if __name__ == "__main__": + unittest.main() From 683c788fcf235ddde33cf80566559ad6da8a362d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Thu, 11 Nov 2021 09:16:06 +0100 Subject: [PATCH 08/24] Revert "ISSUE #434" This reverts commit d00281ae5a4ec73309d7545fcae2a42fd6cd4299. --- minos/networks/__init__.py | 3 + minos/networks/brokers/__init__.py | 3 + minos/networks/brokers/publishers/__init__.py | 3 + .../brokers/publishers/command_replies.py | 54 +++++++++++++++ .../networks/brokers/subscribers/__init__.py | 4 ++ .../subscribers/command_replies/__init__.py | 6 ++ .../subscribers/command_replies/handlers.py | 52 ++++++++++++++ .../subscribers/command_replies/services.py | 52 ++++++++++++++ .../brokers/subscribers/commands/handlers.py | 2 +- .../test_publishers/test_command_replies.py | 64 +++++++++++++++++ .../test_publishers/test_producers.py | 17 ++--- .../test_command_replies/__init__.py | 1 + .../test_command_replies/test_handlers.py | 68 +++++++++++++++++++ .../test_command_replies/test_services.py | 62 +++++++++++++++++ 14 files changed, 382 insertions(+), 9 deletions(-) create mode 100644 minos/networks/brokers/publishers/command_replies.py create mode 100644 minos/networks/brokers/subscribers/command_replies/__init__.py create mode 100644 minos/networks/brokers/subscribers/command_replies/handlers.py create mode 100644 minos/networks/brokers/subscribers/command_replies/services.py create mode 100644 tests/test_networks/test_brokers/test_publishers/test_command_replies.py create mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py create mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py create mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index c0c65582..f74faf2a 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -11,6 +11,9 @@ CommandBroker, CommandHandler, CommandHandlerService, + CommandReplyBroker, + CommandReplyHandler, + CommandReplyHandlerService, Consumer, ConsumerService, DynamicHandler, diff --git a/minos/networks/brokers/__init__.py b/minos/networks/brokers/__init__.py index b66b3d29..6365d8c3 100644 --- a/minos/networks/brokers/__init__.py +++ b/minos/networks/brokers/__init__.py @@ -7,6 +7,7 @@ Broker, BrokerSetup, CommandBroker, + CommandReplyBroker, EventBroker, Producer, ProducerService, @@ -14,6 +15,8 @@ from .subscribers import ( CommandHandler, CommandHandlerService, + CommandReplyHandler, + CommandReplyHandlerService, Consumer, ConsumerService, DynamicHandler, diff --git a/minos/networks/brokers/publishers/__init__.py b/minos/networks/brokers/publishers/__init__.py index a34a1a40..af2120b4 100644 --- a/minos/networks/brokers/publishers/__init__.py +++ b/minos/networks/brokers/publishers/__init__.py @@ -2,6 +2,9 @@ Broker, BrokerSetup, ) +from .command_replies import ( + CommandReplyBroker, +) from .commands import ( CommandBroker, ) diff --git a/minos/networks/brokers/publishers/command_replies.py b/minos/networks/brokers/publishers/command_replies.py new file mode 100644 index 00000000..842f4dee --- /dev/null +++ b/minos/networks/brokers/publishers/command_replies.py @@ -0,0 +1,54 @@ +from __future__ import ( + annotations, +) + +import logging +from typing import ( + Any, +) +from uuid import ( + UUID, +) + +from minos.common import ( + MinosConfig, +) + +from ..messages import ( + BrokerMessage, + BrokerMessageStatus, +) +from .abc import ( + Broker, +) + +logger = logging.getLogger(__name__) + + +class CommandReplyBroker(Broker): + """Minos Command Broker Class.""" + + ACTION = "commandReply" + + def __init__(self, *args, service_name: str, **kwargs): + super().__init__(*args, **kwargs) + self.service_name = service_name + + @classmethod + def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyBroker: + return cls(*args, service_name=config.service.name, **config.broker.queue._asdict(), **kwargs) + + # noinspection PyMethodOverriding + async def send(self, data: Any, topic: str, saga: UUID, status: BrokerMessageStatus, **kwargs) -> int: + """Send a ``CommandReply``. + + :param data: The data to be send. + :param topic: Topic in which the message will be published. + :param saga: Saga identifier. + :param status: command status. + :return: This method does not return anything. + """ + + request = BrokerMessage(topic, data, identifier=saga, status=status, service_name=self.service_name) + logger.info(f"Sending '{request!s}'...") + return await self.enqueue(request.topic, request.avro_bytes) diff --git a/minos/networks/brokers/subscribers/__init__.py b/minos/networks/brokers/subscribers/__init__.py index 166b87fe..021aad98 100644 --- a/minos/networks/brokers/subscribers/__init__.py +++ b/minos/networks/brokers/subscribers/__init__.py @@ -2,6 +2,10 @@ Handler, HandlerSetup, ) +from .command_replies import ( + CommandReplyHandler, + CommandReplyHandlerService, +) from .commands import ( CommandHandler, CommandHandlerService, diff --git a/minos/networks/brokers/subscribers/command_replies/__init__.py b/minos/networks/brokers/subscribers/command_replies/__init__.py new file mode 100644 index 00000000..99238638 --- /dev/null +++ b/minos/networks/brokers/subscribers/command_replies/__init__.py @@ -0,0 +1,6 @@ +from .handlers import ( + CommandReplyHandler, +) +from .services import ( + CommandReplyHandlerService, +) diff --git a/minos/networks/brokers/subscribers/command_replies/handlers.py b/minos/networks/brokers/subscribers/command_replies/handlers.py new file mode 100644 index 00000000..112c5996 --- /dev/null +++ b/minos/networks/brokers/subscribers/command_replies/handlers.py @@ -0,0 +1,52 @@ +from __future__ import ( + annotations, +) + +import logging +from typing import ( + Any, +) + +from dependency_injector.wiring import ( + Provide, + inject, +) + +from minos.common import ( + MinosConfig, + MinosSagaManager, +) + +from ..abc import ( + Handler, +) +from ..entries import ( + HandlerEntry, +) + +logger = logging.getLogger(__name__) + + +class CommandReplyHandler(Handler): + """Command Reply Handler class.""" + + @inject + def __init__(self, saga_manager: MinosSagaManager = Provide["saga_manager"], **kwargs: Any): + super().__init__(**kwargs) + + self.saga_manager = saga_manager + + @classmethod + def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyHandler: + handlers = {f"{config.service.name}Reply": None} + # noinspection PyProtectedMember + return cls(*args, handlers=handlers, **config.broker.queue._asdict(), **kwargs) + + async def dispatch_one(self, entry: HandlerEntry) -> None: + """Dispatch one row. + + :param entry: Entry to be dispatched. + :return: This method does not return anything. + """ + logger.info(f"Dispatching '{entry!s}'...") + await self.saga_manager.run(reply=entry.data, pause_on_disk=True, raise_on_error=False, return_execution=False) diff --git a/minos/networks/brokers/subscribers/command_replies/services.py b/minos/networks/brokers/subscribers/command_replies/services.py new file mode 100644 index 00000000..a4c7e376 --- /dev/null +++ b/minos/networks/brokers/subscribers/command_replies/services.py @@ -0,0 +1,52 @@ +import logging + +from aiomisc import ( + Service, +) +from cached_property import ( + cached_property, +) + +from .handlers import ( + CommandReplyHandler, +) + +logger = logging.getLogger(__name__) + + +class CommandReplyHandlerService(Service): + """Minos QueueDispatcherService class.""" + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self._init_kwargs = kwargs + + async def start(self) -> None: + """Method to be called at the startup by the internal ``aiomisc`` loigc. + + :return: This method does not return anything. + """ + await self.dispatcher.setup() + + try: + self.start_event.set() + except RuntimeError: + logger.warning("Runtime is not properly setup.") + + await self.dispatcher.dispatch_forever() + + async def stop(self, err: Exception = None) -> None: + """Stop the service execution. + + :param err: Optional exception that stopped the execution. + :return: This method does not return anything. + """ + await self.dispatcher.destroy() + + @cached_property + def dispatcher(self) -> CommandReplyHandler: + """Get the service dispatcher. + + :return: A ``CommandReplyHandler`` instance. + """ + return CommandReplyHandler.from_config(**self._init_kwargs) diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index 9408ac09..01896a4e 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -54,7 +54,7 @@ class CommandHandler(Handler): """Command Handler class.""" @inject - def __init__(self, broker: MinosBroker = Provide["command_broker"], **kwargs: Any): + def __init__(self, broker: MinosBroker = Provide["command_reply_broker"], **kwargs: Any): super().__init__(**kwargs) self.broker = broker diff --git a/tests/test_networks/test_brokers/test_publishers/test_command_replies.py b/tests/test_networks/test_brokers/test_publishers/test_command_replies.py new file mode 100644 index 00000000..fecda921 --- /dev/null +++ b/tests/test_networks/test_brokers/test_publishers/test_command_replies.py @@ -0,0 +1,64 @@ +import unittest +from unittest.mock import ( + AsyncMock, +) +from uuid import ( + uuid4, +) + +from minos.common import ( + Model, +) +from minos.common.testing import ( + PostgresAsyncTestCase, +) +from minos.networks import ( + BrokerMessage, + BrokerMessageStatus, + CommandReplyBroker, +) +from tests.utils import ( + BASE_PATH, + FakeModel, +) + + +class TestCommandReplyBroker(PostgresAsyncTestCase): + CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" + + def test_from_config_default(self): + broker = CommandReplyBroker.from_config(config=self.config) + self.assertIsInstance(broker, CommandReplyBroker) + + def test_action(self): + self.assertEqual("commandReply", CommandReplyBroker.ACTION) + + async def test_send(self): + mock = AsyncMock(return_value=56) + saga = uuid4() + reply_topic = "fakeReply" + async with CommandReplyBroker.from_config(config=self.config) as broker: + broker.enqueue = mock + identifier = await broker.send( + FakeModel("foo"), saga=saga, topic=reply_topic, status=BrokerMessageStatus.SUCCESS + ) + + self.assertEqual(56, identifier) + self.assertEqual(1, mock.call_count) + + args = mock.call_args.args + self.assertEqual(reply_topic, args[0]) + + expected = BrokerMessage( + reply_topic, + FakeModel("foo"), + identifier=saga, + status=BrokerMessageStatus.SUCCESS, + service_name=self.config.service.name, + ) + observed = Model.from_avro_bytes(args[1]) + self.assertEqual(expected, observed) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_networks/test_brokers/test_publishers/test_producers.py b/tests/test_networks/test_brokers/test_publishers/test_producers.py index 135238c1..72cc1149 100644 --- a/tests/test_networks/test_brokers/test_publishers/test_producers.py +++ b/tests/test_networks/test_brokers/test_publishers/test_producers.py @@ -20,6 +20,7 @@ from minos.networks import ( BrokerMessageStatus, CommandBroker, + CommandReplyBroker, Consumer, EventBroker, Producer, @@ -132,9 +133,13 @@ async def test_concurrency_dispatcher(self): saga = uuid4() command_broker = CommandBroker.from_config(config=self.config) + command_reply_broker = CommandReplyBroker.from_config(config=self.config) event_broker = EventBroker.from_config(config=self.config) for x in range(0, 20): + async with command_reply_broker: + await command_reply_broker.send(model, "TestDeleteReply", saga, BrokerMessageStatus.SUCCESS) + async with command_broker: await command_broker.send(model, "CommandBroker-Delete", saga, "TestDeleteReply") @@ -146,7 +151,7 @@ async def test_concurrency_dispatcher(self): await cur.execute("SELECT COUNT(*) FROM producer_queue") records = await cur.fetchone() - assert records[0] == 40 + assert records[0] == 60 async with self.producer: await asyncio.gather(*(self.producer.dispatch() for _ in range(6))) @@ -179,13 +184,9 @@ async def test_if_commands_retry_was_incremented(self): model = FakeModel("foo") saga = uuid4() - async with CommandBroker.from_config(config=self.config) as broker: - queue_id_1 = await broker.send( - model, "TestDeleteOrderReply", identifier=saga, status=BrokerMessageStatus.SUCCESS - ) - queue_id_2 = await broker.send( - model, "TestDeleteOrderReply", identifier=saga, status=BrokerMessageStatus.SUCCESS - ) + async with CommandReplyBroker.from_config(config=self.config) as broker: + queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) + queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) async with self.producer: self.producer.publish = AsyncMock(return_value=False) diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py new file mode 100644 index 00000000..a3b1dc09 --- /dev/null +++ b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py @@ -0,0 +1,68 @@ +import unittest +from unittest.mock import ( + AsyncMock, + call, +) +from uuid import ( + uuid4, +) + +from minos.common.testing import ( + PostgresAsyncTestCase, +) +from minos.networks import ( + BrokerMessage, + BrokerMessageStatus, + CommandReplyHandler, + HandlerEntry, +) +from tests.utils import ( + BASE_PATH, + FakeModel, + FakeSagaManager, +) + + +class TestCommandReplyHandler(PostgresAsyncTestCase): + CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" + + def test_from_config(self): + saga_manager = FakeSagaManager() + handler = CommandReplyHandler.from_config(config=self.config, saga_manager=saga_manager) + self.assertIsInstance(handler, CommandReplyHandler) + handlers = {"OrderReply": None} + self.assertEqual(handlers, handler.handlers) + self.assertEqual(self.config.broker.queue.records, handler._records) + self.assertEqual(self.config.broker.queue.retry, handler._retry) + self.assertEqual(self.config.broker.queue.host, handler.host) + self.assertEqual(self.config.broker.queue.port, handler.port) + self.assertEqual(self.config.broker.queue.database, handler.database) + self.assertEqual(self.config.broker.queue.user, handler.user) + self.assertEqual(self.config.broker.queue.password, handler.password) + self.assertEqual(saga_manager, handler.saga_manager) + + async def test_dispatch(self): + saga_manager = FakeSagaManager() + mock = AsyncMock() + saga_manager._load_and_run = mock + + saga = uuid4() + command = BrokerMessage( + "TicketAdded", + [FakeModel("foo")], + identifier=saga, + status=BrokerMessageStatus.SUCCESS, + service_name=self.config.service.name, + ) + entry = HandlerEntry(1, "TicketAdded", 0, command.avro_bytes, 1) + + async with CommandReplyHandler.from_config(config=self.config, saga_manager=saga_manager) as handler: + await handler.dispatch_one(entry) + + self.assertEqual(1, mock.call_count) + expected = call(command, pause_on_disk=True, raise_on_error=False, return_execution=False) + self.assertEqual(expected, mock.call_args) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py new file mode 100644 index 00000000..a9fb60d0 --- /dev/null +++ b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py @@ -0,0 +1,62 @@ +import unittest +from unittest.mock import ( + AsyncMock, +) + +from aiomisc import ( + Service, +) + +from minos.common.testing import ( + PostgresAsyncTestCase, +) +from minos.networks import ( + CommandReplyHandler, + CommandReplyHandlerService, +) +from tests.utils import ( + BASE_PATH, +) + + +class TestCommandReplyHandlerService(PostgresAsyncTestCase): + CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" + + def test_is_instance(self): + service = CommandReplyHandlerService(config=self.config) + self.assertIsInstance(service, Service) + + def test_dispatcher(self): + service = CommandReplyHandlerService(config=self.config) + self.assertIsInstance(service.dispatcher, CommandReplyHandler) + + async def test_start_stop(self): + service = CommandReplyHandlerService(config=self.config) + + setup_mock = AsyncMock() + destroy_mock = AsyncMock() + dispatch_forever_mock = AsyncMock() + + service.dispatcher.setup = setup_mock + service.dispatcher.destroy = destroy_mock + service.dispatcher.dispatch_forever = dispatch_forever_mock + + await service.start() + + self.assertEqual(1, setup_mock.call_count) + self.assertEqual(1, dispatch_forever_mock.call_count) + self.assertEqual(0, destroy_mock.call_count) + + setup_mock.reset_mock() + destroy_mock.reset_mock() + dispatch_forever_mock.reset_mock() + + await service.stop() + + self.assertEqual(0, setup_mock.call_count) + self.assertEqual(0, dispatch_forever_mock.call_count) + self.assertEqual(1, destroy_mock.call_count) + + +if __name__ == "__main__": + unittest.main() From 2708dac1a2055c2a1734534d4085b3c53f02d0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Thu, 11 Nov 2021 09:47:55 +0100 Subject: [PATCH 09/24] ISSUE #434 * Revert change from `Command`, `CommandReply` and `Event` to a single `BrokerMessage`. --- minos/networks/__init__.py | 6 ++- minos/networks/brokers/__init__.py | 6 ++- minos/networks/brokers/messages.py | 45 ++++++++++--------- .../brokers/publishers/command_replies.py | 12 ++--- minos/networks/brokers/publishers/commands.py | 8 ++-- minos/networks/brokers/publishers/events.py | 8 ++-- .../brokers/subscribers/commands/handlers.py | 24 +++++----- .../brokers/subscribers/events/handlers.py | 8 ++-- .../networks/brokers/subscribers/messages.py | 5 +-- .../test_publishers/test_command_replies.py | 14 +++--- .../test_publishers/test_commands.py | 13 +++--- .../test_publishers/test_events.py | 4 +- .../test_publishers/test_producers.py | 8 ++-- .../test_abc/test_handlers.py | 11 ++--- .../test_command_replies/test_handlers.py | 10 ++--- .../test_commands/test_handlers.py | 43 +++++++++--------- .../test_events/test_handlers.py | 10 ++--- .../test_subscribers/test_messages.py | 14 +++--- tests/utils.py | 8 ++-- 19 files changed, 126 insertions(+), 131 deletions(-) diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index f74faf2a..568f954e 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -5,19 +5,21 @@ from .brokers import ( REPLY_TOPIC_CONTEXT_VAR, Broker, - BrokerMessage, - BrokerMessageStatus, BrokerSetup, + Command, CommandBroker, CommandHandler, CommandHandlerService, + CommandReply, CommandReplyBroker, CommandReplyHandler, CommandReplyHandlerService, + CommandStatus, Consumer, ConsumerService, DynamicHandler, DynamicHandlerPool, + Event, EventBroker, EventHandler, EventHandlerService, diff --git a/minos/networks/brokers/__init__.py b/minos/networks/brokers/__init__.py index 6365d8c3..f659c37f 100644 --- a/minos/networks/brokers/__init__.py +++ b/minos/networks/brokers/__init__.py @@ -1,7 +1,9 @@ from .messages import ( REPLY_TOPIC_CONTEXT_VAR, - BrokerMessage, - BrokerMessageStatus, + Command, + CommandReply, + CommandStatus, + Event, ) from .publishers import ( Broker, diff --git a/minos/networks/brokers/messages.py b/minos/networks/brokers/messages.py index 263ba8e0..ac0664a6 100644 --- a/minos/networks/brokers/messages.py +++ b/minos/networks/brokers/messages.py @@ -24,40 +24,41 @@ REPLY_TOPIC_CONTEXT_VAR: Final[ContextVar[Optional[str]]] = ContextVar("reply_topic", default=None) -class BrokerMessage(DeclarativeModel): - """Broker Message class.""" +class Command(DeclarativeModel): + """Base Command class.""" topic: str data: Any - identifier: Optional[UUID] - reply_topic: Optional[str] + saga: UUID + reply_topic: str user: Optional[UUID] - status: Optional[BrokerMessageStatus] - service_name: Optional[str] - def __init__( - self, - topic: str, - data: Any, - *, - identifier: Optional[UUID] = None, - reply_topic: Optional[str] = None, - user: Optional[UUID] = None, - status: Optional[BrokerMessageStatus] = None, - service_name: Optional[str] = None, - **kwargs - ): - super().__init__(topic, data, identifier, reply_topic, user, status, service_name, **kwargs) + +class CommandReply(DeclarativeModel): + """Base Command class.""" + + topic: str + data: Any + saga: UUID + status: CommandStatus + service_name: Optional[str] @property def ok(self) -> bool: """TODO""" - return self.status == BrokerMessageStatus.SUCCESS + return self.status == CommandStatus.SUCCESS -class BrokerMessageStatus(IntEnum): - """Broker status class.""" +class CommandStatus(IntEnum): + """Command Status class.""" SUCCESS = 200 ERROR = 400 SYSTEM_ERROR = 500 + + +class Event(DeclarativeModel): + """Base Event class.""" + + topic: str + data: Any diff --git a/minos/networks/brokers/publishers/command_replies.py b/minos/networks/brokers/publishers/command_replies.py index 842f4dee..470d5057 100644 --- a/minos/networks/brokers/publishers/command_replies.py +++ b/minos/networks/brokers/publishers/command_replies.py @@ -15,8 +15,8 @@ ) from ..messages import ( - BrokerMessage, - BrokerMessageStatus, + CommandReply, + CommandStatus, ) from .abc import ( Broker, @@ -39,7 +39,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyBroke return cls(*args, service_name=config.service.name, **config.broker.queue._asdict(), **kwargs) # noinspection PyMethodOverriding - async def send(self, data: Any, topic: str, saga: UUID, status: BrokerMessageStatus, **kwargs) -> int: + async def send(self, data: Any, topic: str, saga: UUID, status: CommandStatus, **kwargs) -> int: """Send a ``CommandReply``. :param data: The data to be send. @@ -49,6 +49,6 @@ async def send(self, data: Any, topic: str, saga: UUID, status: BrokerMessageSta :return: This method does not return anything. """ - request = BrokerMessage(topic, data, identifier=saga, status=status, service_name=self.service_name) - logger.info(f"Sending '{request!s}'...") - return await self.enqueue(request.topic, request.avro_bytes) + command_reply = CommandReply(topic, data, saga=saga, status=status, service_name=self.service_name) + logger.info(f"Sending '{command_reply!s}'...") + return await self.enqueue(command_reply.topic, command_reply.avro_bytes) diff --git a/minos/networks/brokers/publishers/commands.py b/minos/networks/brokers/publishers/commands.py index 718d68ab..991c4085 100644 --- a/minos/networks/brokers/publishers/commands.py +++ b/minos/networks/brokers/publishers/commands.py @@ -17,7 +17,7 @@ from ..messages import ( REPLY_TOPIC_CONTEXT_VAR, - BrokerMessage, + Command, ) from .abc import ( Broker, @@ -65,6 +65,6 @@ async def send( if reply_topic is None: reply_topic = self.default_reply_topic - request = BrokerMessage(topic, data, identifier=saga, reply_topic=reply_topic, user=user) - logger.info(f"Sending '{request!s}'...") - return await self.enqueue(request.topic, request.avro_bytes) + command = Command(topic, data, saga, reply_topic, user) + logger.info(f"Sending '{command!s}'...") + return await self.enqueue(command.topic, command.avro_bytes) diff --git a/minos/networks/brokers/publishers/events.py b/minos/networks/brokers/publishers/events.py index 0629e2fe..595f3d7c 100644 --- a/minos/networks/brokers/publishers/events.py +++ b/minos/networks/brokers/publishers/events.py @@ -12,7 +12,7 @@ ) from ..messages import ( - BrokerMessage, + Event, ) from .abc import ( Broker, @@ -38,6 +38,6 @@ async def send(self, data: AggregateDiff, topic: str, **kwargs) -> int: :param topic: Topic in which the message will be published. :return: This method does not return anything. """ - request = BrokerMessage(topic, data) - logger.info(f"Sending '{request!s}'...") - return await self.enqueue(request.topic, request.avro_bytes) + event = Event(topic, data) + logger.info(f"Sending '{event!s}'...") + return await self.enqueue(event.topic, event.avro_bytes) diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index 01896a4e..1e7e8042 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -21,7 +21,6 @@ ) from minos.common import ( - MinosBroker, MinosConfig, ) @@ -34,8 +33,11 @@ ResponseException, ) from ...messages import ( - BrokerMessage, - BrokerMessageStatus, + Command, + CommandStatus, +) +from ...publishers import ( + CommandReplyBroker, ) from ..abc import ( Handler, @@ -54,9 +56,9 @@ class CommandHandler(Handler): """Command Handler class.""" @inject - def __init__(self, broker: MinosBroker = Provide["command_reply_broker"], **kwargs: Any): + def __init__(self, command_reply_broker: CommandReplyBroker = Provide["command_reply_broker"], **kwargs: Any): super().__init__(**kwargs) - self.broker = broker + self.command_reply_broker = command_reply_broker @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandHandler: @@ -83,19 +85,19 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: command = entry.data items, status = await fn(command) - await self.broker.send(items, topic=command.reply_topic, saga=command.identifier, status=status) + await self.command_reply_broker.send(items, topic=command.reply_topic, saga=command.saga, status=status) @staticmethod def get_callback( fn: Callable[[HandlerRequest], Union[Optional[HandlerRequest], Awaitable[Optional[HandlerRequest]]]] - ) -> Callable[[BrokerMessage], Awaitable[Tuple[Any, BrokerMessageStatus]]]: + ) -> Callable[[Command], Awaitable[Tuple[Any, CommandStatus]]]: """Get the handler function to be used by the Command Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Command Handler API. """ - async def _fn(raw: BrokerMessage) -> Tuple[Any, BrokerMessageStatus]: + async def _fn(raw: Command) -> Tuple[Any, CommandStatus]: request = HandlerRequest(raw) token = USER_CONTEXT_VAR.set(request.user) @@ -105,13 +107,13 @@ async def _fn(raw: BrokerMessage) -> Tuple[Any, BrokerMessageStatus]: response = await response if isinstance(response, Response): response = await response.content() - return response, BrokerMessageStatus.SUCCESS + return response, CommandStatus.SUCCESS except ResponseException as exc: logger.warning(f"Raised an application exception: {exc!s}") - return repr(exc), BrokerMessageStatus.ERROR + return repr(exc), CommandStatus.ERROR except Exception as exc: logger.exception(f"Raised a system exception: {exc!r}") - return repr(exc), BrokerMessageStatus.SYSTEM_ERROR + return repr(exc), CommandStatus.SYSTEM_ERROR finally: USER_CONTEXT_VAR.reset(token) diff --git a/minos/networks/brokers/subscribers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py index bd47feca..94d7a07e 100644 --- a/minos/networks/brokers/subscribers/events/handlers.py +++ b/minos/networks/brokers/subscribers/events/handlers.py @@ -32,7 +32,7 @@ ResponseException, ) from ...messages import ( - BrokerMessage, + Event, ) from ..abc import ( Handler, @@ -93,16 +93,14 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: await fn(entry.data) @staticmethod - def get_callback( - fn: Callable[[HandlerRequest], Optional[Awaitable[None]]] - ) -> Callable[[BrokerMessage], Awaitable[None]]: + def get_callback(fn: Callable[[HandlerRequest], Optional[Awaitable[None]]]) -> Callable[[Event], Awaitable[None]]: """Get the handler function to be used by the Event Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Event Handler API. """ - async def _fn(raw: BrokerMessage) -> None: + async def _fn(raw: Event) -> None: try: request = HandlerRequest(raw) response = fn(request) diff --git a/minos/networks/brokers/subscribers/messages.py b/minos/networks/brokers/subscribers/messages.py index 1cca0f83..5bdb5768 100644 --- a/minos/networks/brokers/subscribers/messages.py +++ b/minos/networks/brokers/subscribers/messages.py @@ -15,9 +15,6 @@ Response, ResponseException, ) -from ..messages import ( - BrokerMessage, -) class HandlerRequest(Request): @@ -25,7 +22,7 @@ class HandlerRequest(Request): __slots__ = "raw" - def __init__(self, raw: BrokerMessage): + def __init__(self, raw: Any): self.raw = raw def __eq__(self, other: HandlerRequest) -> bool: diff --git a/tests/test_networks/test_brokers/test_publishers/test_command_replies.py b/tests/test_networks/test_brokers/test_publishers/test_command_replies.py index fecda921..37ea6dbb 100644 --- a/tests/test_networks/test_brokers/test_publishers/test_command_replies.py +++ b/tests/test_networks/test_brokers/test_publishers/test_command_replies.py @@ -13,9 +13,9 @@ PostgresAsyncTestCase, ) from minos.networks import ( - BrokerMessage, - BrokerMessageStatus, + CommandReply, CommandReplyBroker, + CommandStatus, ) from tests.utils import ( BASE_PATH, @@ -39,9 +39,7 @@ async def test_send(self): reply_topic = "fakeReply" async with CommandReplyBroker.from_config(config=self.config) as broker: broker.enqueue = mock - identifier = await broker.send( - FakeModel("foo"), saga=saga, topic=reply_topic, status=BrokerMessageStatus.SUCCESS - ) + identifier = await broker.send(FakeModel("foo"), saga=saga, topic=reply_topic, status=CommandStatus.SUCCESS) self.assertEqual(56, identifier) self.assertEqual(1, mock.call_count) @@ -49,11 +47,11 @@ async def test_send(self): args = mock.call_args.args self.assertEqual(reply_topic, args[0]) - expected = BrokerMessage( + expected = CommandReply( reply_topic, FakeModel("foo"), - identifier=saga, - status=BrokerMessageStatus.SUCCESS, + saga=saga, + status=CommandStatus.SUCCESS, service_name=self.config.service.name, ) observed = Model.from_avro_bytes(args[1]) diff --git a/tests/test_networks/test_brokers/test_publishers/test_commands.py b/tests/test_networks/test_brokers/test_publishers/test_commands.py index 50af26c0..d4fe0060 100644 --- a/tests/test_networks/test_brokers/test_publishers/test_commands.py +++ b/tests/test_networks/test_brokers/test_publishers/test_commands.py @@ -14,7 +14,7 @@ ) from minos.networks import ( REPLY_TOPIC_CONTEXT_VAR, - BrokerMessage, + Command, CommandBroker, ) from tests.utils import ( @@ -51,7 +51,7 @@ async def test_send(self): args = mock.call_args.args self.assertEqual("fake", args[0]) self.assertEqual( - BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="ekaf"), Model.from_avro_bytes(args[1]) + Command("fake", FakeModel("foo"), saga=saga, reply_topic="ekaf"), Model.from_avro_bytes(args[1]) ) async def test_send_with_default_reply_topic(self): @@ -68,8 +68,7 @@ async def test_send_with_default_reply_topic(self): args = mock.call_args.args self.assertEqual("fake", args[0]) self.assertEqual( - BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="OrderReply"), - Model.from_avro_bytes(args[1]), + Command("fake", FakeModel("foo"), saga=saga, reply_topic="OrderReply"), Model.from_avro_bytes(args[1]), ) async def test_send_with_reply_topic_context_var(self): @@ -88,8 +87,7 @@ async def test_send_with_reply_topic_context_var(self): args = mock.call_args.args self.assertEqual("fake", args[0]) self.assertEqual( - BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="onetwothree"), - Model.from_avro_bytes(args[1]), + Command("fake", FakeModel("foo"), saga=saga, reply_topic="onetwothree"), Model.from_avro_bytes(args[1]), ) async def test_send_with_user(self): @@ -107,8 +105,7 @@ async def test_send_with_user(self): args = mock.call_args.args self.assertEqual("fake", args[0]) self.assertEqual( - BrokerMessage("fake", FakeModel("foo"), identifier=saga, reply_topic="ekaf", user=user), - Model.from_avro_bytes(args[1]), + Command("fake", FakeModel("foo"), saga=saga, reply_topic="ekaf", user=user), Model.from_avro_bytes(args[1]), ) diff --git a/tests/test_networks/test_brokers/test_publishers/test_events.py b/tests/test_networks/test_brokers/test_publishers/test_events.py index e4309a54..55a6fded 100644 --- a/tests/test_networks/test_brokers/test_publishers/test_events.py +++ b/tests/test_networks/test_brokers/test_publishers/test_events.py @@ -10,7 +10,7 @@ PostgresAsyncTestCase, ) from minos.networks import ( - BrokerMessage, + Event, EventBroker, ) from tests.utils import ( @@ -39,7 +39,7 @@ async def test_send(self): args = mock.call_args.args self.assertEqual("fake", args[0]) - self.assertEqual(BrokerMessage("fake", FAKE_AGGREGATE_DIFF), Model.from_avro_bytes(args[1])) + self.assertEqual(Event("fake", FAKE_AGGREGATE_DIFF), Model.from_avro_bytes(args[1])) if __name__ == "__main__": diff --git a/tests/test_networks/test_brokers/test_publishers/test_producers.py b/tests/test_networks/test_brokers/test_publishers/test_producers.py index 72cc1149..9610d3d2 100644 --- a/tests/test_networks/test_brokers/test_publishers/test_producers.py +++ b/tests/test_networks/test_brokers/test_publishers/test_producers.py @@ -18,9 +18,9 @@ PostgresAsyncTestCase, ) from minos.networks import ( - BrokerMessageStatus, CommandBroker, CommandReplyBroker, + CommandStatus, Consumer, EventBroker, Producer, @@ -138,7 +138,7 @@ async def test_concurrency_dispatcher(self): for x in range(0, 20): async with command_reply_broker: - await command_reply_broker.send(model, "TestDeleteReply", saga, BrokerMessageStatus.SUCCESS) + await command_reply_broker.send(model, "TestDeleteReply", saga, CommandStatus.SUCCESS) async with command_broker: await command_broker.send(model, "CommandBroker-Delete", saga, "TestDeleteReply") @@ -185,8 +185,8 @@ async def test_if_commands_retry_was_incremented(self): saga = uuid4() async with CommandReplyBroker.from_config(config=self.config) as broker: - queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) - queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, BrokerMessageStatus.SUCCESS) + queue_id_1 = await broker.send(model, "TestDeleteOrderReply", saga, CommandStatus.SUCCESS) + queue_id_2 = await broker.send(model, "TestDeleteOrderReply", saga, CommandStatus.SUCCESS) async with self.producer: self.producer.publish = AsyncMock(return_value=False) diff --git a/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py index 6efb77b6..35348098 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py @@ -27,8 +27,9 @@ PostgresAsyncTestCase, ) from minos.networks import ( - BrokerMessage, + Command, EnrouteBuilder, + Event, Handler, HandlerEntry, HandlerResponse, @@ -126,7 +127,7 @@ async def test_dispatch_forever_without_topics(self): self.assertEqual(0, mock.call_count) async def test_dispatch(self): - instance = BrokerMessage("AddOrder", FAKE_AGGREGATE_DIFF) + instance = Event("AddOrder", FAKE_AGGREGATE_DIFF) async with self.handler: queue_id = await self._insert_one(instance) @@ -137,8 +138,8 @@ async def test_dispatch(self): async def test_dispatch_wrong(self): instance_1 = namedtuple("FakeCommand", ("topic", "avro_bytes"))("AddOrder", bytes(b"Test")) - instance_2 = BrokerMessage("DeleteOrder", FAKE_AGGREGATE_DIFF) - instance_3 = BrokerMessage("NoActionTopic", FAKE_AGGREGATE_DIFF) + instance_2 = Event("DeleteOrder", FAKE_AGGREGATE_DIFF) + instance_3 = Event("NoActionTopic", FAKE_AGGREGATE_DIFF) async with self.handler: queue_id_1 = await self._insert_one(instance_1) @@ -156,7 +157,7 @@ async def test_dispatch_concurrent(self): saga = uuid4() - instance = BrokerMessage("AddOrder", [FakeModel("foo")], identifier=saga, reply_topic="UpdateTicket") + instance = Command("AddOrder", [FakeModel("foo")], saga=saga, reply_topic="UpdateTicket") instance_wrong = namedtuple("FakeCommand", ("topic", "avro_bytes"))("AddOrder", bytes(b"Test")) async with self.handler: diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py index a3b1dc09..e3655fc6 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py @@ -11,9 +11,9 @@ PostgresAsyncTestCase, ) from minos.networks import ( - BrokerMessage, - BrokerMessageStatus, + CommandReply, CommandReplyHandler, + CommandStatus, HandlerEntry, ) from tests.utils import ( @@ -47,11 +47,11 @@ async def test_dispatch(self): saga_manager._load_and_run = mock saga = uuid4() - command = BrokerMessage( + command = CommandReply( "TicketAdded", [FakeModel("foo")], - identifier=saga, - status=BrokerMessageStatus.SUCCESS, + saga=saga, + status=CommandStatus.SUCCESS, service_name=self.config.service.name, ) entry = HandlerEntry(1, "TicketAdded", 0, command.avro_bytes, 1) diff --git a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py index 3268f36e..179fdc9c 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py @@ -13,9 +13,9 @@ ) from minos.networks import ( USER_CONTEXT_VAR, - BrokerMessage, - BrokerMessageStatus, + Command, CommandHandler, + CommandStatus, HandlerEntry, HandlerRequest, HandlerResponse, @@ -53,14 +53,15 @@ class TestCommandHandler(PostgresAsyncTestCase): def setUp(self) -> None: super().setUp() - self.broker = FakeBroker() - self.handler = CommandHandler.from_config(config=self.config, broker=self.broker) + self.command_reply_broker = FakeBroker() + self.handler = CommandHandler.from_config(config=self.config, command_reply_broker=self.command_reply_broker) + self.saga = uuid4() self.user = uuid4() - self.request = BrokerMessage("AddOrder", FakeModel("foo"), identifier=self.user, reply_topic="UpdateTicket") + self.command = Command("AddOrder", FakeModel("foo"), saga=self.saga, user=self.user, reply_topic="UpdateTicket") def test_from_config(self): broker = FakeBroker() - handler = CommandHandler.from_config(config=self.config, broker=broker) + handler = CommandHandler.from_config(config=self.config, command_reply_broker=broker) self.assertIsInstance(handler, CommandHandler) self.assertEqual({"GetOrder", "AddOrder", "DeleteOrder", "UpdateOrder"}, set(handler.handlers.keys())) @@ -71,12 +72,12 @@ def test_from_config(self): self.assertEqual(self.config.broker.queue.database, handler.database) self.assertEqual(self.config.broker.queue.user, handler.user) self.assertEqual(self.config.broker.queue.password, handler.password) - self.assertEqual(broker, handler.broker) + self.assertEqual(broker, handler.command_reply_broker) async def test_dispatch(self): callback_mock = AsyncMock(return_value=Response("add_order")) lookup_mock = MagicMock(return_value=callback_mock) - entry = HandlerEntry(1, "AddOrder", 0, self.request.avro_bytes, 1, callback_lookup=lookup_mock) + entry = HandlerEntry(1, "AddOrder", 0, self.command.avro_bytes, 1, callback_lookup=lookup_mock) async with self.handler: await self.handler.dispatch_one(entry) @@ -84,12 +85,12 @@ async def test_dispatch(self): self.assertEqual(1, lookup_mock.call_count) self.assertEqual(call("AddOrder"), lookup_mock.call_args) - self.assertEqual(1, self.broker.call_count) - self.assertEqual("add_order", self.broker.items) - self.assertEqual("UpdateTicket", self.broker.topic) - self.assertEqual(self.request.identifier, self.broker.identifier) - self.assertEqual(None, self.broker.reply_topic) - self.assertEqual(BrokerMessageStatus.SUCCESS, self.broker.status) + self.assertEqual(1, self.command_reply_broker.call_count) + self.assertEqual("add_order", self.command_reply_broker.items) + self.assertEqual("UpdateTicket", self.command_reply_broker.topic) + self.assertEqual(self.command.saga, self.command_reply_broker.saga) + self.assertEqual(None, self.command_reply_broker.reply_topic) + self.assertEqual(CommandStatus.SUCCESS, self.command_reply_broker.status) self.assertEqual(1, callback_mock.call_count) observed = callback_mock.call_args[0][0] @@ -98,21 +99,21 @@ async def test_dispatch(self): async def test_get_callback(self): fn = self.handler.get_callback(_Cls._fn) - self.assertEqual((FakeModel("foo"), BrokerMessageStatus.SUCCESS), await fn(self.request)) + self.assertEqual((FakeModel("foo"), CommandStatus.SUCCESS), await fn(self.command)) async def test_get_callback_none(self): fn = self.handler.get_callback(_Cls._fn_none) - self.assertEqual((None, BrokerMessageStatus.SUCCESS), await fn(self.request)) + self.assertEqual((None, CommandStatus.SUCCESS), await fn(self.command)) async def test_get_callback_raises_response(self): fn = self.handler.get_callback(_Cls._fn_raises_response) - expected = (repr(HandlerResponseException("foo")), BrokerMessageStatus.ERROR) - self.assertEqual(expected, await fn(self.request)) + expected = (repr(HandlerResponseException("foo")), CommandStatus.ERROR) + self.assertEqual(expected, await fn(self.command)) async def test_get_callback_raises_exception(self): fn = self.handler.get_callback(_Cls._fn_raises_exception) - expected = (repr(ValueError()), BrokerMessageStatus.SYSTEM_ERROR) - self.assertEqual(expected, await fn(self.request)) + expected = (repr(ValueError()), CommandStatus.SYSTEM_ERROR) + self.assertEqual(expected, await fn(self.command)) async def test_get_callback_with_user(self): async def _fn(request) -> None: @@ -122,7 +123,7 @@ async def _fn(request) -> None: mock = AsyncMock(side_effect=_fn) handler = self.handler.get_callback(mock) - await handler(self.request) + await handler(self.command) self.assertEqual(1, mock.call_count) diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py index 785b8298..bd6a70fc 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py @@ -28,7 +28,7 @@ PostgresAsyncTestCase, ) from minos.networks import ( - BrokerMessage, + Event, EventHandler, HandlerEntry, HandlerRequest, @@ -61,7 +61,7 @@ class TestEventHandler(PostgresAsyncTestCase): def setUp(self) -> None: super().setUp() self.handler = EventHandler.from_config(config=self.config) - self.event = BrokerMessage("TicketAdded", FAKE_AGGREGATE_DIFF) + self.event = Event("TicketAdded", FAKE_AGGREGATE_DIFF) def test_from_config(self): self.assertIsInstance(self.handler, EventHandler) @@ -88,7 +88,7 @@ async def test_dispatch_one(self): lookup_mock = MagicMock(return_value=callback_mock) topic = "TicketAdded" - event = BrokerMessage(topic, FAKE_AGGREGATE_DIFF) + event = Event(topic, FAKE_AGGREGATE_DIFF) entry = HandlerEntry(1, topic, 0, event.avro_bytes, 1, callback_lookup=lookup_mock) async with self.handler: @@ -127,11 +127,11 @@ async def _fn2(request): for i in range(1, 6): events.extend( [ - BrokerMessage( + Event( "TicketAdded", AggregateDiff(uuid1, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), ), - BrokerMessage( + Event( "TicketAdded", AggregateDiff(uuid2, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), ), diff --git a/tests/test_networks/test_brokers/test_subscribers/test_messages.py b/tests/test_networks/test_brokers/test_subscribers/test_messages.py index 79c396eb..861f9253 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_messages.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_messages.py @@ -4,7 +4,7 @@ ) from minos.networks import ( - BrokerMessage, + Command, HandlerRequest, HandlerResponse, ) @@ -17,7 +17,7 @@ class TestHandlerRequest(unittest.IsolatedAsyncioTestCase): def setUp(self) -> None: self.data = [FakeModel("foo"), FakeModel("bar")] self.saga = uuid4() - self.raw = BrokerMessage("FooCreated", self.data, identifier=self.saga, reply_topic="AddOrderReply") + self.raw = Command("FooCreated", self.data, saga=self.saga, reply_topic="AddOrderReply") def test_repr(self): request = HandlerRequest(self.raw) @@ -28,9 +28,7 @@ def test_eq_true(self): self.assertEqual(HandlerRequest(self.raw), HandlerRequest(self.raw)) def test_eq_false(self): - another = HandlerRequest( - BrokerMessage("FooUpdated", self.data, identifier=self.saga, reply_topic="AddOrderReply") - ) + another = HandlerRequest(Command("FooUpdated", self.data, saga=self.saga, reply_topic="AddOrderReply")) self.assertNotEqual(HandlerRequest(self.raw), another) def test_no_user(self): @@ -46,13 +44,11 @@ async def test_content(self): self.assertEqual(self.data, await request.content()) async def test_content_single(self): - request = HandlerRequest( - BrokerMessage("FooCreated", self.data[0], identifier=self.saga, reply_topic="AddOrderReply") - ) + request = HandlerRequest(Command("FooCreated", self.data[0], saga=self.saga, reply_topic="AddOrderReply")) self.assertEqual(self.data[0], await request.content()) async def test_content_simple(self): - request = HandlerRequest(BrokerMessage("FooCreated", 1234, identifier=self.saga, reply_topic="AddOrderReply")) + request = HandlerRequest(Command("FooCreated", 1234, saga=self.saga, reply_topic="AddOrderReply")) self.assertEqual(1234, await request.content()) diff --git a/tests/utils.py b/tests/utils.py index 9b1d5139..35086673 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -40,7 +40,7 @@ current_datetime, ) from minos.networks import ( - BrokerMessageStatus, + CommandStatus, EnrouteDecorator, Request, Response, @@ -198,7 +198,7 @@ def __init__(self): self.call_count = 0 self.items = None self.topic = None - self.identifier = None + self.saga = None self.reply_topic = None self.status = None @@ -208,14 +208,14 @@ async def send( topic: str = None, saga: str = None, reply_topic: str = None, - status: BrokerMessageStatus = None, + status: CommandStatus = None, **kwargs, ) -> None: """For testing purposes.""" self.call_count += 1 self.items = items self.topic = topic - self.identifier = saga + self.saga = saga self.reply_topic = reply_topic self.status = status From 2e35c68fee4d98af92eb81b33a9bf65ac6cff94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Thu, 11 Nov 2021 10:16:29 +0100 Subject: [PATCH 10/24] ISSUE #434 * Copy tests for `Command`, `CommandReply`, `CommandStatus` and `Event` from `minos.common`. --- poetry.lock | 18 ++--- pyproject.toml | 2 +- .../test_brokers/test_messages.py | 76 +++++++++++++++++++ tests/utils.py | 7 +- 4 files changed, 90 insertions(+), 13 deletions(-) create mode 100644 tests/test_networks/test_brokers/test_messages.py diff --git a/poetry.lock b/poetry.lock index df7d8514..836ce41a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -97,7 +97,7 @@ python-versions = "*" [[package]] name = "async-timeout" -version = "4.0.0" +version = "4.0.1" description = "Timeout context manager for asyncio programs" category = "main" optional = false @@ -495,8 +495,8 @@ PyYAML = "^5.4.1" [package.source] type = "git" url = "https://github.com/Clariteia/minos_microservice_common.git" -reference = "issue-649-minos-config-services" -resolved_reference = "a1c1a7f6ae4d516fd5f58323c648e33ee5733094" +reference = "issue-651-remove-command-commandreply-event" +resolved_reference = "87e944e0b14f65ddd881464233e9e85e3017108a" [[package]] name = "mistune" @@ -734,7 +734,7 @@ python-versions = "*" [[package]] name = "sphinx" -version = "4.2.0" +version = "4.3.0" description = "Python documentation generator" category = "dev" optional = false @@ -947,7 +947,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "e698df0c8fcaf0d14f5825b708db307acce9b73459b41912889ad9a90eb3e4d3" +content-hash = "894386b0f0dfe216edca09cb51175e136d4742ac92629c6f3fd2e5fb21dcc2ca" [metadata.files] aiohttp = [ @@ -1068,8 +1068,8 @@ appdirs = [ {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, ] async-timeout = [ - {file = "async-timeout-4.0.0.tar.gz", hash = "sha256:7d87a4e8adba8ededb52e579ce6bc8276985888913620c935094c2276fd83382"}, - {file = "async_timeout-4.0.0-py3-none-any.whl", hash = "sha256:f3303dddf6cafa748a92747ab6c2ecf60e0aeca769aee4c151adfce243a05d9b"}, + {file = "async-timeout-4.0.1.tar.gz", hash = "sha256:b930cb161a39042f9222f6efb7301399c87eeab394727ec5437924a36d6eef51"}, + {file = "async_timeout-4.0.1-py3-none-any.whl", hash = "sha256:a22c0b311af23337eb05fcf05a8b51c3ea53729d46fb5460af62bee033cec690"}, ] atomicwrites = [ {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, @@ -1810,8 +1810,8 @@ snowballstemmer = [ {file = "snowballstemmer-2.1.0.tar.gz", hash = "sha256:e997baa4f2e9139951b6f4c631bad912dfd3c792467e2f03d7239464af90e914"}, ] sphinx = [ - {file = "Sphinx-4.2.0-py3-none-any.whl", hash = "sha256:98a535c62a4fcfcc362528592f69b26f7caec587d32cd55688db580be0287ae0"}, - {file = "Sphinx-4.2.0.tar.gz", hash = "sha256:94078db9184491e15bce0a56d9186e0aec95f16ac20b12d00e06d4e36f1058a6"}, + {file = "Sphinx-4.3.0-py3-none-any.whl", hash = "sha256:7e2b30da5f39170efcd95c6270f07669d623c276521fee27ad6c380f49d2bf5b"}, + {file = "Sphinx-4.3.0.tar.gz", hash = "sha256:6d051ab6e0d06cba786c4656b0fe67ba259fe058410f49e95bee6e49c4052cbf"}, ] sphinx-autodoc-typehints = [ {file = "sphinx-autodoc-typehints-1.12.0.tar.gz", hash = "sha256:193617d9dbe0847281b1399d369e74e34cd959c82e02c7efde077fca908a9f52"}, diff --git a/pyproject.toml b/pyproject.toml index 861f804c..e49c2845 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ aiomisc = "^14.0.3" aiopg = "^1.2.1" aiohttp = "^3.7.4" dependency-injector = "^4.32.2" -minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-649-minos-config-services" } +minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-651-remove-command-commandreply-event" } minos-microservice-aggregate = "^0.1.0" crontab = "^0.23.0" diff --git a/tests/test_networks/test_brokers/test_messages.py b/tests/test_networks/test_brokers/test_messages.py new file mode 100644 index 00000000..30ef99ea --- /dev/null +++ b/tests/test_networks/test_brokers/test_messages.py @@ -0,0 +1,76 @@ +import unittest +from uuid import ( + uuid4, +) + +from minos.networks import ( + Command, + CommandReply, + CommandStatus, + Event, +) +from tests.utils import ( + FakeModel, +) + + +class TestCommand(unittest.TestCase): + def setUp(self) -> None: + self.topic = "FooCreated" + self.data = [FakeModel("blue"), FakeModel("red")] + self.saga = uuid4() + self.reply_topic = "AddOrderReply" + self.user = uuid4() + + def test_constructor(self): + command = Command(self.topic, self.data, self.saga, self.reply_topic, self.user) + self.assertEqual(self.topic, command.topic) + self.assertEqual(self.data, command.data) + self.assertEqual(self.saga, command.saga) + self.assertEqual(self.reply_topic, command.reply_topic) + self.assertEqual(self.user, command.user) + + def test_avro_serialization(self): + command = Command(self.topic, self.data, self.saga, self.reply_topic, self.user) + decoded_command = Command.from_avro_bytes(command.avro_bytes) + self.assertEqual(command, decoded_command) + + +class TestCommandReply(unittest.TestCase): + def setUp(self) -> None: + self.topic = "FooCreated" + self.data = [FakeModel("blue"), FakeModel("red")] + self.saga = uuid4() + self.status = CommandStatus.SUCCESS + + def test_constructor(self): + command_reply = CommandReply(self.topic, self.data, self.saga, self.status) + self.assertEqual(self.topic, command_reply.topic) + self.assertEqual(self.data, command_reply.data) + self.assertEqual(self.saga, command_reply.saga) + self.assertEqual(self.status, command_reply.status) + + def test_avro_serialization(self): + command_reply = CommandReply(self.topic, self.data, self.saga, self.status) + decoded_command = CommandReply.from_avro_bytes(command_reply.avro_bytes) + self.assertEqual(command_reply, decoded_command) + + +class TestEvent(unittest.TestCase): + def setUp(self) -> None: + self.data = FakeModel("blue") + self.topic = "FooCreated" + + def test_constructor(self): + event = Event(self.topic, self.data) + self.assertEqual(self.topic, event.topic) + self.assertEqual(self.data, event.data) + + def test_avro_serialization(self): + event = Event(self.topic, self.data) + decoded_event = Event.from_avro_bytes(event.avro_bytes) + self.assertEqual(event, decoded_event) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/utils.py b/tests/utils.py index 35086673..22c5722e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -34,10 +34,11 @@ from minos.common import ( Lock, MinosBroker, - MinosModel, + DeclarativeModel, MinosPool, MinosSagaManager, current_datetime, + Model, ) from minos.networks import ( CommandStatus, @@ -122,7 +123,7 @@ async def _destroy_instance(self, instance) -> None: """For testing purposes.""" -class FakeModel(MinosModel): +class FakeModel(DeclarativeModel): """For testing purposes""" text: str @@ -204,7 +205,7 @@ def __init__(self): async def send( self, - items: list[MinosModel], + items: list[Model], topic: str = None, saga: str = None, reply_topic: str = None, From b667ff2924660eb06486f7236e6bd7a9b29c0203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Thu, 11 Nov 2021 10:18:19 +0100 Subject: [PATCH 11/24] ISSUE #434 * Reformat code. --- tests/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 22c5722e..785dac99 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -32,13 +32,13 @@ InMemoryTransactionRepository, ) from minos.common import ( + DeclarativeModel, Lock, MinosBroker, - DeclarativeModel, MinosPool, MinosSagaManager, - current_datetime, Model, + current_datetime, ) from minos.networks import ( CommandStatus, From 85b91a50acd139970281b15360ac92772eed9f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Thu, 11 Nov 2021 10:20:29 +0100 Subject: [PATCH 12/24] ISSUE #434 * Add tests for `ok`. --- tests/test_networks/test_brokers/test_messages.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_networks/test_brokers/test_messages.py b/tests/test_networks/test_brokers/test_messages.py index 30ef99ea..8a79eb8f 100644 --- a/tests/test_networks/test_brokers/test_messages.py +++ b/tests/test_networks/test_brokers/test_messages.py @@ -50,6 +50,11 @@ def test_constructor(self): self.assertEqual(self.saga, command_reply.saga) self.assertEqual(self.status, command_reply.status) + def test_ok(self): + self.assertTrue(CommandReply(self.topic, self.data, self.saga, CommandStatus.SUCCESS).ok) + self.assertFalse(CommandReply(self.topic, self.data, self.saga, CommandStatus.ERROR).ok) + self.assertFalse(CommandReply(self.topic, self.data, self.saga, CommandStatus.SYSTEM_ERROR).ok) + def test_avro_serialization(self): command_reply = CommandReply(self.topic, self.data, self.saga, self.status) decoded_command = CommandReply.from_avro_bytes(command_reply.avro_bytes) From c621ea150995bad9474a2dd874b34d021ba36ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Thu, 11 Nov 2021 10:20:57 +0100 Subject: [PATCH 13/24] ISSUE #434 * Add missing docstring. --- minos/networks/brokers/messages.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/minos/networks/brokers/messages.py b/minos/networks/brokers/messages.py index ac0664a6..2b6122db 100644 --- a/minos/networks/brokers/messages.py +++ b/minos/networks/brokers/messages.py @@ -45,7 +45,10 @@ class CommandReply(DeclarativeModel): @property def ok(self) -> bool: - """TODO""" + """Check if the reply is okay or not. + + :return: ``True`` if the reply is okay or ``False`` otherwise. + """ return self.status == CommandStatus.SUCCESS From 5ef4368a1d5a908615ae84eaffbbc3ecc504b28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 09:18:04 +0100 Subject: [PATCH 14/24] ISSUE #441 * Add support for `middleware` on handling functions. --- .../brokers/subscribers/abc/handlers.py | 14 +- .../subscribers/command_replies/handlers.py | 5 +- .../brokers/subscribers/commands/handlers.py | 13 +- .../brokers/subscribers/events/handlers.py | 14 +- minos/networks/rest/handlers.py | 16 +- poetry.lock | 279 ++++++++---------- pyproject.toml | 2 +- .../test_abc/test_handlers.py | 5 +- 8 files changed, 180 insertions(+), 168 deletions(-) diff --git a/minos/networks/brokers/subscribers/abc/handlers.py b/minos/networks/brokers/subscribers/abc/handlers.py index 9ed4de4e..fa458734 100644 --- a/minos/networks/brokers/subscribers/abc/handlers.py +++ b/minos/networks/brokers/subscribers/abc/handlers.py @@ -52,11 +52,19 @@ class Handler(HandlerSetup): """ - __slots__ = "_handlers", "_records", "_retry" - - def __init__(self, records: int, handlers: dict[str, Optional[Callable]], retry: int, **kwargs: Any): + __slots__ = "_handlers", "_middleware", "_records", "_retry" + + def __init__( + self, + records: int, + handlers: dict[str, Optional[Callable]], + middleware: list[Callable], + retry: int, + **kwargs: Any, + ): super().__init__(**kwargs) self._handlers = handlers + self._middleware = middleware self._records = records self._retry = retry diff --git a/minos/networks/brokers/subscribers/command_replies/handlers.py b/minos/networks/brokers/subscribers/command_replies/handlers.py index 112c5996..3d6fe17d 100644 --- a/minos/networks/brokers/subscribers/command_replies/handlers.py +++ b/minos/networks/brokers/subscribers/command_replies/handlers.py @@ -15,6 +15,7 @@ from minos.common import ( MinosConfig, MinosSagaManager, + import_module, ) from ..abc import ( @@ -39,8 +40,10 @@ def __init__(self, saga_manager: MinosSagaManager = Provide["saga_manager"], **k @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyHandler: handlers = {f"{config.service.name}Reply": None} + middleware = list(map(import_module, config.middleware)) + # noinspection PyProtectedMember - return cls(*args, handlers=handlers, **config.broker.queue._asdict(), **kwargs) + return cls(*args, handlers=handlers, middleware=middleware, **config.broker.queue._asdict(), **kwargs) async def dispatch_one(self, entry: HandlerEntry) -> None: """Dispatch one row. diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index 1e7e8042..51966a57 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -3,6 +3,9 @@ ) import logging +from functools import ( + partial, +) from inspect import ( isawaitable, ) @@ -22,6 +25,7 @@ from minos.common import ( MinosConfig, + import_module, ) from ....decorators import ( @@ -63,8 +67,10 @@ def __init__(self, command_reply_broker: CommandReplyBroker = Provide["command_r @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandHandler: handlers = cls._handlers_from_config(config, **kwargs) + middleware = list(map(import_module, config.middleware)) + # noinspection PyProtectedMember - return cls(handlers=handlers, **config.broker.queue._asdict(), **kwargs) + return cls(middleware=middleware, handlers=handlers, **config.broker.queue._asdict(), **kwargs) @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: @@ -87,15 +93,16 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: await self.command_reply_broker.send(items, topic=command.reply_topic, saga=command.saga, status=status) - @staticmethod def get_callback( - fn: Callable[[HandlerRequest], Union[Optional[HandlerRequest], Awaitable[Optional[HandlerRequest]]]] + self, fn: Callable[[HandlerRequest], Union[Optional[HandlerRequest], Awaitable[Optional[HandlerRequest]]]] ) -> Callable[[Command], Awaitable[Tuple[Any, CommandStatus]]]: """Get the handler function to be used by the Command Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Command Handler API. """ + for f in reversed(self._middleware): + fn = partial(f, inner=fn) async def _fn(raw: Command) -> Tuple[Any, CommandStatus]: request = HandlerRequest(raw) diff --git a/minos/networks/brokers/subscribers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py index 94d7a07e..6985c96f 100644 --- a/minos/networks/brokers/subscribers/events/handlers.py +++ b/minos/networks/brokers/subscribers/events/handlers.py @@ -9,6 +9,9 @@ from collections import ( defaultdict, ) +from functools import ( + partial, +) from inspect import ( isawaitable, ) @@ -23,6 +26,7 @@ from minos.common import ( MinosConfig, + import_module, ) from ....decorators import ( @@ -56,8 +60,9 @@ class EventHandler(Handler): @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventHandler: handlers = cls._handlers_from_config(config, **kwargs) + middleware = list(map(import_module, config.middleware)) # noinspection PyProtectedMember - return cls(handlers=handlers, **config.broker.queue._asdict(), **kwargs) + return cls(handlers=handlers, middleware=middleware, **config.broker.queue._asdict(), **kwargs) @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: @@ -92,13 +97,16 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: fn = self.get_callback(entry.callback) await fn(entry.data) - @staticmethod - def get_callback(fn: Callable[[HandlerRequest], Optional[Awaitable[None]]]) -> Callable[[Event], Awaitable[None]]: + def get_callback( + self, fn: Callable[[HandlerRequest], Optional[Awaitable[None]]] + ) -> Callable[[Event], Awaitable[None]]: """Get the handler function to be used by the Event Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Event Handler API. """ + for f in reversed(self._middleware): + fn = partial(f, inner=fn) async def _fn(raw: Event) -> None: try: diff --git a/minos/networks/rest/handlers.py b/minos/networks/rest/handlers.py index e9bb1173..19974ece 100644 --- a/minos/networks/rest/handlers.py +++ b/minos/networks/rest/handlers.py @@ -5,6 +5,7 @@ import logging from functools import ( cached_property, + partial, ) from inspect import ( isawaitable, @@ -23,6 +24,7 @@ from minos.common import ( MinosConfig, MinosSetup, + import_module, ) from ..decorators import ( @@ -44,11 +46,14 @@ class RestHandler(MinosSetup): """Rest Handler class.""" - def __init__(self, host: str, port: int, endpoints: dict[(str, str), Callable], **kwargs): + def __init__( + self, host: str, port: int, endpoints: dict[(str, str), Callable], middleware: list[Callable], **kwargs + ): super().__init__(**kwargs) self._host = host self._port = port self._endpoints = endpoints + self._middleware = middleware @property def endpoints(self) -> dict[(str, str), Callable]: @@ -63,8 +68,9 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> RestHandler: host = config.rest.host port = config.rest.port endpoints = cls._endpoints_from_config(config) + middleware = list(map(import_module, config.middleware)) - return cls(host=host, port=port, endpoints=endpoints, **kwargs) + return cls(host=host, port=port, endpoints=endpoints, middleware=middleware, **kwargs) @staticmethod def _endpoints_from_config(config: MinosConfig, **kwargs) -> dict[(str, str), Callable]: @@ -114,9 +120,8 @@ def _mount_one_route(self, method: str, url: str, action: Callable, app: web.App handler = self.get_callback(action) app.router.add_route(method, url, handler) - @staticmethod def get_callback( - fn: Callable[[RestRequest], Union[Optional[RestResponse], Awaitable[Optional[RestResponse]]]] + self, fn: Callable[[RestRequest], Union[Optional[RestResponse], Awaitable[Optional[RestResponse]]]] ) -> Callable[[web.Request], Awaitable[web.Response]]: """Get the handler function to be used by the ``aiohttp`` Controller. @@ -124,6 +129,9 @@ def get_callback( :return: A wrapper function around the given one that is compatible with the ``aiohttp`` Controller. """ + for f in reversed(self._middleware): + fn = partial(f, inner=fn) + async def _fn(request: web.Request) -> web.Response: logger.info(f"Dispatching '{request!s}' from '{request.remote!s}'...") diff --git a/poetry.lock b/poetry.lock index 836ce41a..7b6fa98c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,6 +1,6 @@ [[package]] name = "aiohttp" -version = "3.8.0" +version = "3.8.1" description = "Async http client/server framework (asyncio)" category = "main" optional = false @@ -495,8 +495,8 @@ PyYAML = "^5.4.1" [package.source] type = "git" url = "https://github.com/Clariteia/minos_microservice_common.git" -reference = "issue-651-remove-command-commandreply-event" -resolved_reference = "87e944e0b14f65ddd881464233e9e85e3017108a" +reference = "issue-653-middleware-config" +resolved_reference = "2ac6940e56f5f8e616bd02577950bf5efa6089fc" [[package]] name = "mistune" @@ -599,7 +599,7 @@ virtualenv = ">=20.0.8" [[package]] name = "psycopg2-binary" -version = "2.9.1" +version = "2.9.2" description = "psycopg2 - Python-PostgreSQL Database Adapter" category = "main" optional = false @@ -886,19 +886,19 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "typed-ast" -version = "1.4.3" +version = "1.5.0" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.6" [[package]] name = "typing-extensions" -version = "3.10.0.2" -description = "Backported and Experimental Type Hints for Python 3.5+" +version = "4.0.0" +description = "Backported and Experimental Type Hints for Python 3.6+" category = "main" optional = false -python-versions = "*" +python-versions = ">=3.6" [[package]] name = "urllib3" @@ -947,82 +947,82 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "894386b0f0dfe216edca09cb51175e136d4742ac92629c6f3fd2e5fb21dcc2ca" +content-hash = "d84e72b1022b7173d28142839a37627dfdac164236af7ee962dc2499168931d8" [metadata.files] aiohttp = [ - {file = "aiohttp-3.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:48f218a5257b6bc16bcf26a91d97ecea0c7d29c811a90d965f3dd97c20f016d6"}, - {file = "aiohttp-3.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a2fee4d656a7cc9ab47771b2a9e8fad8a9a33331c1b59c3057ecf0ac858f5bfe"}, - {file = "aiohttp-3.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:688a1eb8c1a5f7e795c7cb67e0fe600194e6723ba35f138dfae0db20c0cb8f94"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ba09bb3dcb0b7ec936a485db2b64be44fe14cdce0a5eac56f50e55da3627385"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d7715daf84f10bcebc083ad137e3eced3e1c8e7fa1f096ade9a8d02b08f0d91c"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5e3f81fbbc170418e22918a9585fd7281bbc11d027064d62aa4b507552c92671"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1fa9f50aa1f114249b7963c98e20dc35c51be64096a85bc92433185f331de9cc"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8a50150419b741ee048b53146c39c47053f060cb9d98e78be08fdbe942eaa3c4"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:a84c335337b676d832c1e2bc47c3a97531b46b82de9f959dafb315cbcbe0dfcd"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:88d4917c30fcd7f6404fb1dc713fa21de59d3063dcc048f4a8a1a90e6bbbd739"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:b76669b7c058b8020b11008283c3b8e9c61bfd978807c45862956119b77ece45"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:84fe1732648c1bc303a70faa67cbc2f7f2e810c8a5bca94f6db7818e722e4c0a"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:730b7c2b7382194d9985ffdc32ab317e893bca21e0665cb1186bdfbb4089d990"}, - {file = "aiohttp-3.8.0-cp310-cp310-win32.whl", hash = "sha256:0a96473a1f61d7920a9099bc8e729dc8282539d25f79c12573ee0fdb9c8b66a8"}, - {file = "aiohttp-3.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:764c7c6aa1f78bd77bd9674fc07d1ec44654da1818d0eef9fb48aa8371a3c847"}, - {file = "aiohttp-3.8.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9951c2696c4357703001e1fe6edc6ae8e97553ac630492ea1bf64b429cb712a3"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0af379221975054162959e00daf21159ff69a712fc42ed0052caddbd70d52ff4"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9689af0f0a89e5032426c143fa3683b0451f06c83bf3b1e27902bd33acfae769"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fe4a327da0c6b6e59f2e474ae79d6ee7745ac3279fd15f200044602fa31e3d79"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:ecb314e59bedb77188017f26e6b684b1f6d0465e724c3122a726359fa62ca1ba"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a5399a44a529083951b55521cf4ecbf6ad79fd54b9df57dbf01699ffa0549fc9"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:09754a0d5eaab66c37591f2f8fac8f9781a5f61d51aa852a3261c4805ca6b984"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:adf0cb251b1b842c9dee5cfcdf880ba0aae32e841b8d0e6b6feeaef002a267c5"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:a4759e85a191de58e0ea468ab6fd9c03941986eee436e0518d7a9291fab122c8"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:28369fe331a59d80393ec82df3d43307c7461bfaf9217999e33e2acc7984ff7c"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:2f44d1b1c740a9e2275160d77c73a11f61e8a916191c572876baa7b282bcc934"}, - {file = "aiohttp-3.8.0-cp36-cp36m-win32.whl", hash = "sha256:e27cde1e8d17b09730801ce97b6e0c444ba2a1f06348b169fd931b51d3402f0d"}, - {file = "aiohttp-3.8.0-cp36-cp36m-win_amd64.whl", hash = "sha256:15a660d06092b7c92ed17c1dbe6c1eab0a02963992d60e3e8b9d5fa7fa81f01e"}, - {file = "aiohttp-3.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:257f4fad1714d26d562572095c8c5cd271d5a333252795cb7a002dca41fdbad7"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6074a3b2fa2d0c9bf0963f8dfc85e1e54a26114cc8594126bc52d3fa061c40e"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7a315ceb813208ef32bdd6ec3a85cbe3cb3be9bbda5fd030c234592fa9116993"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9a52b141ff3b923a9166595de6e3768a027546e75052ffba267d95b54267f4ab"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6a038cb1e6e55b26bb5520ccffab7f539b3786f5553af2ee47eb2ec5cbd7084e"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98b1ea2763b33559dd9ec621d67fc17b583484cb90735bfb0ec3614c17b210e4"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:9e8723c3256641e141cd18f6ce478d54a004138b9f1a36e41083b36d9ecc5fc5"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:14a6f026eca80dfa3d52e86be89feb5cd878f6f4a6adb34457e2c689fd85229b"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:c62d4791a8212c885b97a63ef5f3974b2cd41930f0cd224ada9c6ee6654f8150"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:90a97c2ed2830e7974cbe45f0838de0aefc1c123313f7c402e21c29ec063fbb4"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dcc4d5dd5fba3affaf4fd08f00ef156407573de8c63338787614ccc64f96b321"}, - {file = "aiohttp-3.8.0-cp37-cp37m-win32.whl", hash = "sha256:de42f513ed7a997bc821bddab356b72e55e8396b1b7ba1bf39926d538a76a90f"}, - {file = "aiohttp-3.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:7d76e8a83396e06abe3df569b25bd3fc88bf78b7baa2c8e4cf4aaf5983af66a3"}, - {file = "aiohttp-3.8.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5d79174d96446a02664e2bffc95e7b6fa93b9e6d8314536c5840dff130d0878b"}, - {file = "aiohttp-3.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4a6551057a846bf72c7a04f73de3fcaca269c0bd85afe475ceb59d261c6a938c"}, - {file = "aiohttp-3.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:871d4fdc56288caa58b1094c20f2364215f7400411f76783ea19ad13be7c8e19"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ba08a71caa42eef64357257878fb17f3fba3fba6e81a51d170e32321569e079"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:51f90dabd9933b1621260b32c2f0d05d36923c7a5a909eb823e429dba0fd2f3e"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f348ebd20554e8bc26e8ef3ed8a134110c0f4bf015b3b4da6a4ddf34e0515b19"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d5f8c04574efa814a24510122810e3a3c77c0552f9f6ff65c9862f1f046be2c3"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:5ecffdc748d3b40dd3618ede0170e4f5e1d3c9647cfb410d235d19e62cb54ee0"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:577cc2c7b807b174814dac2d02e673728f2e46c7f90ceda3a70ea4bb6d90b769"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:6b79f6c31e68b6dafc0317ec453c83c86dd8db1f8f0c6f28e97186563fca87a0"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:2bdd655732e38b40f8a8344d330cfae3c727fb257585df923316aabbd489ccb8"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:63fa57a0708573d3c059f7b5527617bd0c291e4559298473df238d502e4ab98c"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d3f90ee275b1d7c942e65b5c44c8fb52d55502a0b9a679837d71be2bd8927661"}, - {file = "aiohttp-3.8.0-cp38-cp38-win32.whl", hash = "sha256:fa818609357dde5c4a94a64c097c6404ad996b1d38ca977a72834b682830a722"}, - {file = "aiohttp-3.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:097ecf52f6b9859b025c1e36401f8aa4573552e887d1b91b4b999d68d0b5a3b3"}, - {file = "aiohttp-3.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:be03a7483ad9ea60388f930160bb3728467dd0af538aa5edc60962ee700a0bdc"}, - {file = "aiohttp-3.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:78d51e35ed163783d721b6f2ce8ce3f82fccfe471e8e50a10fba13a766d31f5a"}, - {file = "aiohttp-3.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:bda75d73e7400e81077b0910c9a60bf9771f715420d7e35fa7739ae95555f195"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:707adc30ea6918fba725c3cb3fe782d271ba352b22d7ae54a7f9f2e8a8488c41"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3f58aa995b905ab82fe228acd38538e7dc1509e01508dcf307dad5046399130f"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c996eb91bfbdab1e01e2c02e7ff678c51e2b28e3a04e26e41691991cc55795"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d6a1a66bb8bac9bc2892c2674ea363486bfb748b86504966a390345a11b1680e"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:dafc01a32b4a1d7d3ef8bfd3699406bb44f7b2e0d3eb8906d574846e1019b12f"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:949a605ef3907254b122f845baa0920407080cdb1f73aa64f8d47df4a7f4c4f9"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:0d7b056fd3972d353cb4bc305c03f9381583766b7f8c7f1c44478dba69099e33"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:6f1d39a744101bf4043fa0926b3ead616607578192d0a169974fb5265ab1e9d2"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:67ca7032dfac8d001023fadafc812d9f48bf8a8c3bb15412d9cdcf92267593f4"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:cb751ef712570d3bda9a73fd765ff3e1aba943ec5d52a54a0c2e89c7eef9da1e"}, - {file = "aiohttp-3.8.0-cp39-cp39-win32.whl", hash = "sha256:6d3e027fe291b77f6be9630114a0200b2c52004ef20b94dc50ca59849cd623b3"}, - {file = "aiohttp-3.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:3c5e9981e449d54308c6824f172ec8ab63eb9c5f922920970249efee83f7e919"}, - {file = "aiohttp-3.8.0.tar.gz", hash = "sha256:d3b19d8d183bcfd68b25beebab8dc3308282fe2ca3d6ea3cb4cd101b3c279f8d"}, + {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1ed0b6477896559f17b9eaeb6d38e07f7f9ffe40b9f0f9627ae8b9926ae260a8"}, + {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7dadf3c307b31e0e61689cbf9e06be7a867c563d5a63ce9dca578f956609abf8"}, + {file = "aiohttp-3.8.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a79004bb58748f31ae1cbe9fa891054baaa46fb106c2dc7af9f8e3304dc30316"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:12de6add4038df8f72fac606dff775791a60f113a725c960f2bab01d8b8e6b15"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6f0d5f33feb5f69ddd57a4a4bd3d56c719a141080b445cbf18f238973c5c9923"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:eaba923151d9deea315be1f3e2b31cc39a6d1d2f682f942905951f4e40200922"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:099ebd2c37ac74cce10a3527d2b49af80243e2a4fa39e7bce41617fbc35fa3c1"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2e5d962cf7e1d426aa0e528a7e198658cdc8aa4fe87f781d039ad75dcd52c516"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:fa0ffcace9b3aa34d205d8130f7873fcfefcb6a4dd3dd705b0dab69af6712642"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:61bfc23df345d8c9716d03717c2ed5e27374e0fe6f659ea64edcd27b4b044cf7"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:31560d268ff62143e92423ef183680b9829b1b482c011713ae941997921eebc8"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:01d7bdb774a9acc838e6b8f1d114f45303841b89b95984cbb7d80ea41172a9e3"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:97ef77eb6b044134c0b3a96e16abcb05ecce892965a2124c566af0fd60f717e2"}, + {file = "aiohttp-3.8.1-cp310-cp310-win32.whl", hash = "sha256:c2aef4703f1f2ddc6df17519885dbfa3514929149d3ff900b73f45998f2532fa"}, + {file = "aiohttp-3.8.1-cp310-cp310-win_amd64.whl", hash = "sha256:713ac174a629d39b7c6a3aa757b337599798da4c1157114a314e4e391cd28e32"}, + {file = "aiohttp-3.8.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:473d93d4450880fe278696549f2e7aed8cd23708c3c1997981464475f32137db"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99b5eeae8e019e7aad8af8bb314fb908dd2e028b3cdaad87ec05095394cce632"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3af642b43ce56c24d063325dd2cf20ee012d2b9ba4c3c008755a301aaea720ad"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3630c3ef435c0a7c549ba170a0633a56e92629aeed0e707fec832dee313fb7a"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:4a4a4e30bf1edcad13fb0804300557aedd07a92cabc74382fdd0ba6ca2661091"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6f8b01295e26c68b3a1b90efb7a89029110d3a4139270b24fda961893216c440"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:a25fa703a527158aaf10dafd956f7d42ac6d30ec80e9a70846253dd13e2f067b"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:5bfde62d1d2641a1f5173b8c8c2d96ceb4854f54a44c23102e2ccc7e02f003ec"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:51467000f3647d519272392f484126aa716f747859794ac9924a7aafa86cd411"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:03a6d5349c9ee8f79ab3ff3694d6ce1cfc3ced1c9d36200cb8f08ba06bd3b782"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:102e487eeb82afac440581e5d7f8f44560b36cf0bdd11abc51a46c1cd88914d4"}, + {file = "aiohttp-3.8.1-cp36-cp36m-win32.whl", hash = "sha256:4aed991a28ea3ce320dc8ce655875e1e00a11bdd29fe9444dd4f88c30d558602"}, + {file = "aiohttp-3.8.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b0e20cddbd676ab8a64c774fefa0ad787cc506afd844de95da56060348021e96"}, + {file = "aiohttp-3.8.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:37951ad2f4a6df6506750a23f7cbabad24c73c65f23f72e95897bb2cecbae676"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c23b1ad869653bc818e972b7a3a79852d0e494e9ab7e1a701a3decc49c20d51"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:15b09b06dae900777833fe7fc4b4aa426556ce95847a3e8d7548e2d19e34edb8"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:477c3ea0ba410b2b56b7efb072c36fa91b1e6fc331761798fa3f28bb224830dd"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2f2f69dca064926e79997f45b2f34e202b320fd3782f17a91941f7eb85502ee2"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ef9612483cb35171d51d9173647eed5d0069eaa2ee812793a75373447d487aa4"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:6d69f36d445c45cda7b3b26afef2fc34ef5ac0cdc75584a87ef307ee3c8c6d00"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:55c3d1072704d27401c92339144d199d9de7b52627f724a949fc7d5fc56d8b93"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:b9d00268fcb9f66fbcc7cd9fe423741d90c75ee029a1d15c09b22d23253c0a44"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:07b05cd3305e8a73112103c834e91cd27ce5b4bd07850c4b4dbd1877d3f45be7"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c34dc4958b232ef6188c4318cb7b2c2d80521c9a56c52449f8f93ab7bc2a8a1c"}, + {file = "aiohttp-3.8.1-cp37-cp37m-win32.whl", hash = "sha256:d2f9b69293c33aaa53d923032fe227feac867f81682f002ce33ffae978f0a9a9"}, + {file = "aiohttp-3.8.1-cp37-cp37m-win_amd64.whl", hash = "sha256:6ae828d3a003f03ae31915c31fa684b9890ea44c9c989056fea96e3d12a9fa17"}, + {file = "aiohttp-3.8.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:0c7ebbbde809ff4e970824b2b6cb7e4222be6b95a296e46c03cf050878fc1785"}, + {file = "aiohttp-3.8.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8b7ef7cbd4fec9a1e811a5de813311ed4f7ac7d93e0fda233c9b3e1428f7dd7b"}, + {file = "aiohttp-3.8.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c3d6a4d0619e09dcd61021debf7059955c2004fa29f48788a3dfaf9c9901a7cd"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:718626a174e7e467f0558954f94af117b7d4695d48eb980146016afa4b580b2e"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:589c72667a5febd36f1315aa6e5f56dd4aa4862df295cb51c769d16142ddd7cd"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2ed076098b171573161eb146afcb9129b5ff63308960aeca4b676d9d3c35e700"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:086f92daf51a032d062ec5f58af5ca6a44d082c35299c96376a41cbb33034675"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:11691cf4dc5b94236ccc609b70fec991234e7ef8d4c02dd0c9668d1e486f5abf"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:31d1e1c0dbf19ebccbfd62eff461518dcb1e307b195e93bba60c965a4dcf1ba0"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:11a67c0d562e07067c4e86bffc1553f2cf5b664d6111c894671b2b8712f3aba5"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:bb01ba6b0d3f6c68b89fce7305080145d4877ad3acaed424bae4d4ee75faa950"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:44db35a9e15d6fe5c40d74952e803b1d96e964f683b5a78c3cc64eb177878155"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:844a9b460871ee0a0b0b68a64890dae9c415e513db0f4a7e3cab41a0f2fedf33"}, + {file = "aiohttp-3.8.1-cp38-cp38-win32.whl", hash = "sha256:7d08744e9bae2ca9c382581f7dce1273fe3c9bae94ff572c3626e8da5b193c6a"}, + {file = "aiohttp-3.8.1-cp38-cp38-win_amd64.whl", hash = "sha256:04d48b8ce6ab3cf2097b1855e1505181bdd05586ca275f2505514a6e274e8e75"}, + {file = "aiohttp-3.8.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f5315a2eb0239185af1bddb1abf472d877fede3cc8d143c6cddad37678293237"}, + {file = "aiohttp-3.8.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a996d01ca39b8dfe77440f3cd600825d05841088fd6bc0144cc6c2ec14cc5f74"}, + {file = "aiohttp-3.8.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:13487abd2f761d4be7c8ff9080de2671e53fff69711d46de703c310c4c9317ca"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea302f34477fda3f85560a06d9ebdc7fa41e82420e892fc50b577e35fc6a50b2"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a2f635ce61a89c5732537a7896b6319a8fcfa23ba09bec36e1b1ac0ab31270d2"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e999f2d0e12eea01caeecb17b653f3713d758f6dcc770417cf29ef08d3931421"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0770e2806a30e744b4e21c9d73b7bee18a1cfa3c47991ee2e5a65b887c49d5cf"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:d15367ce87c8e9e09b0f989bfd72dc641bcd04ba091c68cd305312d00962addd"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:6c7cefb4b0640703eb1069835c02486669312bf2f12b48a748e0a7756d0de33d"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:71927042ed6365a09a98a6377501af5c9f0a4d38083652bcd2281a06a5976724"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:28d490af82bc6b7ce53ff31337a18a10498303fe66f701ab65ef27e143c3b0ef"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:b6613280ccedf24354406caf785db748bebbddcf31408b20c0b48cb86af76866"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:81e3d8c34c623ca4e36c46524a3530e99c0bc95ed068fd6e9b55cb721d408fb2"}, + {file = "aiohttp-3.8.1-cp39-cp39-win32.whl", hash = "sha256:7187a76598bdb895af0adbd2fb7474d7f6025d170bc0a1130242da817ce9e7d1"}, + {file = "aiohttp-3.8.1-cp39-cp39-win_amd64.whl", hash = "sha256:1c182cb873bc91b411e184dab7a2b664d4fea2743df0e4d57402f7f3fa644bac"}, + {file = "aiohttp-3.8.1.tar.gz", hash = "sha256:fc5471e1a54de15ef71c1bc6ebe80d4dc681ea600e68bfd1cbce40427f0b7578"}, ] aiokafka = [ {file = "aiokafka-0.7.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b19f077e12fe23e359f7a7dca9baf8532c63f4c8149703ce4c56de372d17e26c"}, @@ -1646,42 +1646,32 @@ pre-commit = [ {file = "pre_commit-2.15.0.tar.gz", hash = "sha256:3c25add78dbdfb6a28a651780d5c311ac40dd17f160eb3954a0c59da40a505a7"}, ] psycopg2-binary = [ - {file = "psycopg2-binary-2.9.1.tar.gz", hash = "sha256:b0221ca5a9837e040ebf61f48899926b5783668b7807419e4adae8175a31f773"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:24b0b6688b9f31a911f2361fe818492650795c9e5d3a1bc647acbd7440142a4f"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:542875f62bc56e91c6eac05a0deadeae20e1730be4c6334d8f04c944fcd99759"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:661509f51531ec125e52357a489ea3806640d0ca37d9dada461ffc69ee1e7b6e"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:d92272c7c16e105788efe2cfa5d680f07e34e0c29b03c1908f8636f55d5f915a"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_24_ppc64le.whl", hash = "sha256:736b8797b58febabb85494142c627bd182b50d2a7ec65322983e71065ad3034c"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-win32.whl", hash = "sha256:ebccf1123e7ef66efc615a68295bf6fdba875a75d5bba10a05073202598085fc"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-win_amd64.whl", hash = "sha256:1f6ca4a9068f5c5c57e744b4baa79f40e83e3746875cac3c45467b16326bab45"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:c250a7ec489b652c892e4f0a5d122cc14c3780f9f643e1a326754aedf82d9a76"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aef9aee84ec78af51107181d02fe8773b100b01c5dfde351184ad9223eab3698"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:123c3fb684e9abfc47218d3784c7b4c47c8587951ea4dd5bc38b6636ac57f616"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_24_aarch64.whl", hash = "sha256:995fc41ebda5a7a663a254a1dcac52638c3e847f48307b5416ee373da15075d7"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_24_ppc64le.whl", hash = "sha256:fbb42a541b1093385a2d8c7eec94d26d30437d0e77c1d25dae1dcc46741a385e"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-win32.whl", hash = "sha256:20f1ab44d8c352074e2d7ca67dc00843067788791be373e67a0911998787ce7d"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f6fac64a38f6768e7bc7b035b9e10d8a538a9fadce06b983fb3e6fa55ac5f5ce"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:1e3a362790edc0a365385b1ac4cc0acc429a0c0d662d829a50b6ce743ae61b5a"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f8559617b1fcf59a9aedba2c9838b5b6aa211ffedecabca412b92a1ff75aac1a"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a36c7eb6152ba5467fb264d73844877be8b0847874d4822b7cf2d3c0cb8cdcb0"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_24_aarch64.whl", hash = "sha256:2f62c207d1740b0bde5c4e949f857b044818f734a3d57f1d0d0edc65050532ed"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_24_ppc64le.whl", hash = "sha256:cfc523edecddaef56f6740d7de1ce24a2fdf94fd5e704091856a201872e37f9f"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-win32.whl", hash = "sha256:1e85b74cbbb3056e3656f1cc4781294df03383127a8114cbc6531e8b8367bf1e"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-win_amd64.whl", hash = "sha256:1473c0215b0613dd938db54a653f68251a45a78b05f6fc21af4326f40e8360a2"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:35c4310f8febe41f442d3c65066ca93cccefd75013df3d8c736c5b93ec288140"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8c13d72ed6af7fd2c8acbd95661cf9477f94e381fce0792c04981a8283b52917"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14db1752acdd2187d99cb2ca0a1a6dfe57fc65c3281e0f20e597aac8d2a5bd90"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_24_aarch64.whl", hash = "sha256:aed4a9a7e3221b3e252c39d0bf794c438dc5453bc2963e8befe9d4cd324dff72"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_24_ppc64le.whl", hash = "sha256:da113b70f6ec40e7d81b43d1b139b9db6a05727ab8be1ee559f3a69854a69d34"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-win32.whl", hash = "sha256:4235f9d5ddcab0b8dbd723dca56ea2922b485ea00e1dafacf33b0c7e840b3d32"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-win_amd64.whl", hash = "sha256:988b47ac70d204aed01589ed342303da7c4d84b56c2f4c4b8b00deda123372bf"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:7360647ea04db2e7dff1648d1da825c8cf68dc5fbd80b8fb5b3ee9f068dcd21a"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca86db5b561b894f9e5f115d6a159fff2a2570a652e07889d8a383b5fae66eb4"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ced67f1e34e1a450cdb48eb53ca73b60aa0af21c46b9b35ac3e581cf9f00e31"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:0f2e04bd2a2ab54fa44ee67fe2d002bb90cee1c0f1cc0ebc3148af7b02034cbd"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_24_ppc64le.whl", hash = "sha256:3242b9619de955ab44581a03a64bdd7d5e470cc4183e8fcadd85ab9d3756ce7a"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-win32.whl", hash = "sha256:0b7dae87f0b729922e06f85f667de7bf16455d411971b2043bbd9577af9d1975"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-win_amd64.whl", hash = "sha256:b4d7679a08fea64573c969f6994a2631908bb2c0e69a7235648642f3d2e39a68"}, + {file = "psycopg2-binary-2.9.2.tar.gz", hash = "sha256:234b1f48488b2f86aac04fb00cb04e5e9bcb960f34fa8a8e41b73149d581a93b"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:c0e1fb7097ded2cc44d9037cfc68ad86a30341261492e7de95d180e534969fb2"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:717525cdc97b23182ff6f470fb5bf6f0bc796b5a7000c6f6699d6679991e4a5e"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3865d0cd919349c45603bd7e80249a382c5ecf8106304cfd153282adf9684b6a"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:daf6b5c62eb738872d61a1fa740d7768904911ba5a7e055ed72169d379b58beb"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_24_ppc64le.whl", hash = "sha256:3ac83656ff4fbe7f2a956ab085e3eb1d678df54759965d509bdd6a06ce520d49"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:53912199abb626a7249c662e72b70b4f57bf37f840599cec68625171435790dd"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:029e09a892b9ebc3c77851f69ce0720e1b72a9c6850460cee49b14dfbf9ccdd2"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db1b03c189f85b8df29030ad32d521dd7dcb862fd5f8892035314f5b886e70ce"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_24_aarch64.whl", hash = "sha256:2eecbdc5fa5886f2dd6cc673ce4291cc0fb8900965315268960ad9c2477f8276"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_24_ppc64le.whl", hash = "sha256:a77e98c68b0e6c51d4d6a994d22b30e77276cbd33e4aabdde03b9ad3a2c148aa"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:a507db7758953b1b170c4310691a1a89877029b1e11b08ba5fc8ae3ddb35596b"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2e4bbcfb403221ea1953f3e0a85cef00ed15c1683a66cf35c956a7e37c33a4c4"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f4dff0f15af6936c6fe6da7067b4216edbbe076ad8625da819cc066591b1133c"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_24_aarch64.whl", hash = "sha256:8d2aafe46eb87742425ece38130510fbb035787ee89a329af299029c4d9ae318"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_24_ppc64le.whl", hash = "sha256:37c8f00f7a2860bac9f7a54f03c243fc1dd9b367e5b2b52f5a02e5f4e9d8c49b"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:eeee7b18c51d02e49bf1984d7af26e8843fe68e31fa1cbab5366ebdfa1c89ade"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:497372cc76e6cbce2f51b37be141f360a321423c03eb9be45524b1d123f4cd11"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5671699aff57d22a245b7f4bba89e3de97dc841c5e98bd7f685429b2b20eca47"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_24_aarch64.whl", hash = "sha256:b9d45374ba98c1184df9cce93a0b766097544f8bdfcd5de83ff10f939c193125"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_24_ppc64le.whl", hash = "sha256:a1852c5bef7e5f52bd43fde5eda610d4df0fb2efc31028150933e84b4140d47a"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:578c279cd1ce04f05ae0912530ece00bab92854911808e5aec27588aba87e361"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c2dea4deac3dd3687e32daeb0712ee96c535970dfdded37a11de6a21145ab0e"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b592f09ff18cfcc9037b9a976fcd62db48cae9dbd5385f2471d4c2ba40c52b4d"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:3a320e7a804f3886a599fea507364aaafbb8387027fffcdfbd34d96316c806c7"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_24_ppc64le.whl", hash = "sha256:7585ca73dcfe326f31fafa8f96e6bb98ea9e9e46c7a1924ec8101d797914ae27"}, ] py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, @@ -1854,41 +1844,28 @@ toml = [ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] typed-ast = [ - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, - {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, - {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, - {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, - {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, - {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, - {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, - {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, - {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, - {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, - {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, - {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, - {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, - {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, - {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, - {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, + {file = "typed_ast-1.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7b310a207ee9fde3f46ba327989e6cba4195bc0c8c70a158456e7b10233e6bed"}, + {file = "typed_ast-1.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:52ca2b2b524d770bed7a393371a38e91943f9160a190141e0df911586066ecda"}, + {file = "typed_ast-1.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:14fed8820114a389a2b7e91624db5f85f3f6682fda09fe0268a59aabd28fe5f5"}, + {file = "typed_ast-1.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:65c81abbabda7d760df7304d843cc9dbe7ef5d485504ca59a46ae2d1731d2428"}, + {file = "typed_ast-1.5.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:37ba2ab65a0028b1a4f2b61a8fe77f12d242731977d274a03d68ebb751271508"}, + {file = "typed_ast-1.5.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:49af5b8f6f03ed1eb89ee06c1d7c2e7c8e743d720c3746a5857609a1abc94c94"}, + {file = "typed_ast-1.5.0-cp36-cp36m-win_amd64.whl", hash = "sha256:e4374a76e61399a173137e7984a1d7e356038cf844f24fd8aea46c8029a2f712"}, + {file = "typed_ast-1.5.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:ea517c2bb11c5e4ba7a83a91482a2837041181d57d3ed0749a6c382a2b6b7086"}, + {file = "typed_ast-1.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:51040bf45aacefa44fa67fb9ebcd1f2bec73182b99a532c2394eea7dabd18e24"}, + {file = "typed_ast-1.5.0-cp37-cp37m-win_amd64.whl", hash = "sha256:806e0c7346b9b4af8c62d9a29053f484599921a4448c37fbbcbbf15c25138570"}, + {file = "typed_ast-1.5.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a67fd5914603e2165e075f1b12f5a8356bfb9557e8bfb74511108cfbab0f51ed"}, + {file = "typed_ast-1.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:224afecb8b39739f5c9562794a7c98325cb9d972712e1a98b6989a4720219541"}, + {file = "typed_ast-1.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:155b74b078be842d2eb630dd30a280025eca0a5383c7d45853c27afee65f278f"}, + {file = "typed_ast-1.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:361b9e5d27bd8e3ccb6ea6ad6c4f3c0be322a1a0f8177db6d56264fa0ae40410"}, + {file = "typed_ast-1.5.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:618912cbc7e17b4aeba86ffe071698c6e2d292acbd6d1d5ec1ee724b8c4ae450"}, + {file = "typed_ast-1.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7e6731044f748340ef68dcadb5172a4b1f40847a2983fe3983b2a66445fbc8e6"}, + {file = "typed_ast-1.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e8a9b9c87801cecaad3b4c2b8876387115d1a14caa602c1618cedbb0cb2a14e6"}, + {file = "typed_ast-1.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:ec184dfb5d3d11e82841dbb973e7092b75f306b625fad7b2e665b64c5d60ab3f"}, + {file = "typed_ast-1.5.0.tar.gz", hash = "sha256:ff4ad88271aa7a55f19b6a161ed44e088c393846d954729549e3cde8257747bb"}, ] typing-extensions = [ - {file = "typing_extensions-3.10.0.2-py2-none-any.whl", hash = "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7"}, - {file = "typing_extensions-3.10.0.2-py3-none-any.whl", hash = "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34"}, - {file = "typing_extensions-3.10.0.2.tar.gz", hash = "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"}, + {file = "typing_extensions-4.0.0-py3-none-any.whl", hash = "sha256:829704698b22e13ec9eaf959122315eabb370b0884400e9818334d8b677023d9"}, ] urllib3 = [ {file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"}, diff --git a/pyproject.toml b/pyproject.toml index e49c2845..e0997750 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ aiomisc = "^14.0.3" aiopg = "^1.2.1" aiohttp = "^3.7.4" dependency-injector = "^4.32.2" -minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-651-remove-command-commandreply-event" } +minos-microservice-common = { path = "../minos_microservice_common", develop = true } minos-microservice-aggregate = "^0.1.0" crontab = "^0.23.0" diff --git a/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py index 35348098..606a594a 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py @@ -73,7 +73,8 @@ def setUp(self) -> None: super().setUp() handlers = self.handlers() handlers["empty"] = None - self.handler = _FakeHandler(handlers=handlers, **self.config.broker.queue._asdict()) + middleware = list() + self.handler = _FakeHandler(handlers=handlers, middleware=middleware, **self.config.broker.queue._asdict()) async def test_get_action(self): action = self.handler.get_action(topic="AddOrder") @@ -116,7 +117,7 @@ async def test_dispatch_forever_without_notify(self): self.assertEqual(3, mock_count.call_count) async def test_dispatch_forever_without_topics(self): - handler = _FakeHandler(handlers=dict(), **self.config.broker.queue._asdict()) + handler = _FakeHandler(handlers=dict(), middleware=list(), **self.config.broker.queue._asdict()) mock = AsyncMock() async with handler: handler.dispatch = mock From 032f60b7f3206a101149ebb245108c0d7083ce6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 09:23:12 +0100 Subject: [PATCH 15/24] Revert "ISSUE #441" This reverts commit 5ef4368a1d5a908615ae84eaffbbc3ecc504b28e. --- .../brokers/subscribers/abc/handlers.py | 14 +- .../subscribers/command_replies/handlers.py | 5 +- .../brokers/subscribers/commands/handlers.py | 13 +- .../brokers/subscribers/events/handlers.py | 14 +- minos/networks/rest/handlers.py | 16 +- poetry.lock | 279 ++++++++++-------- pyproject.toml | 2 +- .../test_abc/test_handlers.py | 5 +- 8 files changed, 168 insertions(+), 180 deletions(-) diff --git a/minos/networks/brokers/subscribers/abc/handlers.py b/minos/networks/brokers/subscribers/abc/handlers.py index fa458734..9ed4de4e 100644 --- a/minos/networks/brokers/subscribers/abc/handlers.py +++ b/minos/networks/brokers/subscribers/abc/handlers.py @@ -52,19 +52,11 @@ class Handler(HandlerSetup): """ - __slots__ = "_handlers", "_middleware", "_records", "_retry" - - def __init__( - self, - records: int, - handlers: dict[str, Optional[Callable]], - middleware: list[Callable], - retry: int, - **kwargs: Any, - ): + __slots__ = "_handlers", "_records", "_retry" + + def __init__(self, records: int, handlers: dict[str, Optional[Callable]], retry: int, **kwargs: Any): super().__init__(**kwargs) self._handlers = handlers - self._middleware = middleware self._records = records self._retry = retry diff --git a/minos/networks/brokers/subscribers/command_replies/handlers.py b/minos/networks/brokers/subscribers/command_replies/handlers.py index 3d6fe17d..112c5996 100644 --- a/minos/networks/brokers/subscribers/command_replies/handlers.py +++ b/minos/networks/brokers/subscribers/command_replies/handlers.py @@ -15,7 +15,6 @@ from minos.common import ( MinosConfig, MinosSagaManager, - import_module, ) from ..abc import ( @@ -40,10 +39,8 @@ def __init__(self, saga_manager: MinosSagaManager = Provide["saga_manager"], **k @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyHandler: handlers = {f"{config.service.name}Reply": None} - middleware = list(map(import_module, config.middleware)) - # noinspection PyProtectedMember - return cls(*args, handlers=handlers, middleware=middleware, **config.broker.queue._asdict(), **kwargs) + return cls(*args, handlers=handlers, **config.broker.queue._asdict(), **kwargs) async def dispatch_one(self, entry: HandlerEntry) -> None: """Dispatch one row. diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index 51966a57..1e7e8042 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -3,9 +3,6 @@ ) import logging -from functools import ( - partial, -) from inspect import ( isawaitable, ) @@ -25,7 +22,6 @@ from minos.common import ( MinosConfig, - import_module, ) from ....decorators import ( @@ -67,10 +63,8 @@ def __init__(self, command_reply_broker: CommandReplyBroker = Provide["command_r @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandHandler: handlers = cls._handlers_from_config(config, **kwargs) - middleware = list(map(import_module, config.middleware)) - # noinspection PyProtectedMember - return cls(middleware=middleware, handlers=handlers, **config.broker.queue._asdict(), **kwargs) + return cls(handlers=handlers, **config.broker.queue._asdict(), **kwargs) @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: @@ -93,16 +87,15 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: await self.command_reply_broker.send(items, topic=command.reply_topic, saga=command.saga, status=status) + @staticmethod def get_callback( - self, fn: Callable[[HandlerRequest], Union[Optional[HandlerRequest], Awaitable[Optional[HandlerRequest]]]] + fn: Callable[[HandlerRequest], Union[Optional[HandlerRequest], Awaitable[Optional[HandlerRequest]]]] ) -> Callable[[Command], Awaitable[Tuple[Any, CommandStatus]]]: """Get the handler function to be used by the Command Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Command Handler API. """ - for f in reversed(self._middleware): - fn = partial(f, inner=fn) async def _fn(raw: Command) -> Tuple[Any, CommandStatus]: request = HandlerRequest(raw) diff --git a/minos/networks/brokers/subscribers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py index 6985c96f..94d7a07e 100644 --- a/minos/networks/brokers/subscribers/events/handlers.py +++ b/minos/networks/brokers/subscribers/events/handlers.py @@ -9,9 +9,6 @@ from collections import ( defaultdict, ) -from functools import ( - partial, -) from inspect import ( isawaitable, ) @@ -26,7 +23,6 @@ from minos.common import ( MinosConfig, - import_module, ) from ....decorators import ( @@ -60,9 +56,8 @@ class EventHandler(Handler): @classmethod def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventHandler: handlers = cls._handlers_from_config(config, **kwargs) - middleware = list(map(import_module, config.middleware)) # noinspection PyProtectedMember - return cls(handlers=handlers, middleware=middleware, **config.broker.queue._asdict(), **kwargs) + return cls(handlers=handlers, **config.broker.queue._asdict(), **kwargs) @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: @@ -97,16 +92,13 @@ async def dispatch_one(self, entry: HandlerEntry) -> None: fn = self.get_callback(entry.callback) await fn(entry.data) - def get_callback( - self, fn: Callable[[HandlerRequest], Optional[Awaitable[None]]] - ) -> Callable[[Event], Awaitable[None]]: + @staticmethod + def get_callback(fn: Callable[[HandlerRequest], Optional[Awaitable[None]]]) -> Callable[[Event], Awaitable[None]]: """Get the handler function to be used by the Event Handler. :param fn: The action function. :return: A wrapper function around the given one that is compatible with the Event Handler API. """ - for f in reversed(self._middleware): - fn = partial(f, inner=fn) async def _fn(raw: Event) -> None: try: diff --git a/minos/networks/rest/handlers.py b/minos/networks/rest/handlers.py index 19974ece..e9bb1173 100644 --- a/minos/networks/rest/handlers.py +++ b/minos/networks/rest/handlers.py @@ -5,7 +5,6 @@ import logging from functools import ( cached_property, - partial, ) from inspect import ( isawaitable, @@ -24,7 +23,6 @@ from minos.common import ( MinosConfig, MinosSetup, - import_module, ) from ..decorators import ( @@ -46,14 +44,11 @@ class RestHandler(MinosSetup): """Rest Handler class.""" - def __init__( - self, host: str, port: int, endpoints: dict[(str, str), Callable], middleware: list[Callable], **kwargs - ): + def __init__(self, host: str, port: int, endpoints: dict[(str, str), Callable], **kwargs): super().__init__(**kwargs) self._host = host self._port = port self._endpoints = endpoints - self._middleware = middleware @property def endpoints(self) -> dict[(str, str), Callable]: @@ -68,9 +63,8 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> RestHandler: host = config.rest.host port = config.rest.port endpoints = cls._endpoints_from_config(config) - middleware = list(map(import_module, config.middleware)) - return cls(host=host, port=port, endpoints=endpoints, middleware=middleware, **kwargs) + return cls(host=host, port=port, endpoints=endpoints, **kwargs) @staticmethod def _endpoints_from_config(config: MinosConfig, **kwargs) -> dict[(str, str), Callable]: @@ -120,8 +114,9 @@ def _mount_one_route(self, method: str, url: str, action: Callable, app: web.App handler = self.get_callback(action) app.router.add_route(method, url, handler) + @staticmethod def get_callback( - self, fn: Callable[[RestRequest], Union[Optional[RestResponse], Awaitable[Optional[RestResponse]]]] + fn: Callable[[RestRequest], Union[Optional[RestResponse], Awaitable[Optional[RestResponse]]]] ) -> Callable[[web.Request], Awaitable[web.Response]]: """Get the handler function to be used by the ``aiohttp`` Controller. @@ -129,9 +124,6 @@ def get_callback( :return: A wrapper function around the given one that is compatible with the ``aiohttp`` Controller. """ - for f in reversed(self._middleware): - fn = partial(f, inner=fn) - async def _fn(request: web.Request) -> web.Response: logger.info(f"Dispatching '{request!s}' from '{request.remote!s}'...") diff --git a/poetry.lock b/poetry.lock index 7b6fa98c..836ce41a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,6 +1,6 @@ [[package]] name = "aiohttp" -version = "3.8.1" +version = "3.8.0" description = "Async http client/server framework (asyncio)" category = "main" optional = false @@ -495,8 +495,8 @@ PyYAML = "^5.4.1" [package.source] type = "git" url = "https://github.com/Clariteia/minos_microservice_common.git" -reference = "issue-653-middleware-config" -resolved_reference = "2ac6940e56f5f8e616bd02577950bf5efa6089fc" +reference = "issue-651-remove-command-commandreply-event" +resolved_reference = "87e944e0b14f65ddd881464233e9e85e3017108a" [[package]] name = "mistune" @@ -599,7 +599,7 @@ virtualenv = ">=20.0.8" [[package]] name = "psycopg2-binary" -version = "2.9.2" +version = "2.9.1" description = "psycopg2 - Python-PostgreSQL Database Adapter" category = "main" optional = false @@ -886,19 +886,19 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "typed-ast" -version = "1.5.0" +version = "1.4.3" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false -python-versions = ">=3.6" +python-versions = "*" [[package]] name = "typing-extensions" -version = "4.0.0" -description = "Backported and Experimental Type Hints for Python 3.6+" +version = "3.10.0.2" +description = "Backported and Experimental Type Hints for Python 3.5+" category = "main" optional = false -python-versions = ">=3.6" +python-versions = "*" [[package]] name = "urllib3" @@ -947,82 +947,82 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "d84e72b1022b7173d28142839a37627dfdac164236af7ee962dc2499168931d8" +content-hash = "894386b0f0dfe216edca09cb51175e136d4742ac92629c6f3fd2e5fb21dcc2ca" [metadata.files] aiohttp = [ - {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1ed0b6477896559f17b9eaeb6d38e07f7f9ffe40b9f0f9627ae8b9926ae260a8"}, - {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7dadf3c307b31e0e61689cbf9e06be7a867c563d5a63ce9dca578f956609abf8"}, - {file = "aiohttp-3.8.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a79004bb58748f31ae1cbe9fa891054baaa46fb106c2dc7af9f8e3304dc30316"}, - {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:12de6add4038df8f72fac606dff775791a60f113a725c960f2bab01d8b8e6b15"}, - {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6f0d5f33feb5f69ddd57a4a4bd3d56c719a141080b445cbf18f238973c5c9923"}, - {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:eaba923151d9deea315be1f3e2b31cc39a6d1d2f682f942905951f4e40200922"}, - {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:099ebd2c37ac74cce10a3527d2b49af80243e2a4fa39e7bce41617fbc35fa3c1"}, - {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2e5d962cf7e1d426aa0e528a7e198658cdc8aa4fe87f781d039ad75dcd52c516"}, - {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:fa0ffcace9b3aa34d205d8130f7873fcfefcb6a4dd3dd705b0dab69af6712642"}, - {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:61bfc23df345d8c9716d03717c2ed5e27374e0fe6f659ea64edcd27b4b044cf7"}, - {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:31560d268ff62143e92423ef183680b9829b1b482c011713ae941997921eebc8"}, - {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:01d7bdb774a9acc838e6b8f1d114f45303841b89b95984cbb7d80ea41172a9e3"}, - {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:97ef77eb6b044134c0b3a96e16abcb05ecce892965a2124c566af0fd60f717e2"}, - {file = "aiohttp-3.8.1-cp310-cp310-win32.whl", hash = "sha256:c2aef4703f1f2ddc6df17519885dbfa3514929149d3ff900b73f45998f2532fa"}, - {file = "aiohttp-3.8.1-cp310-cp310-win_amd64.whl", hash = "sha256:713ac174a629d39b7c6a3aa757b337599798da4c1157114a314e4e391cd28e32"}, - {file = "aiohttp-3.8.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:473d93d4450880fe278696549f2e7aed8cd23708c3c1997981464475f32137db"}, - {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99b5eeae8e019e7aad8af8bb314fb908dd2e028b3cdaad87ec05095394cce632"}, - {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3af642b43ce56c24d063325dd2cf20ee012d2b9ba4c3c008755a301aaea720ad"}, - {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3630c3ef435c0a7c549ba170a0633a56e92629aeed0e707fec832dee313fb7a"}, - {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:4a4a4e30bf1edcad13fb0804300557aedd07a92cabc74382fdd0ba6ca2661091"}, - {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6f8b01295e26c68b3a1b90efb7a89029110d3a4139270b24fda961893216c440"}, - {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:a25fa703a527158aaf10dafd956f7d42ac6d30ec80e9a70846253dd13e2f067b"}, - {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:5bfde62d1d2641a1f5173b8c8c2d96ceb4854f54a44c23102e2ccc7e02f003ec"}, - {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:51467000f3647d519272392f484126aa716f747859794ac9924a7aafa86cd411"}, - {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:03a6d5349c9ee8f79ab3ff3694d6ce1cfc3ced1c9d36200cb8f08ba06bd3b782"}, - {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:102e487eeb82afac440581e5d7f8f44560b36cf0bdd11abc51a46c1cd88914d4"}, - {file = "aiohttp-3.8.1-cp36-cp36m-win32.whl", hash = "sha256:4aed991a28ea3ce320dc8ce655875e1e00a11bdd29fe9444dd4f88c30d558602"}, - {file = "aiohttp-3.8.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b0e20cddbd676ab8a64c774fefa0ad787cc506afd844de95da56060348021e96"}, - {file = "aiohttp-3.8.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:37951ad2f4a6df6506750a23f7cbabad24c73c65f23f72e95897bb2cecbae676"}, - {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c23b1ad869653bc818e972b7a3a79852d0e494e9ab7e1a701a3decc49c20d51"}, - {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:15b09b06dae900777833fe7fc4b4aa426556ce95847a3e8d7548e2d19e34edb8"}, - {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:477c3ea0ba410b2b56b7efb072c36fa91b1e6fc331761798fa3f28bb224830dd"}, - {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2f2f69dca064926e79997f45b2f34e202b320fd3782f17a91941f7eb85502ee2"}, - {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ef9612483cb35171d51d9173647eed5d0069eaa2ee812793a75373447d487aa4"}, - {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:6d69f36d445c45cda7b3b26afef2fc34ef5ac0cdc75584a87ef307ee3c8c6d00"}, - {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:55c3d1072704d27401c92339144d199d9de7b52627f724a949fc7d5fc56d8b93"}, - {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:b9d00268fcb9f66fbcc7cd9fe423741d90c75ee029a1d15c09b22d23253c0a44"}, - {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:07b05cd3305e8a73112103c834e91cd27ce5b4bd07850c4b4dbd1877d3f45be7"}, - {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c34dc4958b232ef6188c4318cb7b2c2d80521c9a56c52449f8f93ab7bc2a8a1c"}, - {file = "aiohttp-3.8.1-cp37-cp37m-win32.whl", hash = "sha256:d2f9b69293c33aaa53d923032fe227feac867f81682f002ce33ffae978f0a9a9"}, - {file = "aiohttp-3.8.1-cp37-cp37m-win_amd64.whl", hash = "sha256:6ae828d3a003f03ae31915c31fa684b9890ea44c9c989056fea96e3d12a9fa17"}, - {file = "aiohttp-3.8.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:0c7ebbbde809ff4e970824b2b6cb7e4222be6b95a296e46c03cf050878fc1785"}, - {file = "aiohttp-3.8.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8b7ef7cbd4fec9a1e811a5de813311ed4f7ac7d93e0fda233c9b3e1428f7dd7b"}, - {file = "aiohttp-3.8.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c3d6a4d0619e09dcd61021debf7059955c2004fa29f48788a3dfaf9c9901a7cd"}, - {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:718626a174e7e467f0558954f94af117b7d4695d48eb980146016afa4b580b2e"}, - {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:589c72667a5febd36f1315aa6e5f56dd4aa4862df295cb51c769d16142ddd7cd"}, - {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2ed076098b171573161eb146afcb9129b5ff63308960aeca4b676d9d3c35e700"}, - {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:086f92daf51a032d062ec5f58af5ca6a44d082c35299c96376a41cbb33034675"}, - {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:11691cf4dc5b94236ccc609b70fec991234e7ef8d4c02dd0c9668d1e486f5abf"}, - {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:31d1e1c0dbf19ebccbfd62eff461518dcb1e307b195e93bba60c965a4dcf1ba0"}, - {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:11a67c0d562e07067c4e86bffc1553f2cf5b664d6111c894671b2b8712f3aba5"}, - {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:bb01ba6b0d3f6c68b89fce7305080145d4877ad3acaed424bae4d4ee75faa950"}, - {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:44db35a9e15d6fe5c40d74952e803b1d96e964f683b5a78c3cc64eb177878155"}, - {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:844a9b460871ee0a0b0b68a64890dae9c415e513db0f4a7e3cab41a0f2fedf33"}, - {file = "aiohttp-3.8.1-cp38-cp38-win32.whl", hash = "sha256:7d08744e9bae2ca9c382581f7dce1273fe3c9bae94ff572c3626e8da5b193c6a"}, - {file = "aiohttp-3.8.1-cp38-cp38-win_amd64.whl", hash = "sha256:04d48b8ce6ab3cf2097b1855e1505181bdd05586ca275f2505514a6e274e8e75"}, - {file = "aiohttp-3.8.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f5315a2eb0239185af1bddb1abf472d877fede3cc8d143c6cddad37678293237"}, - {file = "aiohttp-3.8.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a996d01ca39b8dfe77440f3cd600825d05841088fd6bc0144cc6c2ec14cc5f74"}, - {file = "aiohttp-3.8.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:13487abd2f761d4be7c8ff9080de2671e53fff69711d46de703c310c4c9317ca"}, - {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea302f34477fda3f85560a06d9ebdc7fa41e82420e892fc50b577e35fc6a50b2"}, - {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a2f635ce61a89c5732537a7896b6319a8fcfa23ba09bec36e1b1ac0ab31270d2"}, - {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e999f2d0e12eea01caeecb17b653f3713d758f6dcc770417cf29ef08d3931421"}, - {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0770e2806a30e744b4e21c9d73b7bee18a1cfa3c47991ee2e5a65b887c49d5cf"}, - {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:d15367ce87c8e9e09b0f989bfd72dc641bcd04ba091c68cd305312d00962addd"}, - {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:6c7cefb4b0640703eb1069835c02486669312bf2f12b48a748e0a7756d0de33d"}, - {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:71927042ed6365a09a98a6377501af5c9f0a4d38083652bcd2281a06a5976724"}, - {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:28d490af82bc6b7ce53ff31337a18a10498303fe66f701ab65ef27e143c3b0ef"}, - {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:b6613280ccedf24354406caf785db748bebbddcf31408b20c0b48cb86af76866"}, - {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:81e3d8c34c623ca4e36c46524a3530e99c0bc95ed068fd6e9b55cb721d408fb2"}, - {file = "aiohttp-3.8.1-cp39-cp39-win32.whl", hash = "sha256:7187a76598bdb895af0adbd2fb7474d7f6025d170bc0a1130242da817ce9e7d1"}, - {file = "aiohttp-3.8.1-cp39-cp39-win_amd64.whl", hash = "sha256:1c182cb873bc91b411e184dab7a2b664d4fea2743df0e4d57402f7f3fa644bac"}, - {file = "aiohttp-3.8.1.tar.gz", hash = "sha256:fc5471e1a54de15ef71c1bc6ebe80d4dc681ea600e68bfd1cbce40427f0b7578"}, + {file = "aiohttp-3.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:48f218a5257b6bc16bcf26a91d97ecea0c7d29c811a90d965f3dd97c20f016d6"}, + {file = "aiohttp-3.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a2fee4d656a7cc9ab47771b2a9e8fad8a9a33331c1b59c3057ecf0ac858f5bfe"}, + {file = "aiohttp-3.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:688a1eb8c1a5f7e795c7cb67e0fe600194e6723ba35f138dfae0db20c0cb8f94"}, + {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ba09bb3dcb0b7ec936a485db2b64be44fe14cdce0a5eac56f50e55da3627385"}, + {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d7715daf84f10bcebc083ad137e3eced3e1c8e7fa1f096ade9a8d02b08f0d91c"}, + {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5e3f81fbbc170418e22918a9585fd7281bbc11d027064d62aa4b507552c92671"}, + {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1fa9f50aa1f114249b7963c98e20dc35c51be64096a85bc92433185f331de9cc"}, + {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8a50150419b741ee048b53146c39c47053f060cb9d98e78be08fdbe942eaa3c4"}, + {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:a84c335337b676d832c1e2bc47c3a97531b46b82de9f959dafb315cbcbe0dfcd"}, + {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:88d4917c30fcd7f6404fb1dc713fa21de59d3063dcc048f4a8a1a90e6bbbd739"}, + {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:b76669b7c058b8020b11008283c3b8e9c61bfd978807c45862956119b77ece45"}, + {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:84fe1732648c1bc303a70faa67cbc2f7f2e810c8a5bca94f6db7818e722e4c0a"}, + {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:730b7c2b7382194d9985ffdc32ab317e893bca21e0665cb1186bdfbb4089d990"}, + {file = "aiohttp-3.8.0-cp310-cp310-win32.whl", hash = "sha256:0a96473a1f61d7920a9099bc8e729dc8282539d25f79c12573ee0fdb9c8b66a8"}, + {file = "aiohttp-3.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:764c7c6aa1f78bd77bd9674fc07d1ec44654da1818d0eef9fb48aa8371a3c847"}, + {file = "aiohttp-3.8.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9951c2696c4357703001e1fe6edc6ae8e97553ac630492ea1bf64b429cb712a3"}, + {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0af379221975054162959e00daf21159ff69a712fc42ed0052caddbd70d52ff4"}, + {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9689af0f0a89e5032426c143fa3683b0451f06c83bf3b1e27902bd33acfae769"}, + {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fe4a327da0c6b6e59f2e474ae79d6ee7745ac3279fd15f200044602fa31e3d79"}, + {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:ecb314e59bedb77188017f26e6b684b1f6d0465e724c3122a726359fa62ca1ba"}, + {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a5399a44a529083951b55521cf4ecbf6ad79fd54b9df57dbf01699ffa0549fc9"}, + {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:09754a0d5eaab66c37591f2f8fac8f9781a5f61d51aa852a3261c4805ca6b984"}, + {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:adf0cb251b1b842c9dee5cfcdf880ba0aae32e841b8d0e6b6feeaef002a267c5"}, + {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:a4759e85a191de58e0ea468ab6fd9c03941986eee436e0518d7a9291fab122c8"}, + {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:28369fe331a59d80393ec82df3d43307c7461bfaf9217999e33e2acc7984ff7c"}, + {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:2f44d1b1c740a9e2275160d77c73a11f61e8a916191c572876baa7b282bcc934"}, + {file = "aiohttp-3.8.0-cp36-cp36m-win32.whl", hash = "sha256:e27cde1e8d17b09730801ce97b6e0c444ba2a1f06348b169fd931b51d3402f0d"}, + {file = "aiohttp-3.8.0-cp36-cp36m-win_amd64.whl", hash = "sha256:15a660d06092b7c92ed17c1dbe6c1eab0a02963992d60e3e8b9d5fa7fa81f01e"}, + {file = "aiohttp-3.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:257f4fad1714d26d562572095c8c5cd271d5a333252795cb7a002dca41fdbad7"}, + {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6074a3b2fa2d0c9bf0963f8dfc85e1e54a26114cc8594126bc52d3fa061c40e"}, + {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7a315ceb813208ef32bdd6ec3a85cbe3cb3be9bbda5fd030c234592fa9116993"}, + {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9a52b141ff3b923a9166595de6e3768a027546e75052ffba267d95b54267f4ab"}, + {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6a038cb1e6e55b26bb5520ccffab7f539b3786f5553af2ee47eb2ec5cbd7084e"}, + {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98b1ea2763b33559dd9ec621d67fc17b583484cb90735bfb0ec3614c17b210e4"}, + {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:9e8723c3256641e141cd18f6ce478d54a004138b9f1a36e41083b36d9ecc5fc5"}, + {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:14a6f026eca80dfa3d52e86be89feb5cd878f6f4a6adb34457e2c689fd85229b"}, + {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:c62d4791a8212c885b97a63ef5f3974b2cd41930f0cd224ada9c6ee6654f8150"}, + {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:90a97c2ed2830e7974cbe45f0838de0aefc1c123313f7c402e21c29ec063fbb4"}, + {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dcc4d5dd5fba3affaf4fd08f00ef156407573de8c63338787614ccc64f96b321"}, + {file = "aiohttp-3.8.0-cp37-cp37m-win32.whl", hash = "sha256:de42f513ed7a997bc821bddab356b72e55e8396b1b7ba1bf39926d538a76a90f"}, + {file = "aiohttp-3.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:7d76e8a83396e06abe3df569b25bd3fc88bf78b7baa2c8e4cf4aaf5983af66a3"}, + {file = "aiohttp-3.8.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5d79174d96446a02664e2bffc95e7b6fa93b9e6d8314536c5840dff130d0878b"}, + {file = "aiohttp-3.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4a6551057a846bf72c7a04f73de3fcaca269c0bd85afe475ceb59d261c6a938c"}, + {file = "aiohttp-3.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:871d4fdc56288caa58b1094c20f2364215f7400411f76783ea19ad13be7c8e19"}, + {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ba08a71caa42eef64357257878fb17f3fba3fba6e81a51d170e32321569e079"}, + {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:51f90dabd9933b1621260b32c2f0d05d36923c7a5a909eb823e429dba0fd2f3e"}, + {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f348ebd20554e8bc26e8ef3ed8a134110c0f4bf015b3b4da6a4ddf34e0515b19"}, + {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d5f8c04574efa814a24510122810e3a3c77c0552f9f6ff65c9862f1f046be2c3"}, + {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:5ecffdc748d3b40dd3618ede0170e4f5e1d3c9647cfb410d235d19e62cb54ee0"}, + {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:577cc2c7b807b174814dac2d02e673728f2e46c7f90ceda3a70ea4bb6d90b769"}, + {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:6b79f6c31e68b6dafc0317ec453c83c86dd8db1f8f0c6f28e97186563fca87a0"}, + {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:2bdd655732e38b40f8a8344d330cfae3c727fb257585df923316aabbd489ccb8"}, + {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:63fa57a0708573d3c059f7b5527617bd0c291e4559298473df238d502e4ab98c"}, + {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d3f90ee275b1d7c942e65b5c44c8fb52d55502a0b9a679837d71be2bd8927661"}, + {file = "aiohttp-3.8.0-cp38-cp38-win32.whl", hash = "sha256:fa818609357dde5c4a94a64c097c6404ad996b1d38ca977a72834b682830a722"}, + {file = "aiohttp-3.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:097ecf52f6b9859b025c1e36401f8aa4573552e887d1b91b4b999d68d0b5a3b3"}, + {file = "aiohttp-3.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:be03a7483ad9ea60388f930160bb3728467dd0af538aa5edc60962ee700a0bdc"}, + {file = "aiohttp-3.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:78d51e35ed163783d721b6f2ce8ce3f82fccfe471e8e50a10fba13a766d31f5a"}, + {file = "aiohttp-3.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:bda75d73e7400e81077b0910c9a60bf9771f715420d7e35fa7739ae95555f195"}, + {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:707adc30ea6918fba725c3cb3fe782d271ba352b22d7ae54a7f9f2e8a8488c41"}, + {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3f58aa995b905ab82fe228acd38538e7dc1509e01508dcf307dad5046399130f"}, + {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c996eb91bfbdab1e01e2c02e7ff678c51e2b28e3a04e26e41691991cc55795"}, + {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d6a1a66bb8bac9bc2892c2674ea363486bfb748b86504966a390345a11b1680e"}, + {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:dafc01a32b4a1d7d3ef8bfd3699406bb44f7b2e0d3eb8906d574846e1019b12f"}, + {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:949a605ef3907254b122f845baa0920407080cdb1f73aa64f8d47df4a7f4c4f9"}, + {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:0d7b056fd3972d353cb4bc305c03f9381583766b7f8c7f1c44478dba69099e33"}, + {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:6f1d39a744101bf4043fa0926b3ead616607578192d0a169974fb5265ab1e9d2"}, + {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:67ca7032dfac8d001023fadafc812d9f48bf8a8c3bb15412d9cdcf92267593f4"}, + {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:cb751ef712570d3bda9a73fd765ff3e1aba943ec5d52a54a0c2e89c7eef9da1e"}, + {file = "aiohttp-3.8.0-cp39-cp39-win32.whl", hash = "sha256:6d3e027fe291b77f6be9630114a0200b2c52004ef20b94dc50ca59849cd623b3"}, + {file = "aiohttp-3.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:3c5e9981e449d54308c6824f172ec8ab63eb9c5f922920970249efee83f7e919"}, + {file = "aiohttp-3.8.0.tar.gz", hash = "sha256:d3b19d8d183bcfd68b25beebab8dc3308282fe2ca3d6ea3cb4cd101b3c279f8d"}, ] aiokafka = [ {file = "aiokafka-0.7.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b19f077e12fe23e359f7a7dca9baf8532c63f4c8149703ce4c56de372d17e26c"}, @@ -1646,32 +1646,42 @@ pre-commit = [ {file = "pre_commit-2.15.0.tar.gz", hash = "sha256:3c25add78dbdfb6a28a651780d5c311ac40dd17f160eb3954a0c59da40a505a7"}, ] psycopg2-binary = [ - {file = "psycopg2-binary-2.9.2.tar.gz", hash = "sha256:234b1f48488b2f86aac04fb00cb04e5e9bcb960f34fa8a8e41b73149d581a93b"}, - {file = "psycopg2_binary-2.9.2-cp310-cp310-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:c0e1fb7097ded2cc44d9037cfc68ad86a30341261492e7de95d180e534969fb2"}, - {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:717525cdc97b23182ff6f470fb5bf6f0bc796b5a7000c6f6699d6679991e4a5e"}, - {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3865d0cd919349c45603bd7e80249a382c5ecf8106304cfd153282adf9684b6a"}, - {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:daf6b5c62eb738872d61a1fa740d7768904911ba5a7e055ed72169d379b58beb"}, - {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_24_ppc64le.whl", hash = "sha256:3ac83656ff4fbe7f2a956ab085e3eb1d678df54759965d509bdd6a06ce520d49"}, - {file = "psycopg2_binary-2.9.2-cp36-cp36m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:53912199abb626a7249c662e72b70b4f57bf37f840599cec68625171435790dd"}, - {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:029e09a892b9ebc3c77851f69ce0720e1b72a9c6850460cee49b14dfbf9ccdd2"}, - {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db1b03c189f85b8df29030ad32d521dd7dcb862fd5f8892035314f5b886e70ce"}, - {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_24_aarch64.whl", hash = "sha256:2eecbdc5fa5886f2dd6cc673ce4291cc0fb8900965315268960ad9c2477f8276"}, - {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_24_ppc64le.whl", hash = "sha256:a77e98c68b0e6c51d4d6a994d22b30e77276cbd33e4aabdde03b9ad3a2c148aa"}, - {file = "psycopg2_binary-2.9.2-cp37-cp37m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:a507db7758953b1b170c4310691a1a89877029b1e11b08ba5fc8ae3ddb35596b"}, - {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2e4bbcfb403221ea1953f3e0a85cef00ed15c1683a66cf35c956a7e37c33a4c4"}, - {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f4dff0f15af6936c6fe6da7067b4216edbbe076ad8625da819cc066591b1133c"}, - {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_24_aarch64.whl", hash = "sha256:8d2aafe46eb87742425ece38130510fbb035787ee89a329af299029c4d9ae318"}, - {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_24_ppc64le.whl", hash = "sha256:37c8f00f7a2860bac9f7a54f03c243fc1dd9b367e5b2b52f5a02e5f4e9d8c49b"}, - {file = "psycopg2_binary-2.9.2-cp38-cp38-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:eeee7b18c51d02e49bf1984d7af26e8843fe68e31fa1cbab5366ebdfa1c89ade"}, - {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:497372cc76e6cbce2f51b37be141f360a321423c03eb9be45524b1d123f4cd11"}, - {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5671699aff57d22a245b7f4bba89e3de97dc841c5e98bd7f685429b2b20eca47"}, - {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_24_aarch64.whl", hash = "sha256:b9d45374ba98c1184df9cce93a0b766097544f8bdfcd5de83ff10f939c193125"}, - {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_24_ppc64le.whl", hash = "sha256:a1852c5bef7e5f52bd43fde5eda610d4df0fb2efc31028150933e84b4140d47a"}, - {file = "psycopg2_binary-2.9.2-cp39-cp39-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:578c279cd1ce04f05ae0912530ece00bab92854911808e5aec27588aba87e361"}, - {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c2dea4deac3dd3687e32daeb0712ee96c535970dfdded37a11de6a21145ab0e"}, - {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b592f09ff18cfcc9037b9a976fcd62db48cae9dbd5385f2471d4c2ba40c52b4d"}, - {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:3a320e7a804f3886a599fea507364aaafbb8387027fffcdfbd34d96316c806c7"}, - {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_24_ppc64le.whl", hash = "sha256:7585ca73dcfe326f31fafa8f96e6bb98ea9e9e46c7a1924ec8101d797914ae27"}, + {file = "psycopg2-binary-2.9.1.tar.gz", hash = "sha256:b0221ca5a9837e040ebf61f48899926b5783668b7807419e4adae8175a31f773"}, + {file = "psycopg2_binary-2.9.1-cp310-cp310-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:24b0b6688b9f31a911f2361fe818492650795c9e5d3a1bc647acbd7440142a4f"}, + {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:542875f62bc56e91c6eac05a0deadeae20e1730be4c6334d8f04c944fcd99759"}, + {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:661509f51531ec125e52357a489ea3806640d0ca37d9dada461ffc69ee1e7b6e"}, + {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:d92272c7c16e105788efe2cfa5d680f07e34e0c29b03c1908f8636f55d5f915a"}, + {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_24_ppc64le.whl", hash = "sha256:736b8797b58febabb85494142c627bd182b50d2a7ec65322983e71065ad3034c"}, + {file = "psycopg2_binary-2.9.1-cp310-cp310-win32.whl", hash = "sha256:ebccf1123e7ef66efc615a68295bf6fdba875a75d5bba10a05073202598085fc"}, + {file = "psycopg2_binary-2.9.1-cp310-cp310-win_amd64.whl", hash = "sha256:1f6ca4a9068f5c5c57e744b4baa79f40e83e3746875cac3c45467b16326bab45"}, + {file = "psycopg2_binary-2.9.1-cp36-cp36m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:c250a7ec489b652c892e4f0a5d122cc14c3780f9f643e1a326754aedf82d9a76"}, + {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aef9aee84ec78af51107181d02fe8773b100b01c5dfde351184ad9223eab3698"}, + {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:123c3fb684e9abfc47218d3784c7b4c47c8587951ea4dd5bc38b6636ac57f616"}, + {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_24_aarch64.whl", hash = "sha256:995fc41ebda5a7a663a254a1dcac52638c3e847f48307b5416ee373da15075d7"}, + {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_24_ppc64le.whl", hash = "sha256:fbb42a541b1093385a2d8c7eec94d26d30437d0e77c1d25dae1dcc46741a385e"}, + {file = "psycopg2_binary-2.9.1-cp36-cp36m-win32.whl", hash = "sha256:20f1ab44d8c352074e2d7ca67dc00843067788791be373e67a0911998787ce7d"}, + {file = "psycopg2_binary-2.9.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f6fac64a38f6768e7bc7b035b9e10d8a538a9fadce06b983fb3e6fa55ac5f5ce"}, + {file = "psycopg2_binary-2.9.1-cp37-cp37m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:1e3a362790edc0a365385b1ac4cc0acc429a0c0d662d829a50b6ce743ae61b5a"}, + {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f8559617b1fcf59a9aedba2c9838b5b6aa211ffedecabca412b92a1ff75aac1a"}, + {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a36c7eb6152ba5467fb264d73844877be8b0847874d4822b7cf2d3c0cb8cdcb0"}, + {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_24_aarch64.whl", hash = "sha256:2f62c207d1740b0bde5c4e949f857b044818f734a3d57f1d0d0edc65050532ed"}, + {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_24_ppc64le.whl", hash = "sha256:cfc523edecddaef56f6740d7de1ce24a2fdf94fd5e704091856a201872e37f9f"}, + {file = "psycopg2_binary-2.9.1-cp37-cp37m-win32.whl", hash = "sha256:1e85b74cbbb3056e3656f1cc4781294df03383127a8114cbc6531e8b8367bf1e"}, + {file = "psycopg2_binary-2.9.1-cp37-cp37m-win_amd64.whl", hash = "sha256:1473c0215b0613dd938db54a653f68251a45a78b05f6fc21af4326f40e8360a2"}, + {file = "psycopg2_binary-2.9.1-cp38-cp38-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:35c4310f8febe41f442d3c65066ca93cccefd75013df3d8c736c5b93ec288140"}, + {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8c13d72ed6af7fd2c8acbd95661cf9477f94e381fce0792c04981a8283b52917"}, + {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14db1752acdd2187d99cb2ca0a1a6dfe57fc65c3281e0f20e597aac8d2a5bd90"}, + {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_24_aarch64.whl", hash = "sha256:aed4a9a7e3221b3e252c39d0bf794c438dc5453bc2963e8befe9d4cd324dff72"}, + {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_24_ppc64le.whl", hash = "sha256:da113b70f6ec40e7d81b43d1b139b9db6a05727ab8be1ee559f3a69854a69d34"}, + {file = "psycopg2_binary-2.9.1-cp38-cp38-win32.whl", hash = "sha256:4235f9d5ddcab0b8dbd723dca56ea2922b485ea00e1dafacf33b0c7e840b3d32"}, + {file = "psycopg2_binary-2.9.1-cp38-cp38-win_amd64.whl", hash = "sha256:988b47ac70d204aed01589ed342303da7c4d84b56c2f4c4b8b00deda123372bf"}, + {file = "psycopg2_binary-2.9.1-cp39-cp39-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:7360647ea04db2e7dff1648d1da825c8cf68dc5fbd80b8fb5b3ee9f068dcd21a"}, + {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca86db5b561b894f9e5f115d6a159fff2a2570a652e07889d8a383b5fae66eb4"}, + {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ced67f1e34e1a450cdb48eb53ca73b60aa0af21c46b9b35ac3e581cf9f00e31"}, + {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:0f2e04bd2a2ab54fa44ee67fe2d002bb90cee1c0f1cc0ebc3148af7b02034cbd"}, + {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_24_ppc64le.whl", hash = "sha256:3242b9619de955ab44581a03a64bdd7d5e470cc4183e8fcadd85ab9d3756ce7a"}, + {file = "psycopg2_binary-2.9.1-cp39-cp39-win32.whl", hash = "sha256:0b7dae87f0b729922e06f85f667de7bf16455d411971b2043bbd9577af9d1975"}, + {file = "psycopg2_binary-2.9.1-cp39-cp39-win_amd64.whl", hash = "sha256:b4d7679a08fea64573c969f6994a2631908bb2c0e69a7235648642f3d2e39a68"}, ] py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, @@ -1844,28 +1854,41 @@ toml = [ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] typed-ast = [ - {file = "typed_ast-1.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7b310a207ee9fde3f46ba327989e6cba4195bc0c8c70a158456e7b10233e6bed"}, - {file = "typed_ast-1.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:52ca2b2b524d770bed7a393371a38e91943f9160a190141e0df911586066ecda"}, - {file = "typed_ast-1.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:14fed8820114a389a2b7e91624db5f85f3f6682fda09fe0268a59aabd28fe5f5"}, - {file = "typed_ast-1.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:65c81abbabda7d760df7304d843cc9dbe7ef5d485504ca59a46ae2d1731d2428"}, - {file = "typed_ast-1.5.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:37ba2ab65a0028b1a4f2b61a8fe77f12d242731977d274a03d68ebb751271508"}, - {file = "typed_ast-1.5.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:49af5b8f6f03ed1eb89ee06c1d7c2e7c8e743d720c3746a5857609a1abc94c94"}, - {file = "typed_ast-1.5.0-cp36-cp36m-win_amd64.whl", hash = "sha256:e4374a76e61399a173137e7984a1d7e356038cf844f24fd8aea46c8029a2f712"}, - {file = "typed_ast-1.5.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:ea517c2bb11c5e4ba7a83a91482a2837041181d57d3ed0749a6c382a2b6b7086"}, - {file = "typed_ast-1.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:51040bf45aacefa44fa67fb9ebcd1f2bec73182b99a532c2394eea7dabd18e24"}, - {file = "typed_ast-1.5.0-cp37-cp37m-win_amd64.whl", hash = "sha256:806e0c7346b9b4af8c62d9a29053f484599921a4448c37fbbcbbf15c25138570"}, - {file = "typed_ast-1.5.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a67fd5914603e2165e075f1b12f5a8356bfb9557e8bfb74511108cfbab0f51ed"}, - {file = "typed_ast-1.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:224afecb8b39739f5c9562794a7c98325cb9d972712e1a98b6989a4720219541"}, - {file = "typed_ast-1.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:155b74b078be842d2eb630dd30a280025eca0a5383c7d45853c27afee65f278f"}, - {file = "typed_ast-1.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:361b9e5d27bd8e3ccb6ea6ad6c4f3c0be322a1a0f8177db6d56264fa0ae40410"}, - {file = "typed_ast-1.5.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:618912cbc7e17b4aeba86ffe071698c6e2d292acbd6d1d5ec1ee724b8c4ae450"}, - {file = "typed_ast-1.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7e6731044f748340ef68dcadb5172a4b1f40847a2983fe3983b2a66445fbc8e6"}, - {file = "typed_ast-1.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e8a9b9c87801cecaad3b4c2b8876387115d1a14caa602c1618cedbb0cb2a14e6"}, - {file = "typed_ast-1.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:ec184dfb5d3d11e82841dbb973e7092b75f306b625fad7b2e665b64c5d60ab3f"}, - {file = "typed_ast-1.5.0.tar.gz", hash = "sha256:ff4ad88271aa7a55f19b6a161ed44e088c393846d954729549e3cde8257747bb"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, + {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, + {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, + {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, + {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, + {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, + {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, + {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, + {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, + {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, ] typing-extensions = [ - {file = "typing_extensions-4.0.0-py3-none-any.whl", hash = "sha256:829704698b22e13ec9eaf959122315eabb370b0884400e9818334d8b677023d9"}, + {file = "typing_extensions-3.10.0.2-py2-none-any.whl", hash = "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7"}, + {file = "typing_extensions-3.10.0.2-py3-none-any.whl", hash = "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34"}, + {file = "typing_extensions-3.10.0.2.tar.gz", hash = "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"}, ] urllib3 = [ {file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"}, diff --git a/pyproject.toml b/pyproject.toml index e0997750..e49c2845 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ aiomisc = "^14.0.3" aiopg = "^1.2.1" aiohttp = "^3.7.4" dependency-injector = "^4.32.2" -minos-microservice-common = { path = "../minos_microservice_common", develop = true } +minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-651-remove-command-commandreply-event" } minos-microservice-aggregate = "^0.1.0" crontab = "^0.23.0" diff --git a/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py index 606a594a..35348098 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_abc/test_handlers.py @@ -73,8 +73,7 @@ def setUp(self) -> None: super().setUp() handlers = self.handlers() handlers["empty"] = None - middleware = list() - self.handler = _FakeHandler(handlers=handlers, middleware=middleware, **self.config.broker.queue._asdict()) + self.handler = _FakeHandler(handlers=handlers, **self.config.broker.queue._asdict()) async def test_get_action(self): action = self.handler.get_action(topic="AddOrder") @@ -117,7 +116,7 @@ async def test_dispatch_forever_without_notify(self): self.assertEqual(3, mock_count.call_count) async def test_dispatch_forever_without_topics(self): - handler = _FakeHandler(handlers=dict(), middleware=list(), **self.config.broker.queue._asdict()) + handler = _FakeHandler(handlers=dict(), **self.config.broker.queue._asdict()) mock = AsyncMock() async with handler: handler.dispatch = mock From a591270ddb6be26328ec4984d69b1d69263cefc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 09:30:24 +0100 Subject: [PATCH 16/24] ISSUE #441 * Add support for `middleware` on handling functions (2). --- .../brokers/subscribers/commands/handlers.py | 2 +- .../brokers/subscribers/events/handlers.py | 2 +- minos/networks/decorators/builders.py | 15 ++++++++++++--- minos/networks/rest/handlers.py | 2 +- minos/networks/scheduling/schedulers.py | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/minos/networks/brokers/subscribers/commands/handlers.py b/minos/networks/brokers/subscribers/commands/handlers.py index 1e7e8042..3df40f93 100644 --- a/minos/networks/brokers/subscribers/commands/handlers.py +++ b/minos/networks/brokers/subscribers/commands/handlers.py @@ -68,7 +68,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandHandler: @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: - builder = EnrouteBuilder(*config.services) + builder = EnrouteBuilder(*config.services, middleware=config.middleware) decorators = builder.get_broker_command_query(config=config, **kwargs) handlers = {decorator.topic: fn for decorator, fn in decorators.items()} return handlers diff --git a/minos/networks/brokers/subscribers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py index 94d7a07e..2f83deb4 100644 --- a/minos/networks/brokers/subscribers/events/handlers.py +++ b/minos/networks/brokers/subscribers/events/handlers.py @@ -61,7 +61,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventHandler: @staticmethod def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[HandlerRequest], Awaitable]]: - builder = EnrouteBuilder(*config.services) + builder = EnrouteBuilder(*config.services, middleware=config.middleware) handlers = builder.get_broker_event(config=config, **kwargs) handlers = {decorator.topic: fn for decorator, fn in handlers.items()} return handlers diff --git a/minos/networks/decorators/builders.py b/minos/networks/decorators/builders.py index afcb88c7..c2b39869 100644 --- a/minos/networks/decorators/builders.py +++ b/minos/networks/decorators/builders.py @@ -4,6 +4,7 @@ from collections import ( defaultdict, ) +from functools import partial from inspect import ( isawaitable, ) @@ -43,10 +44,16 @@ class EnrouteBuilder: """Enroute builder class.""" - def __init__(self, *classes: Union[str, Type]): + def __init__(self, *classes: Union[str, Type], middleware: Optional[list[Union[str, Callable]]] = None): + if middleware is None: + middleware = list() + + middleware = list(map(lambda fn: fn if not isinstance(fn, str) else import_module(fn), middleware)) + classes = tuple((class_ if not isinstance(class_, str) else import_module(class_)) for class_ in classes) self.classes = classes + self.middleware = middleware def get_rest_command_query(self, **kwargs) -> dict[RestEnrouteDecorator, Handler]: """Get the rest handlers for commands and queries. @@ -114,8 +121,7 @@ def _build_one_class( for decorator in decorators: ans[decorator].add(self._build_one_method(class_, name, decorator.pre_fn_name, decorator.post_fn_name)) - @staticmethod - def _build_one_method(class_: type, name: str, pref_fn_name: str, post_fn_name: str, **kwargs) -> Handler: + def _build_one_method(self, class_: type, name: str, pref_fn_name: str, post_fn_name: str, **kwargs) -> Handler: instance = class_(**kwargs) fn = getattr(instance, name) pre_fn = getattr(instance, pref_fn_name, None) @@ -138,4 +144,7 @@ async def _wrapped_fn(request: Request) -> Optional[Response]: return response + for middleware_fn in reversed(self.middleware): + _wrapped_fn = partial(middleware_fn, inner=_wrapped_fn) + return _wrapped_fn diff --git a/minos/networks/rest/handlers.py b/minos/networks/rest/handlers.py index e9bb1173..3a467b3c 100644 --- a/minos/networks/rest/handlers.py +++ b/minos/networks/rest/handlers.py @@ -68,7 +68,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> RestHandler: @staticmethod def _endpoints_from_config(config: MinosConfig, **kwargs) -> dict[(str, str), Callable]: - builder = EnrouteBuilder(*config.services) + builder = EnrouteBuilder(*config.services, middleware=config.middleware) decorators = builder.get_rest_command_query(config=config, **kwargs) endpoints = {(decorator.url, decorator.method): fn for decorator, fn in decorators.items()} return endpoints diff --git a/minos/networks/scheduling/schedulers.py b/minos/networks/scheduling/schedulers.py index 82448695..4383c9cd 100644 --- a/minos/networks/scheduling/schedulers.py +++ b/minos/networks/scheduling/schedulers.py @@ -58,7 +58,7 @@ def _from_config(cls, config: MinosConfig, **kwargs) -> PeriodicTaskScheduler: @staticmethod def _tasks_from_config(config: MinosConfig, **kwargs) -> set[PeriodicTask]: - builder = EnrouteBuilder(*config.services) + builder = EnrouteBuilder(*config.services, middleware=config.middleware) decorators = builder.get_periodic_event(config=config, **kwargs) tasks = {PeriodicTask(decorator.crontab, fn) for decorator, fn in decorators.items()} return tasks From c23398d575810fa51f8436ea5273761fa0bd27a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 09:33:53 +0100 Subject: [PATCH 17/24] ISSUE #441 * Add support for `middleware` on handling functions (2). --- minos/networks/decorators/builders.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/minos/networks/decorators/builders.py b/minos/networks/decorators/builders.py index c2b39869..4d7d7e6e 100644 --- a/minos/networks/decorators/builders.py +++ b/minos/networks/decorators/builders.py @@ -4,7 +4,9 @@ from collections import ( defaultdict, ) -from functools import partial +from functools import ( + partial, +) from inspect import ( isawaitable, ) From 101b2ac781713d9c2ef6cdbc303743f471063bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 09:42:49 +0100 Subject: [PATCH 18/24] ISSUE #441 * Update `poetry.lock` --- poetry.lock | 275 ++++++++++++++++++++++++---------------------------- 1 file changed, 126 insertions(+), 149 deletions(-) diff --git a/poetry.lock b/poetry.lock index 836ce41a..ecf9332f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,6 +1,6 @@ [[package]] name = "aiohttp" -version = "3.8.0" +version = "3.8.1" description = "Async http client/server framework (asyncio)" category = "main" optional = false @@ -496,7 +496,7 @@ PyYAML = "^5.4.1" type = "git" url = "https://github.com/Clariteia/minos_microservice_common.git" reference = "issue-651-remove-command-commandreply-event" -resolved_reference = "87e944e0b14f65ddd881464233e9e85e3017108a" +resolved_reference = "78996b750b19fac968d6ea85e865f1620adab278" [[package]] name = "mistune" @@ -599,7 +599,7 @@ virtualenv = ">=20.0.8" [[package]] name = "psycopg2-binary" -version = "2.9.1" +version = "2.9.2" description = "psycopg2 - Python-PostgreSQL Database Adapter" category = "main" optional = false @@ -886,19 +886,19 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "typed-ast" -version = "1.4.3" +version = "1.5.0" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.6" [[package]] name = "typing-extensions" -version = "3.10.0.2" -description = "Backported and Experimental Type Hints for Python 3.5+" +version = "4.0.0" +description = "Backported and Experimental Type Hints for Python 3.6+" category = "main" optional = false -python-versions = "*" +python-versions = ">=3.6" [[package]] name = "urllib3" @@ -951,78 +951,78 @@ content-hash = "894386b0f0dfe216edca09cb51175e136d4742ac92629c6f3fd2e5fb21dcc2ca [metadata.files] aiohttp = [ - {file = "aiohttp-3.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:48f218a5257b6bc16bcf26a91d97ecea0c7d29c811a90d965f3dd97c20f016d6"}, - {file = "aiohttp-3.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a2fee4d656a7cc9ab47771b2a9e8fad8a9a33331c1b59c3057ecf0ac858f5bfe"}, - {file = "aiohttp-3.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:688a1eb8c1a5f7e795c7cb67e0fe600194e6723ba35f138dfae0db20c0cb8f94"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ba09bb3dcb0b7ec936a485db2b64be44fe14cdce0a5eac56f50e55da3627385"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d7715daf84f10bcebc083ad137e3eced3e1c8e7fa1f096ade9a8d02b08f0d91c"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5e3f81fbbc170418e22918a9585fd7281bbc11d027064d62aa4b507552c92671"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1fa9f50aa1f114249b7963c98e20dc35c51be64096a85bc92433185f331de9cc"}, - {file = "aiohttp-3.8.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8a50150419b741ee048b53146c39c47053f060cb9d98e78be08fdbe942eaa3c4"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:a84c335337b676d832c1e2bc47c3a97531b46b82de9f959dafb315cbcbe0dfcd"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:88d4917c30fcd7f6404fb1dc713fa21de59d3063dcc048f4a8a1a90e6bbbd739"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:b76669b7c058b8020b11008283c3b8e9c61bfd978807c45862956119b77ece45"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:84fe1732648c1bc303a70faa67cbc2f7f2e810c8a5bca94f6db7818e722e4c0a"}, - {file = "aiohttp-3.8.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:730b7c2b7382194d9985ffdc32ab317e893bca21e0665cb1186bdfbb4089d990"}, - {file = "aiohttp-3.8.0-cp310-cp310-win32.whl", hash = "sha256:0a96473a1f61d7920a9099bc8e729dc8282539d25f79c12573ee0fdb9c8b66a8"}, - {file = "aiohttp-3.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:764c7c6aa1f78bd77bd9674fc07d1ec44654da1818d0eef9fb48aa8371a3c847"}, - {file = "aiohttp-3.8.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9951c2696c4357703001e1fe6edc6ae8e97553ac630492ea1bf64b429cb712a3"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0af379221975054162959e00daf21159ff69a712fc42ed0052caddbd70d52ff4"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9689af0f0a89e5032426c143fa3683b0451f06c83bf3b1e27902bd33acfae769"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fe4a327da0c6b6e59f2e474ae79d6ee7745ac3279fd15f200044602fa31e3d79"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:ecb314e59bedb77188017f26e6b684b1f6d0465e724c3122a726359fa62ca1ba"}, - {file = "aiohttp-3.8.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a5399a44a529083951b55521cf4ecbf6ad79fd54b9df57dbf01699ffa0549fc9"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:09754a0d5eaab66c37591f2f8fac8f9781a5f61d51aa852a3261c4805ca6b984"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:adf0cb251b1b842c9dee5cfcdf880ba0aae32e841b8d0e6b6feeaef002a267c5"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:a4759e85a191de58e0ea468ab6fd9c03941986eee436e0518d7a9291fab122c8"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:28369fe331a59d80393ec82df3d43307c7461bfaf9217999e33e2acc7984ff7c"}, - {file = "aiohttp-3.8.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:2f44d1b1c740a9e2275160d77c73a11f61e8a916191c572876baa7b282bcc934"}, - {file = "aiohttp-3.8.0-cp36-cp36m-win32.whl", hash = "sha256:e27cde1e8d17b09730801ce97b6e0c444ba2a1f06348b169fd931b51d3402f0d"}, - {file = "aiohttp-3.8.0-cp36-cp36m-win_amd64.whl", hash = "sha256:15a660d06092b7c92ed17c1dbe6c1eab0a02963992d60e3e8b9d5fa7fa81f01e"}, - {file = "aiohttp-3.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:257f4fad1714d26d562572095c8c5cd271d5a333252795cb7a002dca41fdbad7"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6074a3b2fa2d0c9bf0963f8dfc85e1e54a26114cc8594126bc52d3fa061c40e"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7a315ceb813208ef32bdd6ec3a85cbe3cb3be9bbda5fd030c234592fa9116993"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9a52b141ff3b923a9166595de6e3768a027546e75052ffba267d95b54267f4ab"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6a038cb1e6e55b26bb5520ccffab7f539b3786f5553af2ee47eb2ec5cbd7084e"}, - {file = "aiohttp-3.8.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98b1ea2763b33559dd9ec621d67fc17b583484cb90735bfb0ec3614c17b210e4"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:9e8723c3256641e141cd18f6ce478d54a004138b9f1a36e41083b36d9ecc5fc5"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:14a6f026eca80dfa3d52e86be89feb5cd878f6f4a6adb34457e2c689fd85229b"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:c62d4791a8212c885b97a63ef5f3974b2cd41930f0cd224ada9c6ee6654f8150"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:90a97c2ed2830e7974cbe45f0838de0aefc1c123313f7c402e21c29ec063fbb4"}, - {file = "aiohttp-3.8.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dcc4d5dd5fba3affaf4fd08f00ef156407573de8c63338787614ccc64f96b321"}, - {file = "aiohttp-3.8.0-cp37-cp37m-win32.whl", hash = "sha256:de42f513ed7a997bc821bddab356b72e55e8396b1b7ba1bf39926d538a76a90f"}, - {file = "aiohttp-3.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:7d76e8a83396e06abe3df569b25bd3fc88bf78b7baa2c8e4cf4aaf5983af66a3"}, - {file = "aiohttp-3.8.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5d79174d96446a02664e2bffc95e7b6fa93b9e6d8314536c5840dff130d0878b"}, - {file = "aiohttp-3.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4a6551057a846bf72c7a04f73de3fcaca269c0bd85afe475ceb59d261c6a938c"}, - {file = "aiohttp-3.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:871d4fdc56288caa58b1094c20f2364215f7400411f76783ea19ad13be7c8e19"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ba08a71caa42eef64357257878fb17f3fba3fba6e81a51d170e32321569e079"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:51f90dabd9933b1621260b32c2f0d05d36923c7a5a909eb823e429dba0fd2f3e"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f348ebd20554e8bc26e8ef3ed8a134110c0f4bf015b3b4da6a4ddf34e0515b19"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d5f8c04574efa814a24510122810e3a3c77c0552f9f6ff65c9862f1f046be2c3"}, - {file = "aiohttp-3.8.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:5ecffdc748d3b40dd3618ede0170e4f5e1d3c9647cfb410d235d19e62cb54ee0"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:577cc2c7b807b174814dac2d02e673728f2e46c7f90ceda3a70ea4bb6d90b769"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:6b79f6c31e68b6dafc0317ec453c83c86dd8db1f8f0c6f28e97186563fca87a0"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:2bdd655732e38b40f8a8344d330cfae3c727fb257585df923316aabbd489ccb8"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:63fa57a0708573d3c059f7b5527617bd0c291e4559298473df238d502e4ab98c"}, - {file = "aiohttp-3.8.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d3f90ee275b1d7c942e65b5c44c8fb52d55502a0b9a679837d71be2bd8927661"}, - {file = "aiohttp-3.8.0-cp38-cp38-win32.whl", hash = "sha256:fa818609357dde5c4a94a64c097c6404ad996b1d38ca977a72834b682830a722"}, - {file = "aiohttp-3.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:097ecf52f6b9859b025c1e36401f8aa4573552e887d1b91b4b999d68d0b5a3b3"}, - {file = "aiohttp-3.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:be03a7483ad9ea60388f930160bb3728467dd0af538aa5edc60962ee700a0bdc"}, - {file = "aiohttp-3.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:78d51e35ed163783d721b6f2ce8ce3f82fccfe471e8e50a10fba13a766d31f5a"}, - {file = "aiohttp-3.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:bda75d73e7400e81077b0910c9a60bf9771f715420d7e35fa7739ae95555f195"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:707adc30ea6918fba725c3cb3fe782d271ba352b22d7ae54a7f9f2e8a8488c41"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3f58aa995b905ab82fe228acd38538e7dc1509e01508dcf307dad5046399130f"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c996eb91bfbdab1e01e2c02e7ff678c51e2b28e3a04e26e41691991cc55795"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d6a1a66bb8bac9bc2892c2674ea363486bfb748b86504966a390345a11b1680e"}, - {file = "aiohttp-3.8.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:dafc01a32b4a1d7d3ef8bfd3699406bb44f7b2e0d3eb8906d574846e1019b12f"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:949a605ef3907254b122f845baa0920407080cdb1f73aa64f8d47df4a7f4c4f9"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:0d7b056fd3972d353cb4bc305c03f9381583766b7f8c7f1c44478dba69099e33"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:6f1d39a744101bf4043fa0926b3ead616607578192d0a169974fb5265ab1e9d2"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:67ca7032dfac8d001023fadafc812d9f48bf8a8c3bb15412d9cdcf92267593f4"}, - {file = "aiohttp-3.8.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:cb751ef712570d3bda9a73fd765ff3e1aba943ec5d52a54a0c2e89c7eef9da1e"}, - {file = "aiohttp-3.8.0-cp39-cp39-win32.whl", hash = "sha256:6d3e027fe291b77f6be9630114a0200b2c52004ef20b94dc50ca59849cd623b3"}, - {file = "aiohttp-3.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:3c5e9981e449d54308c6824f172ec8ab63eb9c5f922920970249efee83f7e919"}, - {file = "aiohttp-3.8.0.tar.gz", hash = "sha256:d3b19d8d183bcfd68b25beebab8dc3308282fe2ca3d6ea3cb4cd101b3c279f8d"}, + {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1ed0b6477896559f17b9eaeb6d38e07f7f9ffe40b9f0f9627ae8b9926ae260a8"}, + {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7dadf3c307b31e0e61689cbf9e06be7a867c563d5a63ce9dca578f956609abf8"}, + {file = "aiohttp-3.8.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a79004bb58748f31ae1cbe9fa891054baaa46fb106c2dc7af9f8e3304dc30316"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:12de6add4038df8f72fac606dff775791a60f113a725c960f2bab01d8b8e6b15"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6f0d5f33feb5f69ddd57a4a4bd3d56c719a141080b445cbf18f238973c5c9923"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:eaba923151d9deea315be1f3e2b31cc39a6d1d2f682f942905951f4e40200922"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:099ebd2c37ac74cce10a3527d2b49af80243e2a4fa39e7bce41617fbc35fa3c1"}, + {file = "aiohttp-3.8.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2e5d962cf7e1d426aa0e528a7e198658cdc8aa4fe87f781d039ad75dcd52c516"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:fa0ffcace9b3aa34d205d8130f7873fcfefcb6a4dd3dd705b0dab69af6712642"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:61bfc23df345d8c9716d03717c2ed5e27374e0fe6f659ea64edcd27b4b044cf7"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:31560d268ff62143e92423ef183680b9829b1b482c011713ae941997921eebc8"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:01d7bdb774a9acc838e6b8f1d114f45303841b89b95984cbb7d80ea41172a9e3"}, + {file = "aiohttp-3.8.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:97ef77eb6b044134c0b3a96e16abcb05ecce892965a2124c566af0fd60f717e2"}, + {file = "aiohttp-3.8.1-cp310-cp310-win32.whl", hash = "sha256:c2aef4703f1f2ddc6df17519885dbfa3514929149d3ff900b73f45998f2532fa"}, + {file = "aiohttp-3.8.1-cp310-cp310-win_amd64.whl", hash = "sha256:713ac174a629d39b7c6a3aa757b337599798da4c1157114a314e4e391cd28e32"}, + {file = "aiohttp-3.8.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:473d93d4450880fe278696549f2e7aed8cd23708c3c1997981464475f32137db"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99b5eeae8e019e7aad8af8bb314fb908dd2e028b3cdaad87ec05095394cce632"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3af642b43ce56c24d063325dd2cf20ee012d2b9ba4c3c008755a301aaea720ad"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3630c3ef435c0a7c549ba170a0633a56e92629aeed0e707fec832dee313fb7a"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:4a4a4e30bf1edcad13fb0804300557aedd07a92cabc74382fdd0ba6ca2661091"}, + {file = "aiohttp-3.8.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6f8b01295e26c68b3a1b90efb7a89029110d3a4139270b24fda961893216c440"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:a25fa703a527158aaf10dafd956f7d42ac6d30ec80e9a70846253dd13e2f067b"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:5bfde62d1d2641a1f5173b8c8c2d96ceb4854f54a44c23102e2ccc7e02f003ec"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:51467000f3647d519272392f484126aa716f747859794ac9924a7aafa86cd411"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:03a6d5349c9ee8f79ab3ff3694d6ce1cfc3ced1c9d36200cb8f08ba06bd3b782"}, + {file = "aiohttp-3.8.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:102e487eeb82afac440581e5d7f8f44560b36cf0bdd11abc51a46c1cd88914d4"}, + {file = "aiohttp-3.8.1-cp36-cp36m-win32.whl", hash = "sha256:4aed991a28ea3ce320dc8ce655875e1e00a11bdd29fe9444dd4f88c30d558602"}, + {file = "aiohttp-3.8.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b0e20cddbd676ab8a64c774fefa0ad787cc506afd844de95da56060348021e96"}, + {file = "aiohttp-3.8.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:37951ad2f4a6df6506750a23f7cbabad24c73c65f23f72e95897bb2cecbae676"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c23b1ad869653bc818e972b7a3a79852d0e494e9ab7e1a701a3decc49c20d51"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:15b09b06dae900777833fe7fc4b4aa426556ce95847a3e8d7548e2d19e34edb8"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:477c3ea0ba410b2b56b7efb072c36fa91b1e6fc331761798fa3f28bb224830dd"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2f2f69dca064926e79997f45b2f34e202b320fd3782f17a91941f7eb85502ee2"}, + {file = "aiohttp-3.8.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ef9612483cb35171d51d9173647eed5d0069eaa2ee812793a75373447d487aa4"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:6d69f36d445c45cda7b3b26afef2fc34ef5ac0cdc75584a87ef307ee3c8c6d00"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:55c3d1072704d27401c92339144d199d9de7b52627f724a949fc7d5fc56d8b93"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:b9d00268fcb9f66fbcc7cd9fe423741d90c75ee029a1d15c09b22d23253c0a44"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:07b05cd3305e8a73112103c834e91cd27ce5b4bd07850c4b4dbd1877d3f45be7"}, + {file = "aiohttp-3.8.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c34dc4958b232ef6188c4318cb7b2c2d80521c9a56c52449f8f93ab7bc2a8a1c"}, + {file = "aiohttp-3.8.1-cp37-cp37m-win32.whl", hash = "sha256:d2f9b69293c33aaa53d923032fe227feac867f81682f002ce33ffae978f0a9a9"}, + {file = "aiohttp-3.8.1-cp37-cp37m-win_amd64.whl", hash = "sha256:6ae828d3a003f03ae31915c31fa684b9890ea44c9c989056fea96e3d12a9fa17"}, + {file = "aiohttp-3.8.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:0c7ebbbde809ff4e970824b2b6cb7e4222be6b95a296e46c03cf050878fc1785"}, + {file = "aiohttp-3.8.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8b7ef7cbd4fec9a1e811a5de813311ed4f7ac7d93e0fda233c9b3e1428f7dd7b"}, + {file = "aiohttp-3.8.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c3d6a4d0619e09dcd61021debf7059955c2004fa29f48788a3dfaf9c9901a7cd"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:718626a174e7e467f0558954f94af117b7d4695d48eb980146016afa4b580b2e"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:589c72667a5febd36f1315aa6e5f56dd4aa4862df295cb51c769d16142ddd7cd"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2ed076098b171573161eb146afcb9129b5ff63308960aeca4b676d9d3c35e700"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:086f92daf51a032d062ec5f58af5ca6a44d082c35299c96376a41cbb33034675"}, + {file = "aiohttp-3.8.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:11691cf4dc5b94236ccc609b70fec991234e7ef8d4c02dd0c9668d1e486f5abf"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:31d1e1c0dbf19ebccbfd62eff461518dcb1e307b195e93bba60c965a4dcf1ba0"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:11a67c0d562e07067c4e86bffc1553f2cf5b664d6111c894671b2b8712f3aba5"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:bb01ba6b0d3f6c68b89fce7305080145d4877ad3acaed424bae4d4ee75faa950"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:44db35a9e15d6fe5c40d74952e803b1d96e964f683b5a78c3cc64eb177878155"}, + {file = "aiohttp-3.8.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:844a9b460871ee0a0b0b68a64890dae9c415e513db0f4a7e3cab41a0f2fedf33"}, + {file = "aiohttp-3.8.1-cp38-cp38-win32.whl", hash = "sha256:7d08744e9bae2ca9c382581f7dce1273fe3c9bae94ff572c3626e8da5b193c6a"}, + {file = "aiohttp-3.8.1-cp38-cp38-win_amd64.whl", hash = "sha256:04d48b8ce6ab3cf2097b1855e1505181bdd05586ca275f2505514a6e274e8e75"}, + {file = "aiohttp-3.8.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f5315a2eb0239185af1bddb1abf472d877fede3cc8d143c6cddad37678293237"}, + {file = "aiohttp-3.8.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a996d01ca39b8dfe77440f3cd600825d05841088fd6bc0144cc6c2ec14cc5f74"}, + {file = "aiohttp-3.8.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:13487abd2f761d4be7c8ff9080de2671e53fff69711d46de703c310c4c9317ca"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea302f34477fda3f85560a06d9ebdc7fa41e82420e892fc50b577e35fc6a50b2"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a2f635ce61a89c5732537a7896b6319a8fcfa23ba09bec36e1b1ac0ab31270d2"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e999f2d0e12eea01caeecb17b653f3713d758f6dcc770417cf29ef08d3931421"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0770e2806a30e744b4e21c9d73b7bee18a1cfa3c47991ee2e5a65b887c49d5cf"}, + {file = "aiohttp-3.8.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:d15367ce87c8e9e09b0f989bfd72dc641bcd04ba091c68cd305312d00962addd"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:6c7cefb4b0640703eb1069835c02486669312bf2f12b48a748e0a7756d0de33d"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:71927042ed6365a09a98a6377501af5c9f0a4d38083652bcd2281a06a5976724"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:28d490af82bc6b7ce53ff31337a18a10498303fe66f701ab65ef27e143c3b0ef"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:b6613280ccedf24354406caf785db748bebbddcf31408b20c0b48cb86af76866"}, + {file = "aiohttp-3.8.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:81e3d8c34c623ca4e36c46524a3530e99c0bc95ed068fd6e9b55cb721d408fb2"}, + {file = "aiohttp-3.8.1-cp39-cp39-win32.whl", hash = "sha256:7187a76598bdb895af0adbd2fb7474d7f6025d170bc0a1130242da817ce9e7d1"}, + {file = "aiohttp-3.8.1-cp39-cp39-win_amd64.whl", hash = "sha256:1c182cb873bc91b411e184dab7a2b664d4fea2743df0e4d57402f7f3fa644bac"}, + {file = "aiohttp-3.8.1.tar.gz", hash = "sha256:fc5471e1a54de15ef71c1bc6ebe80d4dc681ea600e68bfd1cbce40427f0b7578"}, ] aiokafka = [ {file = "aiokafka-0.7.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b19f077e12fe23e359f7a7dca9baf8532c63f4c8149703ce4c56de372d17e26c"}, @@ -1646,42 +1646,32 @@ pre-commit = [ {file = "pre_commit-2.15.0.tar.gz", hash = "sha256:3c25add78dbdfb6a28a651780d5c311ac40dd17f160eb3954a0c59da40a505a7"}, ] psycopg2-binary = [ - {file = "psycopg2-binary-2.9.1.tar.gz", hash = "sha256:b0221ca5a9837e040ebf61f48899926b5783668b7807419e4adae8175a31f773"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:24b0b6688b9f31a911f2361fe818492650795c9e5d3a1bc647acbd7440142a4f"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:542875f62bc56e91c6eac05a0deadeae20e1730be4c6334d8f04c944fcd99759"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:661509f51531ec125e52357a489ea3806640d0ca37d9dada461ffc69ee1e7b6e"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:d92272c7c16e105788efe2cfa5d680f07e34e0c29b03c1908f8636f55d5f915a"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-manylinux_2_24_ppc64le.whl", hash = "sha256:736b8797b58febabb85494142c627bd182b50d2a7ec65322983e71065ad3034c"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-win32.whl", hash = "sha256:ebccf1123e7ef66efc615a68295bf6fdba875a75d5bba10a05073202598085fc"}, - {file = "psycopg2_binary-2.9.1-cp310-cp310-win_amd64.whl", hash = "sha256:1f6ca4a9068f5c5c57e744b4baa79f40e83e3746875cac3c45467b16326bab45"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:c250a7ec489b652c892e4f0a5d122cc14c3780f9f643e1a326754aedf82d9a76"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aef9aee84ec78af51107181d02fe8773b100b01c5dfde351184ad9223eab3698"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:123c3fb684e9abfc47218d3784c7b4c47c8587951ea4dd5bc38b6636ac57f616"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_24_aarch64.whl", hash = "sha256:995fc41ebda5a7a663a254a1dcac52638c3e847f48307b5416ee373da15075d7"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-manylinux_2_24_ppc64le.whl", hash = "sha256:fbb42a541b1093385a2d8c7eec94d26d30437d0e77c1d25dae1dcc46741a385e"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-win32.whl", hash = "sha256:20f1ab44d8c352074e2d7ca67dc00843067788791be373e67a0911998787ce7d"}, - {file = "psycopg2_binary-2.9.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f6fac64a38f6768e7bc7b035b9e10d8a538a9fadce06b983fb3e6fa55ac5f5ce"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:1e3a362790edc0a365385b1ac4cc0acc429a0c0d662d829a50b6ce743ae61b5a"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f8559617b1fcf59a9aedba2c9838b5b6aa211ffedecabca412b92a1ff75aac1a"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a36c7eb6152ba5467fb264d73844877be8b0847874d4822b7cf2d3c0cb8cdcb0"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_24_aarch64.whl", hash = "sha256:2f62c207d1740b0bde5c4e949f857b044818f734a3d57f1d0d0edc65050532ed"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-manylinux_2_24_ppc64le.whl", hash = "sha256:cfc523edecddaef56f6740d7de1ce24a2fdf94fd5e704091856a201872e37f9f"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-win32.whl", hash = "sha256:1e85b74cbbb3056e3656f1cc4781294df03383127a8114cbc6531e8b8367bf1e"}, - {file = "psycopg2_binary-2.9.1-cp37-cp37m-win_amd64.whl", hash = "sha256:1473c0215b0613dd938db54a653f68251a45a78b05f6fc21af4326f40e8360a2"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:35c4310f8febe41f442d3c65066ca93cccefd75013df3d8c736c5b93ec288140"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8c13d72ed6af7fd2c8acbd95661cf9477f94e381fce0792c04981a8283b52917"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14db1752acdd2187d99cb2ca0a1a6dfe57fc65c3281e0f20e597aac8d2a5bd90"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_24_aarch64.whl", hash = "sha256:aed4a9a7e3221b3e252c39d0bf794c438dc5453bc2963e8befe9d4cd324dff72"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-manylinux_2_24_ppc64le.whl", hash = "sha256:da113b70f6ec40e7d81b43d1b139b9db6a05727ab8be1ee559f3a69854a69d34"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-win32.whl", hash = "sha256:4235f9d5ddcab0b8dbd723dca56ea2922b485ea00e1dafacf33b0c7e840b3d32"}, - {file = "psycopg2_binary-2.9.1-cp38-cp38-win_amd64.whl", hash = "sha256:988b47ac70d204aed01589ed342303da7c4d84b56c2f4c4b8b00deda123372bf"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:7360647ea04db2e7dff1648d1da825c8cf68dc5fbd80b8fb5b3ee9f068dcd21a"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca86db5b561b894f9e5f115d6a159fff2a2570a652e07889d8a383b5fae66eb4"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ced67f1e34e1a450cdb48eb53ca73b60aa0af21c46b9b35ac3e581cf9f00e31"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:0f2e04bd2a2ab54fa44ee67fe2d002bb90cee1c0f1cc0ebc3148af7b02034cbd"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-manylinux_2_24_ppc64le.whl", hash = "sha256:3242b9619de955ab44581a03a64bdd7d5e470cc4183e8fcadd85ab9d3756ce7a"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-win32.whl", hash = "sha256:0b7dae87f0b729922e06f85f667de7bf16455d411971b2043bbd9577af9d1975"}, - {file = "psycopg2_binary-2.9.1-cp39-cp39-win_amd64.whl", hash = "sha256:b4d7679a08fea64573c969f6994a2631908bb2c0e69a7235648642f3d2e39a68"}, + {file = "psycopg2-binary-2.9.2.tar.gz", hash = "sha256:234b1f48488b2f86aac04fb00cb04e5e9bcb960f34fa8a8e41b73149d581a93b"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:c0e1fb7097ded2cc44d9037cfc68ad86a30341261492e7de95d180e534969fb2"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:717525cdc97b23182ff6f470fb5bf6f0bc796b5a7000c6f6699d6679991e4a5e"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3865d0cd919349c45603bd7e80249a382c5ecf8106304cfd153282adf9684b6a"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:daf6b5c62eb738872d61a1fa740d7768904911ba5a7e055ed72169d379b58beb"}, + {file = "psycopg2_binary-2.9.2-cp310-cp310-manylinux_2_24_ppc64le.whl", hash = "sha256:3ac83656ff4fbe7f2a956ab085e3eb1d678df54759965d509bdd6a06ce520d49"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:53912199abb626a7249c662e72b70b4f57bf37f840599cec68625171435790dd"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:029e09a892b9ebc3c77851f69ce0720e1b72a9c6850460cee49b14dfbf9ccdd2"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db1b03c189f85b8df29030ad32d521dd7dcb862fd5f8892035314f5b886e70ce"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_24_aarch64.whl", hash = "sha256:2eecbdc5fa5886f2dd6cc673ce4291cc0fb8900965315268960ad9c2477f8276"}, + {file = "psycopg2_binary-2.9.2-cp36-cp36m-manylinux_2_24_ppc64le.whl", hash = "sha256:a77e98c68b0e6c51d4d6a994d22b30e77276cbd33e4aabdde03b9ad3a2c148aa"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:a507db7758953b1b170c4310691a1a89877029b1e11b08ba5fc8ae3ddb35596b"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2e4bbcfb403221ea1953f3e0a85cef00ed15c1683a66cf35c956a7e37c33a4c4"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f4dff0f15af6936c6fe6da7067b4216edbbe076ad8625da819cc066591b1133c"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_24_aarch64.whl", hash = "sha256:8d2aafe46eb87742425ece38130510fbb035787ee89a329af299029c4d9ae318"}, + {file = "psycopg2_binary-2.9.2-cp37-cp37m-manylinux_2_24_ppc64le.whl", hash = "sha256:37c8f00f7a2860bac9f7a54f03c243fc1dd9b367e5b2b52f5a02e5f4e9d8c49b"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:eeee7b18c51d02e49bf1984d7af26e8843fe68e31fa1cbab5366ebdfa1c89ade"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:497372cc76e6cbce2f51b37be141f360a321423c03eb9be45524b1d123f4cd11"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5671699aff57d22a245b7f4bba89e3de97dc841c5e98bd7f685429b2b20eca47"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_24_aarch64.whl", hash = "sha256:b9d45374ba98c1184df9cce93a0b766097544f8bdfcd5de83ff10f939c193125"}, + {file = "psycopg2_binary-2.9.2-cp38-cp38-manylinux_2_24_ppc64le.whl", hash = "sha256:a1852c5bef7e5f52bd43fde5eda610d4df0fb2efc31028150933e84b4140d47a"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-macosx_10_14_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:578c279cd1ce04f05ae0912530ece00bab92854911808e5aec27588aba87e361"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c2dea4deac3dd3687e32daeb0712ee96c535970dfdded37a11de6a21145ab0e"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b592f09ff18cfcc9037b9a976fcd62db48cae9dbd5385f2471d4c2ba40c52b4d"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:3a320e7a804f3886a599fea507364aaafbb8387027fffcdfbd34d96316c806c7"}, + {file = "psycopg2_binary-2.9.2-cp39-cp39-manylinux_2_24_ppc64le.whl", hash = "sha256:7585ca73dcfe326f31fafa8f96e6bb98ea9e9e46c7a1924ec8101d797914ae27"}, ] py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, @@ -1854,41 +1844,28 @@ toml = [ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] typed-ast = [ - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, - {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, - {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, - {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, - {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, - {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, - {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, - {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, - {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, - {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, - {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, - {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, - {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, - {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, - {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, - {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, + {file = "typed_ast-1.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7b310a207ee9fde3f46ba327989e6cba4195bc0c8c70a158456e7b10233e6bed"}, + {file = "typed_ast-1.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:52ca2b2b524d770bed7a393371a38e91943f9160a190141e0df911586066ecda"}, + {file = "typed_ast-1.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:14fed8820114a389a2b7e91624db5f85f3f6682fda09fe0268a59aabd28fe5f5"}, + {file = "typed_ast-1.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:65c81abbabda7d760df7304d843cc9dbe7ef5d485504ca59a46ae2d1731d2428"}, + {file = "typed_ast-1.5.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:37ba2ab65a0028b1a4f2b61a8fe77f12d242731977d274a03d68ebb751271508"}, + {file = "typed_ast-1.5.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:49af5b8f6f03ed1eb89ee06c1d7c2e7c8e743d720c3746a5857609a1abc94c94"}, + {file = "typed_ast-1.5.0-cp36-cp36m-win_amd64.whl", hash = "sha256:e4374a76e61399a173137e7984a1d7e356038cf844f24fd8aea46c8029a2f712"}, + {file = "typed_ast-1.5.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:ea517c2bb11c5e4ba7a83a91482a2837041181d57d3ed0749a6c382a2b6b7086"}, + {file = "typed_ast-1.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:51040bf45aacefa44fa67fb9ebcd1f2bec73182b99a532c2394eea7dabd18e24"}, + {file = "typed_ast-1.5.0-cp37-cp37m-win_amd64.whl", hash = "sha256:806e0c7346b9b4af8c62d9a29053f484599921a4448c37fbbcbbf15c25138570"}, + {file = "typed_ast-1.5.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a67fd5914603e2165e075f1b12f5a8356bfb9557e8bfb74511108cfbab0f51ed"}, + {file = "typed_ast-1.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:224afecb8b39739f5c9562794a7c98325cb9d972712e1a98b6989a4720219541"}, + {file = "typed_ast-1.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:155b74b078be842d2eb630dd30a280025eca0a5383c7d45853c27afee65f278f"}, + {file = "typed_ast-1.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:361b9e5d27bd8e3ccb6ea6ad6c4f3c0be322a1a0f8177db6d56264fa0ae40410"}, + {file = "typed_ast-1.5.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:618912cbc7e17b4aeba86ffe071698c6e2d292acbd6d1d5ec1ee724b8c4ae450"}, + {file = "typed_ast-1.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7e6731044f748340ef68dcadb5172a4b1f40847a2983fe3983b2a66445fbc8e6"}, + {file = "typed_ast-1.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e8a9b9c87801cecaad3b4c2b8876387115d1a14caa602c1618cedbb0cb2a14e6"}, + {file = "typed_ast-1.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:ec184dfb5d3d11e82841dbb973e7092b75f306b625fad7b2e665b64c5d60ab3f"}, + {file = "typed_ast-1.5.0.tar.gz", hash = "sha256:ff4ad88271aa7a55f19b6a161ed44e088c393846d954729549e3cde8257747bb"}, ] typing-extensions = [ - {file = "typing_extensions-3.10.0.2-py2-none-any.whl", hash = "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7"}, - {file = "typing_extensions-3.10.0.2-py3-none-any.whl", hash = "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34"}, - {file = "typing_extensions-3.10.0.2.tar.gz", hash = "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"}, + {file = "typing_extensions-4.0.0-py3-none-any.whl", hash = "sha256:829704698b22e13ec9eaf959122315eabb370b0884400e9818334d8b677023d9"}, ] urllib3 = [ {file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"}, From 451a1764277b27a5208c5ae6438090d675720143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 09:49:20 +0100 Subject: [PATCH 19/24] ISSUE #441 * Update `minos-microservice-common` dependency. --- poetry.lock | 6 +++--- pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index ecf9332f..b18e7652 100644 --- a/poetry.lock +++ b/poetry.lock @@ -495,8 +495,8 @@ PyYAML = "^5.4.1" [package.source] type = "git" url = "https://github.com/Clariteia/minos_microservice_common.git" -reference = "issue-651-remove-command-commandreply-event" -resolved_reference = "78996b750b19fac968d6ea85e865f1620adab278" +reference = "issue-653-middleware-config" +resolved_reference = "43e4e20375747153bdd7271e64fa1d32efc2f6b6" [[package]] name = "mistune" @@ -947,7 +947,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "894386b0f0dfe216edca09cb51175e136d4742ac92629c6f3fd2e5fb21dcc2ca" +content-hash = "d84e72b1022b7173d28142839a37627dfdac164236af7ee962dc2499168931d8" [metadata.files] aiohttp = [ diff --git a/pyproject.toml b/pyproject.toml index e49c2845..72361f78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ aiomisc = "^14.0.3" aiopg = "^1.2.1" aiohttp = "^3.7.4" dependency-injector = "^4.32.2" -minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-651-remove-command-commandreply-event" } +minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-653-middleware-config" } minos-microservice-aggregate = "^0.1.0" crontab = "^0.23.0" From 1ea29a1af6a25de261be63a52699fa2da1686611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 11:43:43 +0100 Subject: [PATCH 20/24] ISSUE #443 * Remove `minos-microservice-aggregate` dependency. --- minos/networks/__init__.py | 3 - minos/networks/brokers/publishers/events.py | 8 +- .../brokers/subscribers/events/handlers.py | 34 +++---- minos/networks/snapshots.py | 47 ---------- poetry.lock | 17 +--- pyproject.toml | 1 - .../test_events/test_handlers.py | 53 ++++++----- tests/test_networks/test_snapshots.py | 54 ----------- tests/utils.py | 90 +------------------ 9 files changed, 45 insertions(+), 262 deletions(-) delete mode 100644 minos/networks/snapshots.py delete mode 100644 tests/test_networks/test_snapshots.py diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index 568f954e..76cbc898 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -86,9 +86,6 @@ ScheduledRequestContent, ScheduledResponseException, ) -from .snapshots import ( - SnapshotService, -) from .utils import ( consume_queue, get_host_ip, diff --git a/minos/networks/brokers/publishers/events.py b/minos/networks/brokers/publishers/events.py index 595f3d7c..58ea466c 100644 --- a/minos/networks/brokers/publishers/events.py +++ b/minos/networks/brokers/publishers/events.py @@ -3,10 +3,10 @@ ) import logging - -from minos.aggregate import ( - AggregateDiff, +from typing import ( + Any, ) + from minos.common import ( MinosConfig, ) @@ -31,7 +31,7 @@ def _from_config(cls, *args, config: MinosConfig, **kwargs) -> EventBroker: return cls(*args, **config.broker.queue._asdict(), **kwargs) # noinspection PyMethodOverriding - async def send(self, data: AggregateDiff, topic: str, **kwargs) -> int: + async def send(self, data: Any, topic: str, **kwargs) -> int: """Send an ``Event``. :param data: The data to be send. diff --git a/minos/networks/brokers/subscribers/events/handlers.py b/minos/networks/brokers/subscribers/events/handlers.py index 2f83deb4..ac145c99 100644 --- a/minos/networks/brokers/subscribers/events/handlers.py +++ b/minos/networks/brokers/subscribers/events/handlers.py @@ -3,18 +3,15 @@ ) import logging -from asyncio import ( - gather, +from contextlib import ( + suppress, ) -from collections import ( - defaultdict, +from functools import ( + cmp_to_key, ) from inspect import ( isawaitable, ) -from operator import ( - attrgetter, -) from typing import ( Awaitable, Callable, @@ -46,9 +43,6 @@ logger = logging.getLogger(__name__) -uuid_getter = attrgetter("data.data.uuid") -version_getter = attrgetter("data.data.version") - class EventHandler(Handler): """Event Handler class.""" @@ -66,18 +60,16 @@ def _handlers_from_config(config: MinosConfig, **kwargs) -> dict[str, Callable[[ handlers = {decorator.topic: fn for decorator, fn in handlers.items()} return handlers - async def _dispatch_entries(self, entries: list[HandlerEntry]) -> None: - grouped = defaultdict(list) - for entry in entries: - grouped[uuid_getter(entry)].append(entry) - - for group in grouped.values(): - group.sort(key=version_getter) - - futures = (self._dispatch_group(group) for group in grouped.values()) - await gather(*futures) + async def _dispatch_entries(self, entries: list[HandlerEntry[Event]]) -> None: + def _fn(a: HandlerEntry[Event], b: HandlerEntry[Event]): + with suppress(TypeError): + if a.data.data < b.data.data: + return -1 + elif a.data.data > b.data.data: + return 1 + return 0 - async def _dispatch_group(self, entries: list[HandlerEntry]): + entries.sort(key=cmp_to_key(_fn)) for entry in entries: await self._dispatch_one(entry) diff --git a/minos/networks/snapshots.py b/minos/networks/snapshots.py deleted file mode 100644 index 1c83f984..00000000 --- a/minos/networks/snapshots.py +++ /dev/null @@ -1,47 +0,0 @@ -from aiomisc.service.periodic import ( - PeriodicService, -) -from dependency_injector.wiring import ( - Provide, - inject, -) - -from minos.aggregate import ( - SnapshotRepository, -) - - -class SnapshotService(PeriodicService): - """Minos Snapshot Service class.""" - - @inject - def __init__( - self, snapshot_repository: SnapshotRepository = Provide["snapshot_repository"], interval: float = 60, **kwargs - ): - super().__init__(interval=interval, **kwargs) - - self.snapshot_repository = snapshot_repository - - async def start(self) -> None: - """Start the service execution. - - :return: This method does not return anything. - """ - await self.snapshot_repository.setup() - await super().start() - - async def callback(self) -> None: - """Callback implementation to be executed periodically. - - :return: This method does not return anything. - """ - await self.snapshot_repository.synchronize() - - async def stop(self, err: Exception = None) -> None: - """Stop the service execution. - - :param err: Optional exception that stopped the execution. - :return: This method does not return anything. - """ - await super().stop(err) - await self.snapshot_repository.destroy() diff --git a/poetry.lock b/poetry.lock index b18e7652..685406b5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -462,17 +462,6 @@ category = "dev" optional = false python-versions = "*" -[[package]] -name = "minos-microservice-aggregate" -version = "0.1.1" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" -category = "main" -optional = false -python-versions = ">=3.9,<4.0" - -[package.dependencies] -minos-microservice-common = ">=0.2.0,<0.3.0" - [[package]] name = "minos-microservice-common" version = "0.2.1" @@ -947,7 +936,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "d84e72b1022b7173d28142839a37627dfdac164236af7ee962dc2499168931d8" +content-hash = "89b5e8c3dc0af181de2056f326e15b3344bf654298c401795ec5619643d36e0a" [metadata.files] aiohttp = [ @@ -1509,10 +1498,6 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos_microservice_aggregate-0.1.1-py3-none-any.whl", hash = "sha256:077315ed09a5478e4c85dd7caa9f2876d6089d0eb3a0e69bfbe4bafa934db2ab"}, - {file = "minos_microservice_aggregate-0.1.1.tar.gz", hash = "sha256:9ef4e17479254eb4bd59c9fd3b3295a806a81e858c6228637611314edd5c663c"}, -] minos-microservice-common = [] mistune = [ {file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"}, diff --git a/pyproject.toml b/pyproject.toml index 72361f78..8e7baf60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,6 @@ aiopg = "^1.2.1" aiohttp = "^3.7.4" dependency-injector = "^4.32.2" minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-653-middleware-config" } -minos-microservice-aggregate = "^0.1.0" crontab = "^0.23.0" [tool.poetry.dev-dependencies] diff --git a/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py index bd6a70fc..7ab1d0ba 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_events/test_handlers.py @@ -10,20 +10,9 @@ MagicMock, call, ) -from uuid import ( - uuid4, -) import aiopg -from minos.aggregate import ( - Action, - AggregateDiff, - FieldDiffContainer, -) -from minos.common import ( - current_datetime, -) from minos.common.testing import ( PostgresAsyncTestCase, ) @@ -38,6 +27,7 @@ from tests.utils import ( BASE_PATH, FAKE_AGGREGATE_DIFF, + FakeModel, ) @@ -112,31 +102,38 @@ async def test_get_callback_raises_exception(self): fn = self.handler.get_callback(_Cls._fn_raises_exception) await fn(self.event) + async def test_dispatch_without_sorting(self): + observed = list() + + async def _fn2(request): + content = await request.content() + observed.append(content) + + self.handler.get_action = MagicMock(return_value=_fn2) + + events = [Event("TicketAdded", FakeModel("uuid1")), Event("TicketAdded", FakeModel("uuid2"))] + + async with self.handler: + for event in events: + await self._insert_one(event) + + await self.handler.dispatch() + + expected = [FakeModel("uuid1"), FakeModel("uuid2")] + self.assertEqual(expected, observed) + async def test_dispatch_concurrent(self): observed = defaultdict(list) async def _fn2(request): - diff = await request.content() - observed[diff.uuid].append(diff.version) + content = await request.content() + observed[content[0]].append(content[1]) self.handler.get_action = MagicMock(return_value=_fn2) - uuid1, uuid2 = uuid4(), uuid4() - events = list() for i in range(1, 6): - events.extend( - [ - Event( - "TicketAdded", - AggregateDiff(uuid1, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), - ), - Event( - "TicketAdded", - AggregateDiff(uuid2, "Foo", i, Action.CREATE, current_datetime(), FieldDiffContainer.empty()), - ), - ] - ) + events.extend([Event("TicketAdded", ["uuid1", i]), Event("TicketAdded", ["uuid2", i])]) shuffle(events) async with self.handler: @@ -145,7 +142,7 @@ async def _fn2(request): await self.handler.dispatch() - expected = {uuid1: list(range(1, 6)), uuid2: list(range(1, 6))} + expected = {"uuid1": list(range(1, 6)), "uuid2": list(range(1, 6))} self.assertEqual(expected, observed) async def _insert_one(self, instance): diff --git a/tests/test_networks/test_snapshots.py b/tests/test_networks/test_snapshots.py deleted file mode 100644 index a2af7172..00000000 --- a/tests/test_networks/test_snapshots.py +++ /dev/null @@ -1,54 +0,0 @@ -import unittest -from unittest.mock import ( - MagicMock, -) - -from aiomisc.service.periodic import ( - PeriodicService, -) - -from minos.aggregate import ( - InMemorySnapshotRepository, -) -from minos.networks import ( - SnapshotService, -) -from tests.utils import ( - MinosTestCase, -) - - -class TestSnapshotService(MinosTestCase): - def setUp(self) -> None: - super().setUp() - self.snapshot = InMemorySnapshotRepository() - - def test_is_instance(self): - service = SnapshotService(self.snapshot, interval=0.1) - self.assertIsInstance(service, PeriodicService) - - def test_dispatcher_config(self): - snapshot = InMemorySnapshotRepository() - service = SnapshotService(snapshot, interval=0.1) - self.assertEqual(snapshot, service.snapshot_repository) - self.assertFalse(snapshot.already_setup) - - async def test_start(self): - service = SnapshotService(self.snapshot, interval=0.1, loop=None) - service.snapshot_repository.setup = MagicMock(side_effect=service.snapshot_repository.setup) - await service.start() - self.assertTrue(1, service.snapshot_repository.setup.call_count) - await service.stop() - - async def test_callback(self): - service = SnapshotService(self.snapshot, interval=0.1) - await service.snapshot_repository.setup() - mock = MagicMock(side_effect=service.snapshot_repository.synchronize) - service.snapshot_repository.synchronize = mock - await service.callback() - self.assertEqual(1, mock.call_count) - await service.snapshot_repository.destroy() - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/utils.py b/tests/utils.py index 785dac99..4e4d4330 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,5 +1,3 @@ -import sys -import unittest from collections import ( namedtuple, ) @@ -17,25 +15,10 @@ from cached_property import ( cached_property, ) -from dependency_injector import ( - containers, - providers, -) -from minos.aggregate import ( - Action, - AggregateDiff, - FieldDiff, - FieldDiffContainer, - InMemoryEventRepository, - InMemorySnapshotRepository, - InMemoryTransactionRepository, -) from minos.common import ( DeclarativeModel, - Lock, MinosBroker, - MinosPool, MinosSagaManager, Model, current_datetime, @@ -51,77 +34,6 @@ BASE_PATH = Path(__file__).parent -FAKE_AGGREGATE_DIFF = AggregateDiff( - uuid4(), "Foo", 3, Action.CREATE, current_datetime(), FieldDiffContainer({FieldDiff("doors", int, 5)}) -) - - -class MinosTestCase(unittest.IsolatedAsyncioTestCase): - def setUp(self) -> None: - super().setUp() - - self.event_broker = FakeBroker() - self.lock_pool = FakeLockPool() - self.transaction_repository = InMemoryTransactionRepository(lock_pool=self.lock_pool) - self.event_repository = InMemoryEventRepository( - event_broker=self.event_broker, transaction_repository=self.transaction_repository, lock_pool=self.lock_pool - ) - self.snapshot = InMemorySnapshotRepository( - event_repository=self.event_repository, transaction_repository=self.transaction_repository - ) - - self.container = containers.DynamicContainer() - self.container.event_broker = providers.Object(self.event_broker) - self.container.transaction_repository = providers.Object(self.transaction_repository) - self.container.lock_pool = providers.Object(self.lock_pool) - self.container.event_repository = providers.Object(self.event_repository) - self.container.snapshot = providers.Object(self.snapshot) - self.container.wire(modules=[sys.modules[__name__]]) - - async def asyncSetUp(self): - await super().asyncSetUp() - - await self.event_broker.setup() - await self.transaction_repository.setup() - await self.lock_pool.setup() - await self.event_repository.setup() - await self.snapshot.setup() - - async def asyncTearDown(self): - await self.snapshot.destroy() - await self.event_repository.destroy() - await self.lock_pool.destroy() - await self.transaction_repository.destroy() - await self.event_broker.destroy() - - await super().asyncTearDown() - - def tearDown(self) -> None: - self.container.unwire() - super().tearDown() - - -class FakeLock(Lock): - """For testing purposes.""" - - def __init__(self, key=None, *args, **kwargs): - if key is None: - key = "fake" - super().__init__(key, *args, **kwargs) - - async def __aexit__(self, exc_type, exc_val, exc_tb): - return - - -class FakeLockPool(MinosPool): - """For testing purposes.""" - - async def _create_instance(self): - return FakeLock() - - async def _destroy_instance(self, instance) -> None: - """For testing purposes.""" - class FakeModel(DeclarativeModel): """For testing purposes""" @@ -129,6 +41,8 @@ class FakeModel(DeclarativeModel): text: str +FAKE_AGGREGATE_DIFF = FakeModel("Foo") + Message = namedtuple("Message", ["topic", "partition", "value"]) From e8b19be744dd25847403be0fcbfe1ba7fa817e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 12:07:49 +0100 Subject: [PATCH 21/24] ISSUE #441 * Add tests for middleware. * Remove warnings --- minos/networks/decorators/builders.py | 8 ++++++-- .../test_decorators/test_builders.py | 17 +++++++++-------- tests/test_networks/test_rest/test_services.py | 2 -- .../test_scheduling/test_schedulers.py | 9 +++++++-- tests/utils.py | 9 +++++++++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/minos/networks/decorators/builders.py b/minos/networks/decorators/builders.py index 4d7d7e6e..d4a17fa4 100644 --- a/minos/networks/decorators/builders.py +++ b/minos/networks/decorators/builders.py @@ -46,9 +46,13 @@ class EnrouteBuilder: """Enroute builder class.""" - def __init__(self, *classes: Union[str, Type], middleware: Optional[list[Union[str, Callable]]] = None): + def __init__( + self, *classes: Union[str, Type], middleware: Optional[Union[str, Callable, list[Union[str, Callable]]]] = None + ): if middleware is None: - middleware = list() + middleware = tuple() + if not isinstance(middleware, (tuple, list)): + middleware = [middleware] middleware = list(map(lambda fn: fn if not isinstance(fn, str) else import_module(fn), middleware)) diff --git a/tests/test_networks/test_decorators/test_builders.py b/tests/test_networks/test_decorators/test_builders.py index afb62eba..949a86e7 100644 --- a/tests/test_networks/test_decorators/test_builders.py +++ b/tests/test_networks/test_decorators/test_builders.py @@ -18,13 +18,14 @@ from tests.utils import ( FakeRequest, FakeService, + fake_middleware, ) class TestEnrouteBuilder(unittest.IsolatedAsyncioTestCase): def setUp(self) -> None: self.request = FakeRequest("test") - self.builder = EnrouteBuilder(FakeService) + self.builder = EnrouteBuilder(FakeService, middleware=fake_middleware) def test_classes(self): self.assertEqual((FakeService,), self.builder.classes) @@ -37,11 +38,11 @@ async def test_get_rest_command_query(self): handlers = self.builder.get_rest_command_query() self.assertEqual(3, len(handlers)) - expected = Response("(Get Tickets: test)") + expected = Response("_(Get Tickets: test)_") observed = await handlers[RestQueryEnrouteDecorator("tickets/", "GET")](self.request) self.assertEqual(expected, observed) - expected = Response("Create Ticket") + expected = Response("_Create Ticket_") observed = await handlers[RestCommandEnrouteDecorator("orders/", "GET")](self.request) self.assertEqual(expected, observed) @@ -53,7 +54,7 @@ async def test_get_broker_event(self): handlers = self.builder.get_broker_event() self.assertEqual(1, len(handlers)) - expected = Response("Ticket Added: [test]") + expected = Response("_Ticket Added: [test]_") observed = await handlers[BrokerEventEnrouteDecorator("TicketAdded")](self.request) self.assertEqual(expected, observed) @@ -61,7 +62,7 @@ async def test_get_periodic_event(self): handlers = self.builder.get_periodic_event() self.assertEqual(1, len(handlers)) - expected = {Response("newsletter sent!"), Response("checked inactive users!")} + expected = {Response("_newsletter sent!_"), Response("_checked inactive users!_")} # noinspection PyTypeChecker observed = set(await handlers[PeriodicEventEnrouteDecorator("@daily")](self.request)) self.assertEqual(expected, observed) @@ -70,15 +71,15 @@ async def test_get_broker_command_query(self): handlers = self.builder.get_broker_command_query() self.assertEqual(4, len(handlers)) - expected = Response("(Get Tickets: test)") + expected = Response("_(Get Tickets: test)_") observed = await handlers[BrokerQueryEnrouteDecorator("GetTickets")](self.request) self.assertEqual(expected, observed) - expected = Response("Create Ticket") + expected = Response("_Create Ticket_") observed = await handlers[BrokerCommandEnrouteDecorator("CreateTicket")](self.request) self.assertEqual(expected, observed) - expected = Response("Create Ticket") + expected = Response("_Create Ticket_") observed = await handlers[BrokerCommandEnrouteDecorator("AddTicket")](self.request) self.assertEqual(expected, observed) diff --git a/tests/test_networks/test_rest/test_services.py b/tests/test_networks/test_rest/test_services.py index 572b7709..c9978cd8 100644 --- a/tests/test_networks/test_rest/test_services.py +++ b/tests/test_networks/test_rest/test_services.py @@ -2,7 +2,6 @@ from aiohttp.test_utils import ( AioHTTPTestCase, - unittest_run_loop, ) from minos.common import ( @@ -28,7 +27,6 @@ async def get_application(self): return await rest_interface.create_application() - @unittest_run_loop async def test_methods(self): url = "/order" resp = await self.client.request("GET", url) diff --git a/tests/test_networks/test_scheduling/test_schedulers.py b/tests/test_networks/test_scheduling/test_schedulers.py index a6a15a1f..89e7f37b 100644 --- a/tests/test_networks/test_scheduling/test_schedulers.py +++ b/tests/test_networks/test_scheduling/test_schedulers.py @@ -1,5 +1,6 @@ import asyncio import unittest +import warnings from unittest.mock import ( AsyncMock, call, @@ -88,7 +89,9 @@ async def test_start(self) -> None: self.assertFalse(self.periodic.started) with patch("asyncio.create_task", return_value="test") as mock_create: - await self.periodic.start() + with warnings.catch_warnings(): + warnings.simplefilter("ignore", RuntimeWarning) + await self.periodic.start() self.assertEqual(1, mock_create.call_count) self.assertEqual("run_forever", mock_create.call_args.args[0].__name__) self.assertTrue(self.periodic.started) @@ -98,7 +101,9 @@ async def test_stop(self) -> None: mock = AsyncMock() self.periodic._task = mock with patch("asyncio.wait_for") as mock_wait: - await self.periodic.stop() + with warnings.catch_warnings(): + warnings.simplefilter("ignore", RuntimeWarning) + await self.periodic.stop() self.assertEqual(1, mock_wait.call_count) self.assertEqual(call(mock, None), mock_wait.call_args) diff --git a/tests/utils.py b/tests/utils.py index 785dac99..f4fe63c8 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -7,6 +7,7 @@ Path, ) from typing import ( + Callable, Optional, ) from uuid import ( @@ -221,6 +222,14 @@ async def send( self.status = status +async def fake_middleware(request: Request, inner: Callable) -> Optional[Response]: + """For testing purposes.""" + response = await inner(request) + if response is not None: + return Response(f"_{await response.content()}_") + return response + + class FakeService: """For testing purposes.""" From e2a449f350d9efa3ba91a798235985144e3a1103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 12:25:04 +0100 Subject: [PATCH 22/24] ISSUE #441 * Update `minos-microservice-common` dependency. --- minos/networks/__init__.py | 2 - minos/networks/brokers/__init__.py | 2 - minos/networks/brokers/publishers/abc.py | 3 +- .../networks/brokers/subscribers/__init__.py | 4 -- .../subscribers/command_replies/__init__.py | 6 -- .../subscribers/command_replies/handlers.py | 52 -------------- .../subscribers/command_replies/services.py | 52 -------------- poetry.lock | 34 ++++------ pyproject.toml | 2 +- .../test_command_replies/__init__.py | 1 - .../test_command_replies/test_handlers.py | 68 ------------------- .../test_command_replies/test_services.py | 62 ----------------- .../test_commands/test_handlers.py | 37 ++++++---- tests/utils.py | 45 ------------ 14 files changed, 40 insertions(+), 330 deletions(-) delete mode 100644 minos/networks/brokers/subscribers/command_replies/__init__.py delete mode 100644 minos/networks/brokers/subscribers/command_replies/handlers.py delete mode 100644 minos/networks/brokers/subscribers/command_replies/services.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py delete mode 100644 tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index 76cbc898..d50df8b6 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -12,8 +12,6 @@ CommandHandlerService, CommandReply, CommandReplyBroker, - CommandReplyHandler, - CommandReplyHandlerService, CommandStatus, Consumer, ConsumerService, diff --git a/minos/networks/brokers/__init__.py b/minos/networks/brokers/__init__.py index f659c37f..f547a418 100644 --- a/minos/networks/brokers/__init__.py +++ b/minos/networks/brokers/__init__.py @@ -17,8 +17,6 @@ from .subscribers import ( CommandHandler, CommandHandlerService, - CommandReplyHandler, - CommandReplyHandlerService, Consumer, ConsumerService, DynamicHandler, diff --git a/minos/networks/brokers/publishers/abc.py b/minos/networks/brokers/publishers/abc.py index 5063535e..21fc57f7 100644 --- a/minos/networks/brokers/publishers/abc.py +++ b/minos/networks/brokers/publishers/abc.py @@ -7,7 +7,6 @@ ) from minos.common import ( - MinosBroker, PostgreSqlMinosDatabase, ) @@ -22,7 +21,7 @@ async def _create_broker_table(self) -> None: await self.submit_query(_CREATE_TABLE_QUERY, lock=hash("producer_queue")) -class Broker(MinosBroker, BrokerSetup, ABC): +class Broker(BrokerSetup, ABC): """Minos Broker Class.""" ACTION: str diff --git a/minos/networks/brokers/subscribers/__init__.py b/minos/networks/brokers/subscribers/__init__.py index 021aad98..166b87fe 100644 --- a/minos/networks/brokers/subscribers/__init__.py +++ b/minos/networks/brokers/subscribers/__init__.py @@ -2,10 +2,6 @@ Handler, HandlerSetup, ) -from .command_replies import ( - CommandReplyHandler, - CommandReplyHandlerService, -) from .commands import ( CommandHandler, CommandHandlerService, diff --git a/minos/networks/brokers/subscribers/command_replies/__init__.py b/minos/networks/brokers/subscribers/command_replies/__init__.py deleted file mode 100644 index 99238638..00000000 --- a/minos/networks/brokers/subscribers/command_replies/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from .handlers import ( - CommandReplyHandler, -) -from .services import ( - CommandReplyHandlerService, -) diff --git a/minos/networks/brokers/subscribers/command_replies/handlers.py b/minos/networks/brokers/subscribers/command_replies/handlers.py deleted file mode 100644 index 112c5996..00000000 --- a/minos/networks/brokers/subscribers/command_replies/handlers.py +++ /dev/null @@ -1,52 +0,0 @@ -from __future__ import ( - annotations, -) - -import logging -from typing import ( - Any, -) - -from dependency_injector.wiring import ( - Provide, - inject, -) - -from minos.common import ( - MinosConfig, - MinosSagaManager, -) - -from ..abc import ( - Handler, -) -from ..entries import ( - HandlerEntry, -) - -logger = logging.getLogger(__name__) - - -class CommandReplyHandler(Handler): - """Command Reply Handler class.""" - - @inject - def __init__(self, saga_manager: MinosSagaManager = Provide["saga_manager"], **kwargs: Any): - super().__init__(**kwargs) - - self.saga_manager = saga_manager - - @classmethod - def _from_config(cls, *args, config: MinosConfig, **kwargs) -> CommandReplyHandler: - handlers = {f"{config.service.name}Reply": None} - # noinspection PyProtectedMember - return cls(*args, handlers=handlers, **config.broker.queue._asdict(), **kwargs) - - async def dispatch_one(self, entry: HandlerEntry) -> None: - """Dispatch one row. - - :param entry: Entry to be dispatched. - :return: This method does not return anything. - """ - logger.info(f"Dispatching '{entry!s}'...") - await self.saga_manager.run(reply=entry.data, pause_on_disk=True, raise_on_error=False, return_execution=False) diff --git a/minos/networks/brokers/subscribers/command_replies/services.py b/minos/networks/brokers/subscribers/command_replies/services.py deleted file mode 100644 index a4c7e376..00000000 --- a/minos/networks/brokers/subscribers/command_replies/services.py +++ /dev/null @@ -1,52 +0,0 @@ -import logging - -from aiomisc import ( - Service, -) -from cached_property import ( - cached_property, -) - -from .handlers import ( - CommandReplyHandler, -) - -logger = logging.getLogger(__name__) - - -class CommandReplyHandlerService(Service): - """Minos QueueDispatcherService class.""" - - def __init__(self, **kwargs): - super().__init__(**kwargs) - self._init_kwargs = kwargs - - async def start(self) -> None: - """Method to be called at the startup by the internal ``aiomisc`` loigc. - - :return: This method does not return anything. - """ - await self.dispatcher.setup() - - try: - self.start_event.set() - except RuntimeError: - logger.warning("Runtime is not properly setup.") - - await self.dispatcher.dispatch_forever() - - async def stop(self, err: Exception = None) -> None: - """Stop the service execution. - - :param err: Optional exception that stopped the execution. - :return: This method does not return anything. - """ - await self.dispatcher.destroy() - - @cached_property - def dispatcher(self) -> CommandReplyHandler: - """Get the service dispatcher. - - :return: A ``CommandReplyHandler`` instance. - """ - return CommandReplyHandler.from_config(**self._init_kwargs) diff --git a/poetry.lock b/poetry.lock index 685406b5..1587d0b6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -464,28 +464,21 @@ python-versions = "*" [[package]] name = "minos-microservice-common" -version = "0.2.1" +version = "0.3.0" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = "^3.9" -develop = false +python-versions = ">=3.9,<4.0" [package.dependencies] -aiomisc = "^14.0.3" -aiopg = "^1.2.1" -cached-property = "^1.5.2" -dependency-injector = "^4.32.2" -fastavro = "^1.4.0" -lmdb = "^1.2.1" -orjson = "^3.5.2" -PyYAML = "^5.4.1" - -[package.source] -type = "git" -url = "https://github.com/Clariteia/minos_microservice_common.git" -reference = "issue-653-middleware-config" -resolved_reference = "43e4e20375747153bdd7271e64fa1d32efc2f6b6" +aiomisc = ">=14.0.3,<15.0.0" +aiopg = ">=1.2.1,<2.0.0" +cached-property = ">=1.5.2,<2.0.0" +dependency-injector = ">=4.32.2,<5.0.0" +fastavro = ">=1.4.0,<2.0.0" +lmdb = ">=1.2.1,<2.0.0" +orjson = ">=3.5.2,<4.0.0" +PyYAML = ">=5.4.1,<6.0.0" [[package]] name = "mistune" @@ -936,7 +929,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "89b5e8c3dc0af181de2056f326e15b3344bf654298c401795ec5619643d36e0a" +content-hash = "8b78cad6b9193a91e1cc0bc0f549afa4ca4e58d18521381663def0433faec9bb" [metadata.files] aiohttp = [ @@ -1498,7 +1491,10 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-common = [] +minos-microservice-common = [ + {file = "minos_microservice_common-0.3.0-py3-none-any.whl", hash = "sha256:0951b79119ac49a79341fb9de7864f90830f2ff55fa94743d46b0b1aca17eb66"}, + {file = "minos_microservice_common-0.3.0.tar.gz", hash = "sha256:0f0d601b789e6231d482660278e4bd07160bf656c785c5fd2d5c937a112748b8"}, +] mistune = [ {file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"}, {file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"}, diff --git a/pyproject.toml b/pyproject.toml index 8e7baf60..789ec253 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ aiomisc = "^14.0.3" aiopg = "^1.2.1" aiohttp = "^3.7.4" dependency-injector = "^4.32.2" -minos-microservice-common = { git = "https://github.com/Clariteia/minos_microservice_common.git", branch = "issue-653-middleware-config" } +minos-microservice-common = "^0.3.0" crontab = "^0.23.0" [tool.poetry.dev-dependencies] diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py deleted file mode 100644 index 8b137891..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py deleted file mode 100644 index e3655fc6..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_handlers.py +++ /dev/null @@ -1,68 +0,0 @@ -import unittest -from unittest.mock import ( - AsyncMock, - call, -) -from uuid import ( - uuid4, -) - -from minos.common.testing import ( - PostgresAsyncTestCase, -) -from minos.networks import ( - CommandReply, - CommandReplyHandler, - CommandStatus, - HandlerEntry, -) -from tests.utils import ( - BASE_PATH, - FakeModel, - FakeSagaManager, -) - - -class TestCommandReplyHandler(PostgresAsyncTestCase): - CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" - - def test_from_config(self): - saga_manager = FakeSagaManager() - handler = CommandReplyHandler.from_config(config=self.config, saga_manager=saga_manager) - self.assertIsInstance(handler, CommandReplyHandler) - handlers = {"OrderReply": None} - self.assertEqual(handlers, handler.handlers) - self.assertEqual(self.config.broker.queue.records, handler._records) - self.assertEqual(self.config.broker.queue.retry, handler._retry) - self.assertEqual(self.config.broker.queue.host, handler.host) - self.assertEqual(self.config.broker.queue.port, handler.port) - self.assertEqual(self.config.broker.queue.database, handler.database) - self.assertEqual(self.config.broker.queue.user, handler.user) - self.assertEqual(self.config.broker.queue.password, handler.password) - self.assertEqual(saga_manager, handler.saga_manager) - - async def test_dispatch(self): - saga_manager = FakeSagaManager() - mock = AsyncMock() - saga_manager._load_and_run = mock - - saga = uuid4() - command = CommandReply( - "TicketAdded", - [FakeModel("foo")], - saga=saga, - status=CommandStatus.SUCCESS, - service_name=self.config.service.name, - ) - entry = HandlerEntry(1, "TicketAdded", 0, command.avro_bytes, 1) - - async with CommandReplyHandler.from_config(config=self.config, saga_manager=saga_manager) as handler: - await handler.dispatch_one(entry) - - self.assertEqual(1, mock.call_count) - expected = call(command, pause_on_disk=True, raise_on_error=False, return_execution=False) - self.assertEqual(expected, mock.call_args) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py b/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py deleted file mode 100644 index a9fb60d0..00000000 --- a/tests/test_networks/test_brokers/test_subscribers/test_command_replies/test_services.py +++ /dev/null @@ -1,62 +0,0 @@ -import unittest -from unittest.mock import ( - AsyncMock, -) - -from aiomisc import ( - Service, -) - -from minos.common.testing import ( - PostgresAsyncTestCase, -) -from minos.networks import ( - CommandReplyHandler, - CommandReplyHandlerService, -) -from tests.utils import ( - BASE_PATH, -) - - -class TestCommandReplyHandlerService(PostgresAsyncTestCase): - CONFIG_FILE_PATH = BASE_PATH / "test_config.yml" - - def test_is_instance(self): - service = CommandReplyHandlerService(config=self.config) - self.assertIsInstance(service, Service) - - def test_dispatcher(self): - service = CommandReplyHandlerService(config=self.config) - self.assertIsInstance(service.dispatcher, CommandReplyHandler) - - async def test_start_stop(self): - service = CommandReplyHandlerService(config=self.config) - - setup_mock = AsyncMock() - destroy_mock = AsyncMock() - dispatch_forever_mock = AsyncMock() - - service.dispatcher.setup = setup_mock - service.dispatcher.destroy = destroy_mock - service.dispatcher.dispatch_forever = dispatch_forever_mock - - await service.start() - - self.assertEqual(1, setup_mock.call_count) - self.assertEqual(1, dispatch_forever_mock.call_count) - self.assertEqual(0, destroy_mock.call_count) - - setup_mock.reset_mock() - destroy_mock.reset_mock() - dispatch_forever_mock.reset_mock() - - await service.stop() - - self.assertEqual(0, setup_mock.call_count) - self.assertEqual(0, dispatch_forever_mock.call_count) - self.assertEqual(1, destroy_mock.call_count) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py index 179fdc9c..5c8f4e4b 100644 --- a/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py +++ b/tests/test_networks/test_brokers/test_subscribers/test_commands/test_handlers.py @@ -15,6 +15,7 @@ USER_CONTEXT_VAR, Command, CommandHandler, + CommandReplyBroker, CommandStatus, HandlerEntry, HandlerRequest, @@ -25,7 +26,6 @@ ) from tests.utils import ( BASE_PATH, - FakeBroker, FakeModel, ) @@ -53,15 +53,24 @@ class TestCommandHandler(PostgresAsyncTestCase): def setUp(self) -> None: super().setUp() - self.command_reply_broker = FakeBroker() - self.handler = CommandHandler.from_config(config=self.config, command_reply_broker=self.command_reply_broker) + self.command_reply_broker = CommandReplyBroker.from_config(self.config) + self.handler = CommandHandler.from_config(self.config, command_reply_broker=self.command_reply_broker) self.saga = uuid4() self.user = uuid4() self.command = Command("AddOrder", FakeModel("foo"), saga=self.saga, user=self.user, reply_topic="UpdateTicket") + async def asyncSetUp(self): + await super().asyncSetUp() + await self.command_reply_broker.setup() + await self.handler.setup() + + async def asyncTearDown(self): + await self.handler.destroy() + await self.command_reply_broker.destroy() + await super().asyncTearDown() + def test_from_config(self): - broker = FakeBroker() - handler = CommandHandler.from_config(config=self.config, command_reply_broker=broker) + handler = CommandHandler.from_config(self.config, command_reply_broker=self.command_reply_broker) self.assertIsInstance(handler, CommandHandler) self.assertEqual({"GetOrder", "AddOrder", "DeleteOrder", "UpdateOrder"}, set(handler.handlers.keys())) @@ -72,25 +81,25 @@ def test_from_config(self): self.assertEqual(self.config.broker.queue.database, handler.database) self.assertEqual(self.config.broker.queue.user, handler.user) self.assertEqual(self.config.broker.queue.password, handler.password) - self.assertEqual(broker, handler.command_reply_broker) + self.assertEqual(self.command_reply_broker, handler.command_reply_broker) async def test_dispatch(self): callback_mock = AsyncMock(return_value=Response("add_order")) lookup_mock = MagicMock(return_value=callback_mock) entry = HandlerEntry(1, "AddOrder", 0, self.command.avro_bytes, 1, callback_lookup=lookup_mock) - async with self.handler: - await self.handler.dispatch_one(entry) + send_mock = AsyncMock() + self.command_reply_broker.send = send_mock + + await self.handler.dispatch_one(entry) self.assertEqual(1, lookup_mock.call_count) self.assertEqual(call("AddOrder"), lookup_mock.call_args) - self.assertEqual(1, self.command_reply_broker.call_count) - self.assertEqual("add_order", self.command_reply_broker.items) - self.assertEqual("UpdateTicket", self.command_reply_broker.topic) - self.assertEqual(self.command.saga, self.command_reply_broker.saga) - self.assertEqual(None, self.command_reply_broker.reply_topic) - self.assertEqual(CommandStatus.SUCCESS, self.command_reply_broker.status) + self.assertEqual( + [call("add_order", topic="UpdateTicket", saga=self.command.saga, status=CommandStatus.SUCCESS)], + send_mock.call_args_list, + ) self.assertEqual(1, callback_mock.call_count) observed = callback_mock.call_args[0][0] diff --git a/tests/utils.py b/tests/utils.py index b9af9e41..ea28e2f7 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -19,13 +19,8 @@ from minos.common import ( DeclarativeModel, - MinosBroker, - MinosSagaManager, - Model, - current_datetime, ) from minos.networks import ( - CommandStatus, EnrouteDecorator, Request, Response, @@ -96,46 +91,6 @@ async def destroy(self): self.setup_destroy += 1 -class FakeSagaManager(MinosSagaManager): - """For testing purposes.""" - - async def _run_new(self, name: str, **kwargs) -> None: - """For testing purposes.""" - - async def _load_and_run(self, reply, **kwargs) -> None: - """For testing purposes.""" - - -class FakeBroker(MinosBroker): - """For testing purposes.""" - - def __init__(self): - super().__init__() - self.call_count = 0 - self.items = None - self.topic = None - self.saga = None - self.reply_topic = None - self.status = None - - async def send( - self, - items: list[Model], - topic: str = None, - saga: str = None, - reply_topic: str = None, - status: CommandStatus = None, - **kwargs, - ) -> None: - """For testing purposes.""" - self.call_count += 1 - self.items = items - self.topic = topic - self.saga = saga - self.reply_topic = reply_topic - self.status = status - - async def fake_middleware(request: Request, inner: Callable) -> Optional[Response]: """For testing purposes.""" response = await inner(request) From f5a5d627402b2056b64f6ce6ea7d9c648c29558d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 16:10:43 +0100 Subject: [PATCH 23/24] ISSUE #? * Minor improvements. --- minos/networks/brokers/messages.py | 4 ++-- .../test_scheduling/test_schedulers.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/minos/networks/brokers/messages.py b/minos/networks/brokers/messages.py index 2b6122db..582ef87d 100644 --- a/minos/networks/brokers/messages.py +++ b/minos/networks/brokers/messages.py @@ -29,7 +29,7 @@ class Command(DeclarativeModel): topic: str data: Any - saga: UUID + saga: Optional[UUID] reply_topic: str user: Optional[UUID] @@ -39,7 +39,7 @@ class CommandReply(DeclarativeModel): topic: str data: Any - saga: UUID + saga: Optional[UUID] status: CommandStatus service_name: Optional[str] diff --git a/tests/test_networks/test_scheduling/test_schedulers.py b/tests/test_networks/test_scheduling/test_schedulers.py index 89e7f37b..1a1f0eae 100644 --- a/tests/test_networks/test_scheduling/test_schedulers.py +++ b/tests/test_networks/test_scheduling/test_schedulers.py @@ -3,6 +3,7 @@ import warnings from unittest.mock import ( AsyncMock, + MagicMock, call, patch, ) @@ -87,15 +88,15 @@ def test_fn(self) -> None: async def test_start(self) -> None: self.assertFalse(self.periodic.started) + run_mock = MagicMock() + self.periodic.run_forever = run_mock - with patch("asyncio.create_task", return_value="test") as mock_create: - with warnings.catch_warnings(): - warnings.simplefilter("ignore", RuntimeWarning) - await self.periodic.start() - self.assertEqual(1, mock_create.call_count) - self.assertEqual("run_forever", mock_create.call_args.args[0].__name__) - self.assertTrue(self.periodic.started) - self.assertEqual("test", self.periodic.task) + with patch("asyncio.create_task", return_value="test"): + await self.periodic.start() + + self.assertTrue(self.periodic.started) + self.assertEqual("test", self.periodic.task) + self.assertEqual(1, run_mock.call_count) async def test_stop(self) -> None: mock = AsyncMock() From 5d28488a3cc615a381ff1519cb6799b66268ca12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Garc=C3=ADa=20Prado?= Date: Mon, 15 Nov 2021 16:20:49 +0100 Subject: [PATCH 24/24] v0.2.0 --- HISTORY.md | 9 +++++++++ minos/networks/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index bee7c24b..91ac943c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -126,3 +126,12 @@ History * Add `REPLY_TOPIC_CONTEXT_VAR` and integrate with `DynamicHandlerPool`. * Add support for `post_fn` callbacks following the same strategy as in `pre_fn` callbacks. + +0.2.0 (2021-11-15) +------------------ + +* Remove dependency to `minos-microservice-aggregate` (now `minos.aggregate` package will require `minos.networks`). +* Add support for middleware functions. +* Add support variable number of services (previously only `CommandService` and `QueryService` were allowed). +* Migrate `Command`, `CommandReply`, `CommandStatus` and `Event` from `minos.common` to `minos.networks`. +* Add support for `minos-microservice-common=^0.3.0` diff --git a/minos/networks/__init__.py b/minos/networks/__init__.py index d50df8b6..8d61aa97 100644 --- a/minos/networks/__init__.py +++ b/minos/networks/__init__.py @@ -1,6 +1,6 @@ __author__ = """Clariteia Devs""" __email__ = "devs@clariteia.com" -__version__ = "0.1.1" +__version__ = "0.2.0" from .brokers import ( REPLY_TOPIC_CONTEXT_VAR, diff --git a/pyproject.toml b/pyproject.toml index 789ec253..24804ea3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "minos_microservice_networks" -version = "0.1.1" +version = "0.2.0" description = "Python Package with the common network classes and utilities used in Minos Microservice." readme = "README.md" repository = "https://github.com/clariteia/minos_microservice_network"