Mead.Deck.Tickets (mead v0.1.1)

Copy Markdown View Source

Single-use tickets that turn an authenticated POST /deck/ticket into one WebSocket upgrade.

A ticket is 128 random bits, URL-safe, and lives in a public named ETS table owned by this process. consume/2 is :ets.take/2, which is atomic, so two sockets presenting the same ticket at the same instant cannot both win. Expired tickets are refused on consume and swept periodically so abandoned ones do not accumulate. The ticket is a secret: it is never logged, and the server state is the table name only, so :sys.get_state/1 shows none.

Summary

Functions

Returns a specification to start this module under a supervisor.

How many tickets are held, expired ones included until the next sweep.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

consume(server \\ __MODULE__, ticket)

@spec consume(atom(), term()) :: {:ok, String.t()} | :error

issue(server \\ __MODULE__, session_id, time_to_live_ms)

@spec issue(atom(), String.t(), pos_integer()) :: String.t()

size(server \\ __MODULE__)

@spec size(atom()) :: non_neg_integer()

How many tickets are held, expired ones included until the next sweep.

start_link(options)