Zenohex.Query (Zenohex v0.7.1)
View SourceRepresents an incoming Zenoh query and provides functions for replying to it.
This module defines the structure used when receiving a query via a queryable, as well as functions for sending successful replies or error replies back to the sender.
Queries are received as %Zenohex.Query{} structs in the process registered as a queryable.
Summary
Functions
Sends a reply to the given Zenoh query.
Sends an delete reply to the given Zenoh query.
Sends an error reply to the given Zenoh query.
Types
@type reply_delete_opts() :: [ final?: boolean(), attachment: binary() | nil, congestion_control: Zenohex.Session.congestion_control(), express: boolean(), priority: Zenohex.Session.priority(), timestamp: Zenohex.Session.zenoh_timestamp_string() | nil ]
@type reply_opts() :: [ final?: boolean(), attachment: binary() | nil, congestion_control: Zenohex.Session.congestion_control(), encoding: String.t(), express: boolean(), priority: Zenohex.Session.priority(), timestamp: Zenohex.Session.zenoh_timestamp_string() | nil ]
@type zenoh_query() :: reference()
Functions
@spec reply(zenoh_query(), String.t(), binary(), reply_opts()) :: :ok | {:error, reason :: term()}
Sends a reply to the given Zenoh query.
This function is used inside a queryable process to respond to a query.
The key_expr is the key the data is associated with, and the payload
is the binary data to return.
Options
:final?: Whether this is the final reply. Defaults totrue.
Examples
iex> Zenohex.Query.reply(query.zenoh_query, "key/expr", "payload")
@spec reply_delete(zenoh_query(), String.t(), reply_delete_opts()) :: :ok | {:error, reason :: term()}
Sends an delete reply to the given Zenoh query.
Options
:final?: Whether this is the final reply. Defaults totrue.
Examples
iex> Zenohex.Query.reply_delete(query.zenoh_query, "key/expr")
@spec reply_error(zenoh_query(), binary(), reply_error_opts()) :: :ok | {:error, reason :: term()}
Sends an error reply to the given Zenoh query.
This can be used to signal failure or unsupported requests from within a queryable.
Options
:final?: Whether this is the final reply. Defaults totrue.
Examples
iex> Zenohex.Query.reply_error(query.zenoh_query, "unsupported query")