Added BiddingRoundServer "CurrentRoundServer" with a facade to control it. "Listing Biddings" page shows information which round is currently running.

This commit is contained in:
2026-02-12 12:23:21 +01:00
parent 04c79d341c
commit 6eea9d2fba
5 changed files with 240 additions and 10 deletions

View File

@ -0,0 +1,39 @@
defmodule BeetRoundServer.BiddingRounds.BiddingRoundServer do
use GenServer
def inc(pid), do: GenServer.cast(pid, :inc)
def dec(pid), do: GenServer.cast(pid, :dec)
def val(pid) do
GenServer.call(pid, :val)
end
def stop(pid) do
GenServer.stop(pid)
end
def start(initial_val) do
GenServer.start(__MODULE__, initial_val, name: CurrentRoundServer)
end
def init(initial_val) do
{:ok, initial_val}
end
def terminate(_reason, val) do
IO.puts("Stopping bidding round:")
IO.puts(val)
:ok
end
def handle_cast(:inc, val) do
{:noreply, val + 1}
end
def handle_cast(:dec, val) do
{:noreply, val - 1}
end
def handle_call(:val, _from, val) do
{:reply, val, val}
end
end