tlq_client/
lib.rs

1//! # TLQ Rust Client
2//!
3//! A Rust client library for [TLQ (Tiny Little Queue)](https://github.com/skyak/tlq) - a minimal, in-memory message queue server.
4//!
5//! This library provides an async, type-safe interface for interacting with TLQ servers,
6//! featuring automatic retry with exponential backoff, comprehensive error handling,
7//! and a builder pattern for flexible configuration.
8//!
9//! ## Quick Start
10//!
11//! ```no_run
12//! use tlq_client::TlqClient;
13//!
14//! #[tokio::main]
15//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
16//!     // Create a client
17//!     let client = TlqClient::new("localhost", 1337)?;
18//!
19//!     // Add a message to the queue
20//!     let message = client.add_message("Hello, TLQ!").await?;
21//!     println!("Added message with ID: {}", message.id);
22//!
23//!     // Retrieve messages from the queue
24//!     let messages = client.get_messages(5).await?;
25//!     for msg in messages {
26//!         println!("Message: {} - {}", msg.id, msg.body);
27//!         
28//!         // Delete the message when done
29//!         client.delete_message(msg.id).await?;
30//!     }
31//!     
32//!     Ok(())
33//! }
34//! ```
35//!
36//! ## Features
37//!
38//! - **Async/await support** - Built on Tokio for high-performance async operations
39//! - **Automatic retry** - Exponential backoff for transient failures
40//! - **Type safety** - Strong typing with `serde` for JSON serialization
41//! - **Builder pattern** - Flexible configuration with [`ConfigBuilder`]
42//! - **Error handling** - Comprehensive error types with retryable classification
43//! - **Message validation** - Enforces 64KB message size limit
44//! - **UUID v7 IDs** - Time-ordered message identifiers
45//!
46//! ## Configuration
47//!
48//! Use [`ConfigBuilder`] for advanced configuration:
49//!
50//! ```no_run
51//! use tlq_client::{TlqClient, ConfigBuilder};
52//! use std::time::Duration;
53//!
54//! # async fn example() -> Result<(), tlq_client::TlqError> {
55//! let client = TlqClient::with_config(
56//!     ConfigBuilder::new()
57//!         .host("queue.example.com")
58//!         .port(8080)
59//!         .timeout(Duration::from_secs(10))
60//!         .max_retries(5)
61//!         .retry_delay(Duration::from_millis(200))
62//!         .build()
63//! );
64//! # Ok(())
65//! # }
66//! ```
67
68pub mod client;
69pub mod config;
70pub mod error;
71pub mod message;
72mod retry;
73
74pub use client::TlqClient;
75pub use config::{Config, ConfigBuilder};
76pub use error::{Result, TlqError};
77pub use message::{Message, MessageState};