Skip to content

refactor: remove rate_limiter actor#26

Merged
nootr merged 1 commit intomainfrom
refactor/remove-rate-limiter-actor
Mar 5, 2026
Merged

refactor: remove rate_limiter actor#26
nootr merged 1 commit intomainfrom
refactor/remove-rate-limiter-actor

Conversation

@nootr
Copy link
Owner

@nootr nootr commented Mar 5, 2026

Summary

  • Remove the intermediate rate_limiter actor — in-memory hits now go directly to the memory_store actor (1 actor instead of 2), external store hits are plain function calls
  • Add glimit.hit() and glimit.set_now() to the public API
  • Add bucket.compute_ttl() for store adapter authors
  • Replace two Option fields with a StoreBackend sum type (MemoryBackend | ExternalBackend)
  • Builder API (glimit.new() |> glimit.per_second(10) |> ...) is unchanged

Test plan

  • gleam build succeeds
  • gleam test — 67 tests pass
  • gleam build in examples/redis succeeds
  • All tests from deleted glimit_rate_limiter_test.gleam merged into glimit_test.gleam

@nootr nootr force-pushed the refactor/remove-rate-limiter-actor branch 5 times, most recently from 69117a6 to aeed688 Compare March 5, 2026 10:33
Remove the rate_limiter actor and unify in-memory and external store
hit paths through a single Store interface. Store operations reduced
from 4 (get/set/lock/unlock) to 3 (lock_and_get/set_and_unlock/unlock).
In-memory mode uses no-op locks backed by the memory_store actor.
@nootr nootr force-pushed the refactor/remove-rate-limiter-actor branch from aeed688 to abeeb82 Compare March 5, 2026 10:47
@nootr nootr merged commit 9ab7249 into main Mar 5, 2026
5 checks passed
@nootr nootr deleted the refactor/remove-rate-limiter-actor branch March 5, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant