Zenohex.Liveliness (Zenohex v0.9.1-beta.1)

Copy Markdown View Source

A LivelinessToken is a token which liveliness is tied to the Zenoh Session and can be monitored by remote applications.

see. https://docs.rs/zenoh/latest/zenoh/liveliness/index.html

Summary

Functions

Create a Subscriber for liveliness changes matching the given key expression.

Create a LivelinessToken for the given key expression.

Query liveliness tokens with matching key expressions.

Undeclare the Subscriber.

Undeclare the LivelinessToken.

Types

declare_subscriber_opts()

@type declare_subscriber_opts() :: [{:history, boolean()}]

get_opts()

@type get_opts() :: [{:query_timeout, non_neg_integer()}]

token()

@type token() :: reference()

Functions

declare_subscriber(session_id, key_expr, pid \\ self(), opts \\ [])

@spec declare_subscriber(
  Zenohex.Session.id(),
  String.t(),
  pid(),
  declare_subscriber_opts()
) ::
  {:ok, subscriber_id :: Zenohex.Subscriber.id()} | {:error, reason :: term()}

Create a Subscriber for liveliness changes matching the given key expression.

Parameters

  • session_id — The session to declare on
  • key_expr — Key expression to associate with
  • pid - Process to receive liveliness updates (defaults to self())
  • opts - Options for configuring the liveliness subscriber.

Examples

iex> Zenohex.Liveliness.declare_subscriber(session_id, "key/expr")
{:ok, #Reference<...>}

declare_token(session_id, key_expr)

@spec declare_token(Zenohex.Session.id(), String.t()) ::
  {:ok, token()} | {:error, reason :: term()}

Create a LivelinessToken for the given key expression.

Parameters

  • session_id — The session to declare on
  • key_expr — Key expression to associate with

Examples

iex> Zenohex.Liveliness.declare_token(session_id, "key/expr")
{:ok, #Reference<...>}

get(session_id, key_expr, timeout, opts \\ [])

@spec get(Zenohex.Session.id(), String.t(), non_neg_integer(), get_opts()) ::
  {:ok, [Zenohex.Sample.t() | Zenohex.Query.ReplyError.t()]}
  | {:error, :timeout}
  | {:error, reason :: term()}

Query liveliness tokens with matching key expressions.

Parameters

  • key_expr - The key expression matching liveliness tokens to query

Examples

iex> Zenohex.Liveliness.get(session_id, "key/expr", 100)
{:ok, [%Zenohex.Sample{}]}

undeclare_subscriber(subscriber_id)

@spec undeclare_subscriber(Zenohex.Subscriber.id()) ::
  :ok | {:error, reason :: term()}

Undeclare the Subscriber.

Parameters

  • subscriber_id — The ID of the subscriber to undeclare

Examples

iex> Zenohex.Liveliness.undeclare_subscriber(subscriber_id)
:ok

undeclare_token(token)

@spec undeclare_token(token()) :: :ok | {:error, reason :: term()}

Undeclare the LivelinessToken.

Examples

iex> Zenohex.Liveliness.undeclare_token(token)
:ok