Allocation lifetime and refresh deadline helpers.
What problem this solves
TURN allocations, permissions, and channels expire unless refreshed. GenServer
:timeout values must not jump when the system clock changes, so expiry uses
monotonic deadlines. Legacy reporting still uses Gregorian seconds from
:calendar where older state fields require it.
RFCs
- RFC 5766 (LIFETIME and Refresh)
Summary
Functions
Computes a monotonic deadline in milliseconds from a lifetime in seconds.
Returns the current local {date, time} tuple from :calendar.
Returns remaining milliseconds until expiry, or zero when already expired.
Returns remaining milliseconds from allocation start time and lifetime (Gregorian seconds).
Returns the current local time as Gregorian seconds since year zero.
Functions
Computes a monotonic deadline in milliseconds from a lifetime in seconds.
Parameters
lifetime_seconds- allocation or permission lifetime in whole seconds
Examples
iex> deadline = Xirsys.XTurn.Timing.deadline_ms(10)
iex> is_integer(deadline)
true
iex> deadline > System.monotonic_time(:millisecond)
true
Returns the current local {date, time} tuple from :calendar.
Returns remaining milliseconds until expiry, or zero when already expired.
Accepts a monotonic deadline, a map with :deadline_ms, a map with
:refresh_time and :lifetime, or a (start_time, lifetime) pair.
Returns remaining milliseconds from allocation start time and lifetime (Gregorian seconds).
Returns the current local time as Gregorian seconds since year zero.