Crates.io | stream-consumer-task |
lib.rs | stream-consumer-task |
version | 0.1.0 |
source | src |
created_at | 2024-01-21 17:59:18.861736 |
updated_at | 2024-01-21 17:59:18.861736 |
description | Start asynchronous task in background to consume stream |
homepage | |
repository | https://github.com/leroyguillaume/stream-consumer-task |
max_upload_size | |
id | 1107777 |
size | 64,308 |
Start asynchronous task in background to consume stream.
It can be useful if your application consumes several RabbitMQ queues or Kafka Topics.
Add to your Cargo.toml
:
[dependencies]
...
stream-consumer-task = "0"
...
You can look examples to see how to use the library.
The task takes two arguments: a stream and an item handler.
Each time a new item is available in the stream, the consumer spawns a new task to handle it.
The item handler takes two arguments: the item from the stream and a Receiver<()>
to handle graceful shutdown.
If the consumer is stopped, a stop signal is sent to all tasks and it will wait them termination.
See CONTRIBUTING.md.