Packages

An Elixir library for real-time state sync and delta tracking, with ETS, Redis, and periodic cleanup support.

Current section

Files

Jump to
chord lib chord utils time behaviour.ex
Raw

lib/chord/utils/time/behaviour.ex

defmodule Chord.Utils.Time.Behaviour do
@moduledoc """
Defines the behavior for time utilities used by the library.
This behavior allows developers to implement custom time providers,
making it easier to handle time-based operations (e.g., cleanup) and mock
time in tests.
## Example
defmodule MyCustomTimeProvider do
@behaviour Chord.Utils.Time.Behaviour
@impl true
def current_time(:second) do
# Custom logic for returning current time
DateTime.utc_now() |> DateTime.to_unix(:second)
end
@impl true
def current_time(:millisecond) do
# Custom logic for millisecond precision
DateTime.utc_now() |> DateTime.to_unix(:millisecond)
end
end
"""
@callback current_time(:second | :millisecond) :: integer()
end