herostools.actor.archiver.base

Classes

HERODataArchiver

Base EventObserver that subscribes to a HERO event and archives its payload.

Module Contents

class herostools.actor.archiver.base.HERODataArchiver(object_selector: str, event_name: str, default_metadata: dict | None = None, max_retries: int = 5, *args, **kwargs)[source]

Bases: heros.EventObserver

Base EventObserver that subscribes to a HERO event and archives its payload.

The event payload may be a (data, metadata) tuple or a plain dict. Subclasses implement _store().

Parameters:
  • object_selector – Zenoh object selector for the devices to subscribe to.

  • event_name – Name of the event.

  • default_metadata – Default metadata merged with every incoming payload’s metadata.

  • max_retries – Number of times to retry a failed store before dropping the item.

metadata
max_retries = 5
_payload_queue
_stop_event
_worker_thread
_process_queue() None[source]

Background worker that consumes the payload queue.

is_queue_drained() bool[source]

Return True when all queued items have been processed.

Returns:

True if every item put on the queue has had task_done() called.

_stop()[source]

Stop the background thread gracefully.

_teardown() None[source]

Called by boss on shutdown.

feed(source_name: str, data: Iterable, retry_count: int = 0) None[source]

Callback registered with the source event.

data may be a (payload, metadata) tuple or a plain dict. When a plain dict is received it is used as both payload and metadata so downstream _store implementations can still locate identifier keys regardless of which field they are in.

Parameters:
  • source_name – Name of the event source (the HERO).

  • data – Either a (payload, metadata) tuple or a plain dict payload.

  • retry_count – Number of times this item has already been retried.

abstractmethod _store(source_name: str, payload: Any, metadata: dict) None[source]

Store the payload. Must be implemented by subclasses.

Parameters:
  • source_name – Name of the event source (the HERO).

  • payload – The actual data.

  • metadata – Incoming metadata merged with default_metadata.