1
0
Fork 0
mirror of https://github.com/benbusby/farside.git synced 2025-05-04 17:40:02 +00:00

Reuse previous instance within rate-limit interval

Rather than blocking <1s back-to-back queries from the same IP, Farside
will now re-use the previously selected instance.

Fixes #20
This commit is contained in:
Ben Busby 2022-03-18 13:51:37 -06:00
parent 20347822da
commit 22e9135e0c
No known key found for this signature in database
GPG key ID: B9B7231E01D924A1
3 changed files with 20 additions and 11 deletions

View file

@ -40,7 +40,14 @@ defmodule Farside.Router do
get "/:service/*glob" do
path = Enum.join(glob, "/")
instance = Farside.pick_instance(service)
instance = cond do
conn.assigns[:throttle] != nil ->
Farside.last_instance(service)
true ->
Farside.pick_instance(service)
end
IO.inspect(get_req_header(conn, "throttle"))
IO.inspect(instance)
params =
cond do