Schema for PGMQ messages.
Summary
Types
A PGMQ message group.
PGMQ message headers.
A PGMQ message ID.
A PGMQ message payload.
A PGMQ message specification.
A PGMQ message.
Functions
Returns a query for the messages in the archive for the given queue.
Returns a query for the messages in the given queue.
Types
@type group() :: String.t()
A PGMQ message group.
For more information about FIFO message groups, see FIFO Message Groups.
@type headers() :: %{optional(String.Chars.t()) => term()}
PGMQ message headers.
@type id() :: pos_integer()
A PGMQ message ID.
@type payload() :: %{optional(String.Chars.t()) => term()}
A PGMQ message payload.
@type specification() :: payload() | {payload(), group() | nil} | {payload(), group() | nil, headers() | nil}
A PGMQ message specification.
Warning
If the group is not nil, it will override any group that may already be
specified in the headers.
@type t() :: %EctoPGMQ.Message{ archived_at: DateTime.t() | nil, enqueued_at: DateTime.t(), group: group() | nil, headers: headers() | nil, id: id(), payload: payload(), reads: non_neg_integer(), visible_at: DateTime.t() }
A PGMQ message.
Functions
@spec archive_query(EctoPGMQ.Queue.name()) :: Ecto.Query.t()
Returns a query for the messages in the archive for the given queue.
Examples
iex> message_ids = EctoPGMQ.send_messages(Repo, "my_queue", [%{"foo" => 1}, %{"bar" => 2}])
iex> EctoPGMQ.archive_messages(Repo, "my_queue", message_ids)
iex> messages = Repo.all(archive_query("my_queue"))
iex> Enum.all?(messages, &is_struct(&1, EctoPGMQ.Message))
true
@spec queue_query( EctoPGMQ.Queue.name(), keyword() ) :: Ecto.Query.t()
Returns a query for the messages in the given queue.
Options
:archived_at?- An optionalboolean/0denoting whether or not to select aNULL:archived_atcolumn. This can be used to make the query structure match that ofarchive_query/1. Defaults tofalse.
Examples
iex> EctoPGMQ.send_messages(Repo, "my_queue", [%{"foo" => 1}, %{"bar" => 2}])
iex> messages = Repo.all(queue_query("my_queue"))
iex> Enum.all?(messages, &is_struct(&1, EctoPGMQ.Message))
true