heros.zenoh¶
Attributes¶
Classes¶
Share one zenoh session per realm between all HEROs of a process. |
Functions¶
|
Return the link open timeout of an untouched zenoh config, in milliseconds. |
|
Parse HEROS_SEP_MULTICAST strictly. |
|
Apply HEROS_ZENOH_MODE and HEROS_ZENOH_CONNECT to a config, unset or empty variables change nothing. |
|
Lower the link open timeout to DEFAULT_OPEN_TIMEOUT, unless the config already sets its own. |
|
Assemble the zenoh config for a realm without opening a session. |
|
Close a zenoh session, logging rather than raising if zenoh gives up on it. |
|
Tear down every HERO and close every zenoh session of this process. |
Module Contents¶
- heros.zenoh.zenoh_default_config¶
- heros.zenoh.DEFAULT_SEP_MULTICAST: bool = True¶
- heros.zenoh.DEFAULT_OPEN_TIMEOUT: int = 1000¶
- heros.zenoh._OPEN_TIMEOUT_KEY = 'transport/unicast/open_timeout'¶
- heros.zenoh._zenoh_default_open_timeout() int[source]¶
Return the link open timeout of an untouched zenoh config, in milliseconds.
- 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._apply_open_timeout(config: zenoh.Config) None[source]¶
Lower the link open timeout to DEFAULT_OPEN_TIMEOUT, unless the config already sets its own.
A value is treated as the caller’s own as soon as it differs from the zenoh default, so HEROS_ZENOH_CONFIG keeps the last word.
- 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
- heros.zenoh._close(session: zenoh.Session) None[source]¶
Close a zenoh session, logging rather than raising if zenoh gives up on it.
- Parameters:
session – The session to close
- heros.zenoh._managers: weakref.WeakSet¶
- heros.zenoh.close_all_sessions() None[source]¶
Tear down every HERO and close every zenoh session of this process.
- 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 = []¶
- _referrer_index(obj: object) int | None[source]¶
Return the index of obj in the referrers, or None. By identity, as HEROs of the same name compare equal.
- 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
- force_close() None[source]¶
Tear down every HERO that holds a session of this manager, then close the sessions.
Closing a session does not reliably release the callback threads of the declarations made on it, undeclaring does. The HEROs therefore have to go first, which is why this does more than close the sessions.
- heros.zenoh.session_manager¶