Skip to content

seuros/throttle_machines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

36 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ThrottleMachines ๐Ÿš€

Ultra-thin rate limiting for the cosmos - Where every request has its own trajectory through spacetime

A precision-engineered Ruby rate limiting library built for interstellar traffic control. Whether you're throttling API calls, AI requests, or quantum communications, ThrottleMachines ensures your systems maintain perfect orbital stability.


๐ŸŒŒ Navigation


๐Ÿš€ Launch Sequence

# Add to your ship's Gemfile
gem 'throttle_machines'

# For warp drive capabilities (Redis storage)
gem 'redis'

# For planetary Rails integration
gem 'rails' # or just railties

# For fiber-safe async throttling
gem 'async'

Then initialize systems:

bundle install

๐ŸŽฏ Quick Mission Brief

Basic Throttling - The Photon Torpedo Approach

# Simple rate limiting - like controlling photon torpedo launches
torpedo_limiter = ThrottleMachines.limiter("photon_launcher",
  limit: 10,     # 10 torpedoes
  period: 60     # per minute
)

# Check and consume approach
if torpedo_limiter.allow?
  torpedo_limiter.throttle!  # Consume one torpedo charge
  launch_torpedo!
else
  puts "Torpedo bay recharging... Please wait."
end

# OR use the exception approach
begin
  torpedo_limiter.throttle!
  launch_torpedo!
rescue ThrottleMachines::ThrottledError => e
  puts "Torpedo bay recharging... Retry after #{e.limiter.retry_after} seconds"
end

GCRA - The Federation Diplomatic Ship ๐Ÿ›ธ

# GCRA: Like a diplomatic vessel that smoothly navigates traffic
# Instead of sudden stops, it gracefully manages flow
diplomatic_limiter = ThrottleMachines.limiter("federation_embassy",
  limit: 100,
  period: 60,
  algorithm: :gcra  # Generic Cell Rate Algorithm
)

# GCRA ensures smooth traffic - no thundering herds at your space dock!

Block Form - Fire and Forget ๐ŸŽฏ

# Use the block form for automatic throttling
# This handles the throttle! and error handling for you
ThrottleMachines.limit("warp_drive", limit: 5, period: 60) do
  engage_warp_drive!  # This will be throttled automatically
end
# Raises ThrottledError if limit exceeded

๐ŸŒ  The Ultra-Thin Philosophy

Like the best spacecraft, ThrottleMachines follows the principle of ultra-thin design:

  • No bloat - Every component serves a critical function
  • No dependencies - Operates in deep space without supply lines
  • Pure Ruby propulsion - No alien technology required
  • Modular systems - Swap components like ship modules

โšก Warp Factor Features

  • ๐Ÿš€ Multiple Algorithms - GCRA, Token Bucket, Fixed Window, Sliding Window
  • ๐Ÿ’ซ Distributed Ready - Redis backend for fleet coordination
  • ๐Ÿ”„ Async Support - Fiber-safe operations for quantum communications
  • ๐Ÿƒ Hedged Requests - Multi-path navigation for reduced latency
  • ๐ŸŽฏ Microsecond Precision - Navigate the cosmos with temporal accuracy
  • ๐Ÿ”Œ Pluggable Storage - Memory crystals or Redis quantum storage
  • ๐ŸŒ Rails Integration - Seamless planetary docking procedures
  • ๐Ÿ“ก Rack Middleware - Universal translator for all spacecraft
  • ๐Ÿ” Full Instrumentation - Real-time telemetry via ActiveSupport::Notifications
  • โšก Thread-Safe - Safe for multi-threaded spacecraft operations
  • ๐ŸŽญ Multiple Usage Patterns - Check-first, exception-based, or block form

๐ŸŒŒ Why ThrottleMachines?

In the vast expanse of cyberspace, your systems face:

  • Asteroid fields of concurrent requests
  • Black holes of resource exhaustion
  • Alien attacks from malicious actors
  • Temporal anomalies in distributed systems

ThrottleMachines is your navigation system through these dangers, ensuring safe passage for every request in your fleet.


๐Ÿ“œ Captain's Log

See our Mission Archives for the full history of our voyages.


๐Ÿค Join the Crew

  1. Signal your intent (fork the repository)
  2. Create your feature branch (git checkout -b feature/quantum-throttling)
  3. Document your modifications (git commit -am 'Add quantum entanglement support')
  4. Transmit to mothership (git push origin feature/quantum-throttling)
  5. Request docking clearance (Pull Request)

๐Ÿ“ก Distress Signals

Found a breach in the hull? Encountered an unknown anomaly?


๐ŸŽ–๏ธ Mission Credentials

MIT License - See LICENSE for full transmission.


A Message from the Temporal Defense Corps

The Quantum Navigation Computer flickers to life:

"Space is vast. Time is relative. And your API is getting hammered by a bot farm in Eastern Europe.

Welcome to the temporal wars, where milliseconds matter and rate limits are the thin line between order and chaos. You think you're just limiting requests? No, pilot. You're manipulating the very fabric of spacetime to ensure fair resource distribution across the quantum multiverse of your distributed system.

Every request has a trajectory. Every limit has a purpose. Every algorithm is a different spacecraft designed for a specific mission through the hostile void.

The universe doesn't care about your startup's runway or your clever blog post about 'Building a Rate Limiter in 5 Minutes with Redis.' It cares about one immutable law:

Can your system maintain temporal stability when the thundering herd arrives?

If not, welcome aboard. We have algorithms."

โ€” Quantum Navigation Computer, Log Entry โˆž


The Fleet Admiral's Warning

So you built a microservice architecture because a YouTube video told you it was 'web scale'?

Now you're drowning in a sea of uncontrolled requests, cascade failures, and that one service that keeps calling your API 10,000 times per second because someone forgot to implement exponential backoff.

This is your life raft. Don't let go.


"In space, nobody can hear your servers scream. But with ThrottleMachines, they won't need to."

โ€” Fleet Admiral J'Rao, Survivor of the Great DDoS Wars of 2019

About

Advanced rate limiting library for Ruby. Rate limit anything - API calls, AI requests, background jobs. Features GCRA, token bucket algorithms, circuit breakers, and multiple storage backends.

Topics

Resources

License

Stars

10 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors