Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #10. Update README.md #11

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# RocksQ

An inproc RocksDB-based queue with Python bindings. It is implemented in Rust.
An inproc RocksDB-based queues with Python bindings.

Features:
The library is implemented in Rust and PyO3, which allows to release GIL when necessary. The library does not require
external dependencies to be installed in the environment.

## Persistent queue

A persistent queue with following features:

- max capacity limit in number of elements;
- size calculation based on filesystem space usage;
Expand All @@ -17,19 +22,54 @@ What is not supported:
- pub/sub is not supported intentionally (implement it on top of RocksQ if necessary);
- TTL is not supported intentionally (implement it on top of RocksQ if necessary).

## Implementation details
### Implementation details

It works on RocksDB and uses a single column family. The keys are 64-bit integers, the values are byte arrays. The keys
are generated by incrementing a counter. The read and write counters are stored in a separate key-value pairs.

## MPMC queue

A persistent queue with following features:

It works on RocksDB and uses a single column family. The keys are 64-bit integers, the values are byte arrays. The keys are generated by incrementing a counter. The read and write counters are stored in a separate key-value pairs.
- TTL in seconds;
- multiple consumers marked with labels;
- size calculation based on filesystem space usage;
- length calculation based on number of elements;
- supports only bytes-like objects;
- can operate in a multithreaded environment efficiently (add and next methods can release GIL if necessary);
- keeps the state between restarts;
- two implementations: blocking and nonblocking;

It is implemented in Rust and PyO3, thus allows to release GIL when necessary. The library does not require external dependencies installed in the environment.
### Implementation details

It works on RocksDB and uses three column families:

- data

Stores queue elements. The keys are 64-bit integers, the values are byte arrays. The keys are generated by
incrementing a counter.

- system

Stores a system information like start and write counters, a timestamp of the last write.

- reader

Stores an information about consumers like read counters, expiration of elements after last reading. The keys are
string labels of consumers, the values are binary serialized objects.

TTL is implemented via [RocksDB TTL feature](https://github.com/facebook/rocksdb/wiki/Time-to-Live). TTL is not strict.
It means that the element will remain in the queue for TTL seconds after insertion and the queue will make efforts to
remove the element after TTL seconds but it is not guaranteed to be done immediately. Thus, consumers can retrieve
expired but not removed elements.

## Supported Platforms and Python Versions

**Windows**: Python versions: 3.7-3.12.

**Linux**: ManyLinux Python versions: 3.7-3.12. CI does not build for PyPy, but it should work if you build it manually.

**MacOS**: Currently, I do not have MacOS environment to debug the build process in MacOS, all volounteers are welcome.
**MacOS**: Currently, I do not have MacOS environment to debug the build process in MacOS, all volunteers are welcome.

## Installation

Expand All @@ -45,5 +85,5 @@ API docs are located at: [https://insight-platform.github.io/RocksQ/](https://in

## Performance

The performance is mostly limited by the throughput of the underlying filesystem. The queue is able to saturate the throughput of the filesystem.

The performance is mostly limited by the throughput of the underlying filesystem. The queue is able to saturate the
throughput of the filesystem.
8 changes: 4 additions & 4 deletions queue_py/src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ impl PersistentQueueWithCapacity {
/// path : str
/// The path to the queue.
/// ttl : int
/// The amount of seconds after which the element in the queue will be removed. Ttl is non-strict
/// meaning that it is guaranteed that the element inserted will remain in the queue for at least
/// ttl amount of time and the queue will make efforts to remove the element as soon as possible
/// after ttl seconds of its insertion.
/// The amount of seconds after which the element in the queue will be removed. TTL is not strict.
/// It means that the element will remain in the queue for TTL seconds after insertion and the
/// queue will make efforts to remove the element after TTL seconds but it is not guaranteed to be
/// done immediately. Thus, consumers can retrieve expired but not removed elements.
///
/// Raises
/// ------
Expand Down
8 changes: 4 additions & 4 deletions queue_py/src/nonblocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ impl MpmcResponse {
/// path : str
/// The path to the queue.
/// ttl : int
/// The amount of seconds after which the element in the queue will be removed. Ttl is non-strict
/// meaning that it is guaranteed that the element inserted will remain in the queue for at least
/// ttl amount of time and the queue will make efforts to remove the element as soon as possible
/// after ttl seconds of its insertion.
/// The amount of seconds after which the element in the queue will be removed. TTL is not strict.
/// It means that the element will remain in the queue for TTL seconds after insertion and the
/// queue will make efforts to remove the element after TTL seconds but it is not guaranteed to be
/// done immediately. Thus, consumers can retrieve expired but not removed elements.
/// max_inflight_ops : int
/// The maximum number of inflight operations. If the number of inflight operations reached its limit,
/// further ops are blocked until the capacity is available. Default to ``1_000``.
Expand Down