heros.zenoh

Attributes

Classes

ZenohSessionManager

Share one zenoh session per realm between all HEROs of a process.

Functions

_parse_sep_multicast_env() → bool | None

Parse HEROS_SEP_MULTICAST strictly.

_apply_mode_and_connect(config) → None

Apply HEROS_ZENOH_MODE and HEROS_ZENOH_CONNECT to a config, unset or empty variables change nothing.

build_config(realm[, overrides, sep_multicast]) → zenoh.Config

Assemble the zenoh config for a realm without opening a session.

Module Contents

heros.zenoh.zenoh_default_config
heros.zenoh.DEFAULT_SEP_MULTICAST: bool = True
heros.zenoh._TRUE_FLAGS = ('1', 'true', 'yes', 'on')
heros.zenoh._FALSE_FLAGS = ('0', 'false', 'no', 'off')
heros.zenoh._ZENOH_MODES = ('peer', 'client', 'router')
heros.zenoh._parse_sep_multicast_env() → bool | None[source]

Parse HEROS_SEP_MULTICAST strictly.

Returns:

True or False for a recognized value, None if the variable is unset or empty

Raises:

ValueError – If the value is not one of 1/true/yes/on or 0/false/no/off (case-insensitive)

heros.zenoh._apply_mode_and_connect(config: zenoh.Config) → None[source]

Apply HEROS_ZENOH_MODE and HEROS_ZENOH_CONNECT to a config, unset or empty variables change nothing.

Raises:

ValueError – If the mode is not peer, client or router, a connect item is empty or zenoh rejects a value

heros.zenoh.build_config(realm: str, overrides: dict | None = None, *, sep_multicast: bool | None = None) → zenoh.Config[source]

Assemble the zenoh config for a realm without opening a session.

Environment variables are read at call time. Later layers win over earlier ones: zenoh defaults, then HEROS_ZENOH_CONFIG, then the realm specific multicast address (non-heros realms only), then HEROS_ZENOH_MODE and HEROS_ZENOH_CONNECT, then overrides. HEROS_ZENOH_CONNECT sets only connect/endpoints.

The multicast address is used if sep_multicast is true. If it is None, HEROS_SEP_MULTICAST decides, and if that is unset, the module default does.

Parameters:
  • realm – The realm the session is opened for

  • overrides – Config keys and values applied last

  • sep_multicast – Whether to use a realm specific multicast address, None to use the environment

Returns:

The assembled zenoh config

Raises:

ValueError – If HEROS_ZENOH_CONFIG is not a valid zenoh config, HEROS_SEP_MULTICAST is not a recognized flag, or HEROS_ZENOH_MODE or HEROS_ZENOH_CONNECT hold an invalid value

class heros.zenoh.ZenohSessionManager(config_dict: dict | None = None, *, sep_multicast: bool | None = None)[source]

Share one zenoh session per realm between all HEROs of a process.

The zenoh config is built when the first session of a realm opens and stays in use until every HERO of that realm has released it.

Parameters:
  • config_dict – Zenoh config keys and values, applied over the environment

  • sep_multicast – Whether sessions use a realm specific multicast address. None defers to HEROS_SEP_MULTICAST and then to the default. Can be changed later via the sep_multicast attribute and applies to sessions opened afterwards.

sep_multicast = None
_config_dict
_sessions
_referrers = []
_referrer_realms = []
request_session(obj: object, realm: str) → zenoh.Session[source]

Request the global zenoh session.

Parameters:

obj – The object that requests the session

release_session(obj: object) → None[source]

Release from the global zenoh session.

Parameters:

obj – The object that wants to release from the global zenoh session

update_config(config_dict: dict) → None[source]
force_close() → None[source]
heros.zenoh.session_manager