Skip to content

Commit

Permalink
New BrokerRouter including logic (close #91), update annotations, ref…
Browse files Browse the repository at this point in the history
…actor BrokerUsecase to compatible with sync inherit (#88)
  • Loading branch information
Lancetnik committed Jun 30, 2023
1 parent 35f6acd commit d187cf2
Show file tree
Hide file tree
Showing 59 changed files with 880 additions and 489 deletions.
2 changes: 1 addition & 1 deletion docs/docs/en/contributing/4_adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this section, we will deal with the details of the implementation of brokers

## Parent class

All brokers **Propan** are inherited from the parent class `propan.brokers.model.BrokerUsecase`.
All brokers **Propan** are inherited from the parent class `propan.brokers.model.BrokerAsyncUsecase`.

In order to create a broker, it is necessary to inherit from this class and implement all its abstract methods.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/ru/contributing/4_adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Родительский класс

Все брокеры **Propan** наследуются от родительского класса `propan.brokers.model.BrokerUsecase`.
Все брокеры **Propan** наследуются от родительского класса `propan.brokers.model.BrokerAsyncUsecase`.

Для того, чтобы создания полноценного брокера необходимо отнаследоваться от этого класса и реализовать все его абстрактные методы.

Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/parent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Callable, Optional, TypeVar

from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase
from propan.brokers._model.schemas import PropanMessage
from propan.brokers.push_back_watcher import BaseWatcher
from propan.types import HandlerWrapper, SendableMessage
Expand All @@ -9,7 +9,7 @@
T = TypeVar("T")


class MyBroker(BrokerUsecase):
class MyBroker(BrokerAsyncUsecase):
async def _connect(self, *args: Any, **kwargs: Any) -> Any:
pass

Expand Down
2 changes: 1 addition & 1 deletion docs/docs_src/contributing/adapter/rabbit_close.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
...

async def close(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/rabbit_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


import aio_pika
from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase

class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
_connection: Optional[aio_pika.RobustConnection]
_channel: Optional[aio_pika.RobustChannel]

Expand Down
2 changes: 1 addition & 1 deletion docs/docs_src/contributing/adapter/rabbit_fmt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
__max_exchange_len: int
__max_queue_len: int

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
def _get_log_context(
self,
message: Optional[PropanMessage],
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/rabbit_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List, Union, Optional

from propan.types import HandlerWrapper, HandlerCallable
from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase
from propan.brokers._model.schemas import BaseHandler
from propan.brokers.rabbit import RabbitExchange, RabbitQueue

Expand All @@ -13,7 +13,7 @@ class Handler(BaseHandler):
exchange: Optional[RabbitExchange] = None


class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
handlers: List[Handler]

def handle(
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/rabbit_init.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any, Optional

from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase


class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
def __init__(
self,
*args: Any,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/rabbit_parse.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import aio_pika

from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase
from propan.brokers._model.schemas import PropanMessage


class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
...
@staticmethod
async def _parse_message(
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/rabbit_process.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from functools import wraps
from typing import Optional, TypeVar, Callable

from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase
from propan.brokers._model.schemas import PropanMessage
from propan.brokers.push_back_watcher import BaseWatcher, WatcherContext

T = TypeVar("T")

class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
...
def _process_message(
self, func: Callable[[PropanMessage], T], watcher: Optional[BaseWatcher]
Expand Down
2 changes: 1 addition & 1 deletion docs/docs_src/contributing/adapter/rabbit_start.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RabbitBroker(BrokerUsecase):
class RabbitBroker(BrokerAsyncUsecase):
...
async def start(self) -> None:
await super().start()
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/redis_process.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from functools import wraps
from typing import Optional, TypeVar, Callable

from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase
from propan.brokers._model.schemas import PropanMessage
from propan.brokers.push_back_watcher import BaseWatcher

T = TypeVar("T")

class RedisProcess(BrokerUsecase):
class RedisProcess(BrokerAsyncUsecase):
...
def _process_message(
self,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/redis_publish.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional, Dict, Any

from propan.types import SendableMessage
from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase
from propan.brokers.redis.schemas import RedisMessage


class RedisProcess(BrokerUsecase):
class RedisProcess(BrokerAsyncUsecase):
...
async def publish(
self,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs_src/contributing/adapter/redis_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from redis.asyncio.client import PubSub, Redis

from propan.brokers._model import BrokerUsecase
from propan.brokers._model import BrokerAsyncUsecase
from propan.brokers._model.schemas import BaseHandler


Expand All @@ -17,7 +17,7 @@ class Handler(BaseHandler):
subscription: Optional[PubSub] = None


class RedisBroker(BrokerUsecase):
class RedisBroker(BrokerAsyncUsecase):
handlers: List[Handler]
_connection: Redis

Expand Down
2 changes: 1 addition & 1 deletion propan/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from unittest.mock import Mock

__version__ = "0.1.4.3"
__version__ = "0.1.4.4"


INSTALL_MESSAGE = (
Expand Down
4 changes: 2 additions & 2 deletions propan/brokers/_model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from propan.brokers._model.broker_usecase import BrokerUsecase
from propan.brokers._model.broker_usecase import BrokerAsyncUsecase
from propan.brokers._model.routing import BrokerRouter
from propan.brokers._model.schemas import PropanMessage, Queue
from propan.brokers._model.utils import ContentTypes

__all__ = (
"Queue",
"BrokerUsecase",
"BrokerAsyncUsecase",
"ContentTypes",
"PropanMessage",
"BrokerRouter",
Expand Down
Loading

0 comments on commit d187cf2

Please sign in to comment.