1 unstable release
0.1.0 | Apr 25, 2025 |
---|
#500 in Concurrency
125 downloads per month
Used in ngtask_queue_basic
8KB
51 lines
NGTQ
NGTQ is a trait-based abstraction layer for task queues in Rust, enabling seamless switching between different task queue implementations without changing your application code.
Features
- Thread-safe task queue interface
- Support for both ID-based and category-based queues
- Standardized error handling
- Easily swappable queue implementations
Coming Soon
- Flash queues for ultra-high priority tasks
- Queue recovery mechanisms
- Async method support
- Additional utility helpers
Installation
Add NGTQ to your Cargo.toml
:
[dependencies]
ngtq = "0.1.0"
Application Patterns
NGTQ can be used in different architectural patterns:
- Message Bus/Service - Use NGTQ as the core domain of a dedicated message bus service that other services communicate with
- Monolithic Integration - Embed NGTQ directly in your monolithic application for internal task management
- Distributed Systems - Use NGTQ-compatible implementations to standardize task queuing across microservices
How It Works
NGTQ defines a trait that any task queue implementation must satisfy. This standardizes:
- Initialization - Creates a thread-safe instance of the queue
- Queue operations - Standard methods for pushing and pulling tasks
- Queue inspection - Methods to check queue sizes
- Error handling - Consistent error types and reporting
Compatible Implementations
*Coming soon
Why Use NGTQ?
- Decoupling: Your application logic remains separate from specific queue implementations
- Flexibility: Switch between different queue backends without changing application code
- Standardization: Consistent interface regardless of the underlying queue technology
- Thread safety: Built-in concurrency support with Arc<Mutex<>> pattern
Error Handling
NGTQ provides a standardized error type NGTQError
with categorized error types:
Initialisation
- Errors during queue setupIdQueue
- Errors related to ID-based queue operationsCategoryQueue
- Errors related to category-based queue operationsSerialisation
- Errors during data serialization/deserializationServerError
- Unexpected server or backend errors
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Dependencies
~0.3–0.9MB
~20K SLoC