Stabilize rate limiter tests by using dependency injection

This commit is contained in:
Claudio Ortolina
2026-03-16 11:21:24 +00:00
parent 4a2b7f4e03
commit 028f111300
5 changed files with 141 additions and 67 deletions
+13
View File
@@ -0,0 +1,13 @@
defmodule Req.RateLimiter.SystemClock do
@moduledoc """
Real clock implementation using `System.monotonic_time/1` and `Process.sleep/1`.
"""
@behaviour Req.RateLimiter.Clock
@impl true
def now, do: System.monotonic_time(:millisecond)
@impl true
def sleep(ms), do: Process.sleep(ms)
end