Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
amenezes committed Oct 24, 2023
1 parent b583eda commit 41c7d78
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 27 deletions.
24 changes: 12 additions & 12 deletions docs/error_strategies.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
## Delay strategies

- [scheduling messages](https://blog.rabbitmq.com/posts/2015/04/scheduling-messages-with-rabbitmq)
- [Scheduling Messages with RabbitMQ](https://blog.rabbitmq.com/posts/2015/04/scheduling-messages-with-rabbitmq)

### expo

Exponential backoff time, inspired in the great library [backoff](https://github.com/litl/backoff).

By default a cycle with 3 iteractions will produces:

```txt
1. 600000 # 10 minutes
2. 1200000 # 20 minutes
3. 2400000 # 40 minutes
```txt linenums="1"
600000 # 10 minutes
1200000 # 20 minutes
2400000 # 40 minutes
```

#### configuration

```ini
```ini linenums="1"
# delay
EXPO_DELAY=300000

Expand All @@ -36,7 +36,7 @@ Incremental delay by minute.

By default a cycle with 3 iteractions will produces:

```txt
```txt linenums="1"
1. 360000 # 6 minutes
2. 420000 # 7 minutes
3. 480000 # 8 minutes
Expand All @@ -58,10 +58,10 @@ Constant time.

By default a cycle with 3 iteractions will produces:

```txt
1. 300000 # 5 minutes
2. 300000 # 5 minutes
3. 300000 # 5 minutes
```txt linenums="1"
300000 # 5 minutes
300000 # 5 minutes
300000 # 5 minutes
```

> **constant** strategy it's the default option for Subscribe.
Expand All @@ -74,7 +74,7 @@ CONSTANT_DELAY=300000

## Usage

```python
```py linenums="1" title="error-strategy-example.py"
import asyncio
from rabbit import AioRabbitClient, Subscribe, fibo
from rabbit.job import async_echo_job
Expand Down
4 changes: 2 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ The `Subscribe` class use a `task` that's nothing more that an awaitable. This w

A DLQ will assist you to dosen't lost an event that fail for some reason. So if somehow the task fails, raising any kind of exception, the event will be sent to DLQ and after some delay defined by `rabbit-client` strategy it will be back in the main queue so that the application can try to process it again.

- [when and how to use rabbitmq dlx](https://www.cloudamqp.com/blog/when-and-how-to-use-the-rabbitmq-dead-letter-exchange.html)
- [When and how to use the RabbitMQ Dead Letter Exchange](https://www.cloudamqp.com/blog/when-and-how-to-use-the-rabbitmq-dead-letter-exchange.html)

## **How optimize concurrent jobs?**

Just increase the value of `concurrent` attribute in the Subscribe.

However if the job consists in [CPU bound](https://en.wikipedia.org/wiki/CPU-bound) or long running tasks workloads it's a good choice decrease the value.

- [prefetch count](https://www.cloudamqp.com/blog/how-to-optimize-the-rabbitmq-prefetch-count.html)
- [How to Optimize the RabbitMQ Prefetch Count](https://www.cloudamqp.com/blog/how-to-optimize-the-rabbitmq-prefetch-count.html)


## **Why use publisher-confirms?**
Expand Down
2 changes: 1 addition & 1 deletion docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The main values expected to configure `rabbit-client` can be set via environment

### Default values

```.env
```.env title="Default values for environment variables"
# publisher - send_event method
PUBLISH_EXCHANGE_NAME=default.in.exchange
PUBLISH_ROUTING_KEY=#
Expand Down
9 changes: 4 additions & 5 deletions docs/polling-publisher.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Polling Publisher

> From the version 1.x this feature is supported out-of-box.
!!! info ""
From the version 1.x this feature is supported out-of-box.

![rabbit-client-workflow-polling](./rabbit-client-workflow-polling.png)

## Pattern

> [https://microservices.io/patterns/data/polling-publisher.html](https://microservices.io/patterns/data/polling-publisher.html)
## Usage Example
## Usage example

### Subscribe & Polling Publisher

```python
``` py linenums="1" title="subscribe-polling-publisher.py"
import asyncio
import logging

Expand Down
12 changes: 7 additions & 5 deletions docs/publish-subscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

## Usage Example

All code examples can be used in the python asyncio REPL: `python -m asyncio` available on python >= 3.8.
!!! info ""

All code examples can be used in the python asyncio REPL, for this use: `python -m asyncio` available on python >= 3.8.

#### Consumer

```python
```py linenums="1" title="consumer-example.py"
import logging

from rabbit import AioRabbitClient, Subscribe
Expand All @@ -29,15 +31,15 @@ await client.register(subscribe)

### Publisher

#### CLI example
#### CLI

```bash
python -m rabbit send-event data.json
```

#### Code example
#### Code

```python
``` py linenums="1" title="publisher-example.py"
import logging

from rabbit import AioRabbitClient, Publish
Expand Down
19 changes: 17 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ theme:
logo: bunny.png
favicon: bunny.png
features:
- toc.integrate
- toc.follow
- navigation.instant
- navigation.top
- navigation.prune
- toc.integrate
- search.highlight
- search.suggest
- search.share
- content.code.annotate
- content.tooltips
- toc.follow
- content.code.copy
palette:
- scheme: default
primary: deep orange
Expand All @@ -39,6 +40,20 @@ extra:
link: https://github.com/amenezes/rabbit-client/issues
- icon: fontawesome/solid/envelope
link: mailto:alexandre.fmenezes@gmail.com
markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
- tables
- attr_list
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
nav:
- Overview: overview.md
- Publish Subscribe: publish-subscribe.md
Expand Down

0 comments on commit 41c7d78

Please sign in to comment.