Zenohex.Query (Zenohex v0.7.1)

View Source

Represents 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

reply_delete_opts()

@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
]

reply_error_opts()

@type reply_error_opts() :: [final?: boolean(), encoding: String.t()]

reply_opts()

@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
]

t()

@type t() :: %Zenohex.Query{
  attachment: binary() | nil,
  encoding: String.t() | nil,
  key_expr: String.t(),
  parameters: String.t(),
  payload: binary() | nil,
  selector: String.t(),
  zenoh_query: zenoh_query()
}

zenoh_query()

@type zenoh_query() :: reference()

Functions

reply(zenoh_query, key_expr, payload, opts \\ [final?: true])

@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 to true.

Examples

iex> Zenohex.Query.reply(query.zenoh_query, "key/expr", "payload")

reply_delete(zenoh_query, key_expr, opts \\ [final?: true])

@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 to true.

Examples

iex> Zenohex.Query.reply_delete(query.zenoh_query, "key/expr")

reply_error(zenoh_query, payload, opts \\ [final?: true])

@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 to true.

Examples

iex> Zenohex.Query.reply_error(query.zenoh_query, "unsupported query")