Packages
agentsea_gateway
0.1.0
AgentSea gateway: strategy-based routing, circuit breaking, and failover across LLM providers.
Current section
Files
Jump to
Current section
Files
lib/agent_sea/gateway/router/round_robin.ex
defmodule AgentSea.Gateway.Router.RoundRobin do
@moduledoc "Rotates the candidate order by a counter so load spreads across providers."
@behaviour AgentSea.Gateway.Router
@impl true
def order([], _ctx), do: []
def order(candidates, ctx) do
offset = rem(Map.get(ctx, :counter, 0), length(candidates))
{head, tail} = Enum.split(candidates, offset)
tail ++ head
end
end