Read-only schema for PGMQ queue bindings.
For more information about message routing, see Message Routing.
Summary
Types
@type pattern() :: String.t()
A PGMQ binding pattern.
Binding patterns must meet the following conditions:
Must only contain alphanumeric characters, dots (
.), hyphens (-), underscores (_), and wildcards (*and#).Cannot start with a dot.
Cannot contain consecutive dots or wildcards.
Cannot be longer than 255 characters.
Binding patterns can be validated with
EctoPGMQ.PGMQ.validate_topic_pattern/3.
@type t() :: %EctoPGMQ.Binding{ bound_at: term(), pattern: pattern(), queue: EctoPGMQ.Queue.name(), regex: Regex.t() }
A PGMQ queue binding.
Functions
@spec query() :: Ecto.Query.t()
Returns a query for queue bindings.
Bindings are fetched transparently when querying queues via
EctoPGMQ.Queue.query/0.
Regex Filtering
This schema uses a custom Ecto.Type to load the stored compiled regex into a
Regex.t/0. This custom type can cast both Regex.t/0 structs and
binary/0 sources:
# Casting a Regex struct
where(Binding.query(), [b], b.regex == ^~r/^.*$/)
# Casting a binary source
where(Binding.query(), [b], b.regex == "^.*$")It is also possible to check for a regex match using the tools provided by
Ecto.Query:
where(Binding.query(), [b], fragment("? ~ ?", "my.routing.key", b.regex))Examples
iex> [%Binding{} | _] = Repo.all(Binding.query())