Skip to content

Commit 1b25d35

Browse files
Add CLAUDE.md for Claude Code guidance
1 parent fcd3f22 commit 1b25d35

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

CLAUDE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
- **Install dependencies**: `bundle install`
8+
- **Run tests**: `rake test` or `rake`
9+
- **Build gem**: `rake build`
10+
- **Release gem**: `rake release`
11+
- **Generate documentation**: `rake rdoc`
12+
13+
## Architecture
14+
15+
This is a Ruby gem that adds rate limiting capabilities to Resque queues. The implementation works by:
16+
17+
1. **Core Module**: `Resque::Plugins::Throttler` in `/lib/resque/throttler.rb` contains all functionality
18+
2. **Rate Limit Configuration**: Users set limits via `Resque.rate_limit(:queue_name, at: count, per: seconds)`
19+
3. **Enforcement Mechanism**: Overrides `Resque::Worker#reserve` to check rate limits before allowing job reservation
20+
4. **Redis-based Tracking**: Uses Redis counters with expiration for tracking job counts and distributed locks for thread safety
21+
22+
Key implementation details:
23+
- Rate limit counters use Redis key: `throttler:rate_limit:{queue_name}`
24+
- Distributed locks use Redis key: `throttler:lock:{queue_name}` with 30-second expiration
25+
- Workers skip rate-limited queues rather than blocking
26+
- All logic is contained in a single file for simplicity
27+
28+
## Testing
29+
30+
The project uses Minitest with Mocha for mocking. Note that some test files (particularly `/test/resque_test.rb` and `/test/resque/job_test.rb`) appear to be from an older implementation and may not reflect the current code structure.
31+
32+
## Development Guidelines
33+
34+
- The gem follows standard Ruby gem conventions
35+
- Runtime dependency: resque > 1.25
36+
- All core functionality is in `/lib/resque/throttler.rb`
37+
- Keep the implementation simple - the entire gem is designed to do one thing well

0 commit comments

Comments
 (0)