17 releases

new 0.10.0 Feb 13, 2025
0.9.4 Oct 23, 2024
0.9.3 Jul 10, 2024
0.9.1 Nov 4, 2023
0.6.0 Jul 21, 2023

#255 in Asynchronous

Download history 20/week @ 2024-10-26 7/week @ 2024-11-30 3/week @ 2024-12-07 107/week @ 2025-01-18 15/week @ 2025-01-25 4/week @ 2025-02-01 80/week @ 2025-02-08

208 downloads per month

MIT license

15KB
107 lines

Taskline

Crates.io CI Docs.rs

Taskline is a Rust library for scheduling tasks via Redis.

Overview

Taskline provides a simple way to schedule and process tasks asynchronously. It follows a producer-consumer model, where a producer schedules tasks to be executed at a specific time, and a consumer retrieves and processes them.

Use Cases

Taskline is ideal for applications that require deferred execution, such as:

  • Scheduling emails to be sent at a later time.
  • Sending notifications to users at a specific moment.
  • Any background job that needs time-based execution.

Features

  • Send/receive tasks in Redis
  • Delayed tasks
  • Deleting from a storage after handling
  • Support Redis Cluster
  • Metrics

Requirements

  • Redis 6.2.0 or higher

Installation

Cargo

cargo add taskline

Task Auto-Deletion

Default Behavior

By default, Taskline automatically deletes tasks from storage after they are processed. This is the recommended approach for most use cases, as it ensures tasks are not executed multiple read.

Disabling Auto-Deletion

If you prefer to manually manage task deletion, you can disable auto-delete by setting autodelete=false. However, this should only be used with a single consumer to avoid duplicate processing. If multiple consumers are involved, consider using a distributed lock mechanism like redlock. For more details, see Distributed Locks with Redis.

To manually remove a processed task, use: Taskline::delete.

Recommendation

If your use case allows, it is recommended to keep autodelete=true, as it simplifies task management and reduces configuration overhead. However, be aware that in the event of an application crash, tasks may be lost before they are processed.

License

Contribution

CONTRIBUTING.md

Dependencies

~7–16MB
~202K SLoC