Zenohex is a thin Elixir wrapper around Zenoh, implemented using Rustler.
- Zenoh:
- Rustler: https://github.com/rusterlium/rustler
To learn how to use this library, check the example implementations in the following directory:
Summary
Functions
Deletes data matching the given key_expr.
Query data with the given selector.
Publishes a payload to the specified key_expr.
Scouts for routers or peers.
Functions
Deletes data matching the given key_expr.
Internally opens a session, deletes the data, and ensures the session is closed.
Parameters
key_expr: The key expression to delete.opts: Additional options. SeeZenohex.Session.delete/3for details.
@spec get(String.t(), non_neg_integer(), keyword()) :: {:ok, [Zenohex.Sample.t() | Zenohex.Query.ReplyError.t()]} | {:error, :timeout} | {:error, reason :: term()}
Query data with the given selector.
Internally opens a session, performs the query, and ensures the session is closed.
Parameters
selector: The selector to query.timeout: Timeout in milliseconds to wait for query replies.opts: Additional options. SeeZenohex.Session.get/4for details.
Publishes a payload to the specified key_expr.
Internally opens a session, performs the publish, and ensures the session is closed.
Parameters
key_expr: The key expression to publish to.payload: The binary payload to publish.opts: Additional options. SeeZenohex.Session.put/4for details.
@spec scout(Zenohex.Scouting.what(), Zenohex.Config.t(), non_neg_integer()) :: {:ok, [Zenohex.Scouting.Hello.t()]} | {:error, :timeout} | {:error, reason :: term()}
Scouts for routers or peers.
This function discovers either :peer or :router nodes based on the given configuration.
It blocks until a response is received or the timeout is reached.
Parameters
what: Either:peeror:router, indicating what type of node to search for.config: The Zenoh configuration used for the scout operation.timeout: The maximum time to wait (in milliseconds) before giving up.
Examples
iex> config = Zenohex.Config.default()
iex> {:ok, hellos} = Zenohex.scout(:peer, config, 1000)