Read-only schema for PGMQ messages.
Summary
Types
A PGMQ message group.
PGMQ message headers.
A PGMQ message ID.
A PGMQ message specification.
A PGMQ message payload.
A PGMQ Message payload type.
A PGMQ message.
Query API
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.
@opaque message()
A PGMQ message specification.
@type payload() :: EctoPGMQ.PGMQ.payload() | term()
A PGMQ message payload.
For more information about valid PGMQ message payloads, see Custom Payload Types.
A PGMQ Message payload type.
This can take any of the following forms:
:mapto denotemap/0payloads.A
module/0that implements theEcto.Typebehaviour and dumps to and loads from amap/0.{module, opts}wheremoduleis amodule/0that implements theEcto.ParameterizedTypebehaviour and dumps to and loads from amap/0andoptsis akeyword/0that contains the init parameters.
For more information about custom PGMQ payloads, see Custom Payload Types guide.
@type t() :: %EctoPGMQ.Message{ archived_at: DateTime.t() | nil, enqueued_at: DateTime.t(), headers: headers() | nil, id: id(), last_read_at: DateTime.t() | nil, payload: payload() | nil, reads: non_neg_integer(), visible_at: DateTime.t() }
A PGMQ message.
Functions
Message API
Query API
@spec archive_query(EctoPGMQ.Queue.name(), [{:payload_type, payload_type()}]) :: Ecto.Query.t()
Returns a query for the messages in the archive for the given queue.
Options
An archive message query can be built with the following options:
:payload_type- An optionalpayload_type/0for the message payloads. Defaults to:map.
Examples
iex> messages = [Message.build(%{"id" => 1})]
iex> %{"my_queue" => ids} = EctoPGMQ.send_messages(Repo, "my_queue", messages)
iex> EctoPGMQ.archive_messages(Repo, "my_queue", ids)
iex> [%Message{}] = Repo.all(Message.archive_query("my_queue"))
@spec queue_query(EctoPGMQ.Queue.name(), archived_at?: boolean(), payload_type: payload_type() ) :: Ecto.Query.t()
Returns a query for the messages in the given queue.
Options
A queue message query can be built with the following 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.:payload_type- An optionalpayload_type/0for the message payloads. Defaults to:map.
Examples
iex> messages = [Message.build(%{"id" => 1})]
iex> EctoPGMQ.send_messages(Repo, "my_queue", messages)
iex> [%Message{}] = Repo.all(Message.queue_query("my_queue"))