Skip to content

Commit

Permalink
[BUG FIX] Fixing Async Consumer Logic to work based on SelectConnecti…
Browse files Browse the repository at this point in the history
…on (#100)

* moved `create_connection` as a separate function in `AsyncConsumer`

* Improved aio handling

* Removed non-working tests and added pika-based Async Consumer

* Small improvements to handle failure scenarious

* tmp commit

* small fix

* Updated codebase to fully test SelectConsumerThread

* small fix

* Removed parameterized from test_connector.py

* Fixed tests and restored logic to pre-aio state

* small fix

* Added license notices

---------

Co-authored-by: NeonKirill <kirill.grim@gmail.com>
  • Loading branch information
NeonKirill and kirgrim authored Dec 3, 2024
1 parent e629a59 commit ef96424
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 398 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[aio] -r requirements/test_requirements.txt
pip install . -r requirements/test_requirements.txt
- name: Run Utils Tests
run: |
pytest tests/test_utils.py --doctest-modules --junitxml=tests/utils-test-results.xml
Expand Down
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,11 @@ Where `<queue>` is the queue to which the response will be published, and `data`

### [BETA] Asynchronous Consumers

Now there is a support for async-based consumers handling based on `aio-pika` API.

#### Installation

To install async dependencies, run installation with `[aio]` extra:
```shell
pip install neon-mq-connector[aio]
```
Now there is a support for async-based consumers handling based on `pika.SelectConnection`

#### Enabling in a code

When declaring the consumer/subscriber instances, specify `async_consumer` param like follows:
```python
register_consumer(name="some_consumer",
...
async_consumer=True,)
register_subscriber(name="some_subscriber",
...
async_consumer=True,)
```

To set creation of async consumers/subscribers globally, set the class-attribute `async_consumers_enabled` to True:
To enable creation of async consumers/subscribers, set the class-attribute `async_consumers_enabled` to True:

```python
from neon_mq_connector import MQConnector
Expand Down
Empty file removed neon_mq_connector/aio/__init__.py
Empty file.
106 changes: 0 additions & 106 deletions neon_mq_connector/aio/consumer.py

This file was deleted.

Loading

0 comments on commit ef96424

Please sign in to comment.