Read-only schema for PGMQ queue notification throttles.
For more information about notifications, see Notifications.
Summary
Types
@type t() :: %EctoPGMQ.Throttle{ interval: Duration.t(), last_notified_at: DateTime.t() | nil, queue: EctoPGMQ.Queue.name() }
A PGMQ queue notification throttle.
Functions
@spec query() :: Ecto.Query.t()
Returns a query for notification throttles.
Notification throttles are fetched transparently when querying queues via
EctoPGMQ.Queue.query/0.
Interval Filtering
This schema uses a custom Ecto.Type to load the throttle interval into a
Duration.t/0. This custom type can cast both Duration.t/0 structs and
non_neg_integer/0 times (in milliseconds):
# Casting a Duration struct
where(Throttle.query(), [t], t.interval >= ^Duration.new!(hour: 1))
# Casting an integer time
where(Throttle.query(), [t], t.interval <= 250)Examples
iex> [%Throttle{} | _] = Repo.all(Throttle.query())