Skip to content

Commit fe1259a

Browse files
CodingAnarchyclaude
andcommitted
Release v0.5.0: Comprehensive rate limiting and throttling system
- Add comprehensive rate limiting system with RateLimit, ThrottleConfig, and TokenBucket - Implement worker-level rate limiting with configurable burst support - Add queue-level throttling configuration with error backoff - Provide both blocking and non-blocking token acquisition methods - Integrate rate limiting into job processing loop with intelligent waiting - Add 17 comprehensive tests covering all rate limiting functionality - Update PostgreSQL example to demonstrate rate limiting usage - Extend DatabaseQueue trait with throttling configuration methods - Maintain full backward compatibility with existing deployments 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a6cf981 commit fe1259a

File tree

9 files changed

+1212
-6
lines changed

9 files changed

+1212
-6
lines changed

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,63 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.0] - 2025-06-26
9+
10+
### Added
11+
- **🚀 Comprehensive Rate Limiting & Throttling System**
12+
- `RateLimit` struct with flexible time windows: `per_second()`, `per_minute()`, `per_hour()`
13+
- Configurable burst limits with `with_burst_limit()` for handling traffic spikes
14+
- Token bucket algorithm implementation for efficient and precise rate limiting
15+
- `RateLimiter` with both blocking (`acquire()`) and non-blocking (`try_acquire()`) token acquisition
16+
17+
- **⚖️ Advanced Worker Rate Limiting**
18+
- Worker-level rate limiting with `with_rate_limit()` configuration method
19+
- `with_throttle_config()` for advanced throttling with error backoff
20+
- Automatic rate limit enforcement in job processing loop
21+
- Configurable backoff periods when rate limits are exceeded or errors occur
22+
23+
- **🎛️ Queue-Level Throttling Configuration**
24+
- `ThrottleConfig` for queue-specific throttling policies
25+
- Maximum concurrent job limits per queue
26+
- Rate limiting with automatic conversion from throttle configs
27+
- Error backoff configuration for resilient job processing
28+
- In-memory throttling configuration storage with async access
29+
30+
- **🔧 Production-Ready Features**
31+
- Token availability monitoring for operational visibility
32+
- Rate limiter cloning for shared rate limits across workers
33+
- Integration with existing timeout and statistics systems
34+
- Graceful handling of rate limit exhaustion with intelligent waiting
35+
36+
- **🧪 Comprehensive Testing Suite**
37+
- 17 rate limiting specific unit tests covering all functionality
38+
- Token bucket algorithm validation and edge case testing
39+
- Rate limiter integration tests with async behavior verification
40+
- Worker integration tests ensuring seamless rate limiting integration
41+
- Performance and timing validation for production reliability
42+
43+
- **📖 Enhanced Documentation and Examples**
44+
- Updated PostgreSQL example demonstrating worker and queue-level rate limiting
45+
- Rate limiting configuration examples with realistic scenarios
46+
- Throttling configuration with burst support and error handling
47+
- Statistics integration showing rate limiting effects in monitoring
48+
49+
### Enhanced
50+
- Extended `DatabaseQueue` trait with throttling configuration methods
51+
- Enhanced worker error handling with configurable backoff periods
52+
- Updated package exports to include all rate limiting types
53+
- Improved example documentation with rate limiting best practices
54+
55+
### Technical Implementation
56+
- **Token Bucket Algorithm**: Efficient rate limiting with configurable capacity and refill rates
57+
- **Async-First Design**: Non-blocking rate limiting with `tokio::time::timeout` integration
58+
- **Memory Efficient**: Shared rate limiters with `Arc<Mutex<TokenBucket>>` for concurrent access
59+
- **Error Resilience**: Graceful degradation when rate limiters encounter errors
60+
- **Backward Compatibility**: All existing functionality preserved, rate limiting is opt-in
61+
62+
### Breaking Changes
63+
- None - all changes are backward compatible with existing deployments
64+
865
## [0.4.0] - 2025-06-26
966

1067
### Added

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rand = "0.8"
2525

2626
[package]
2727
name = "hammerwork"
28-
version = "0.4.0"
28+
version = "0.5.0"
2929
edition = "2021"
3030
description = "A high-performance, database-driven job queue for Rust with PostgreSQL and MySQL support, featuring job prioritization, cron scheduling, timeouts, dead job management, and comprehensive statistics collection"
3131
license = "MIT"

0 commit comments

Comments
 (0)