tethys.core.streams.stream_zero

Module Contents

tethys.core.streams.stream_zero.log[source]
class tethys.core.streams.stream_zero.ZeroStream(pipe: ZeroPipe, session: ZeroSession, transport: Union['ZeroTransport', Callable], **kwargs)[source]

Bases: tethys.core.regobjs.regobj_zero.ZeroRegistrableObject, tethys.core.streams.stream_base.StreamBase

The Stream entity class of the Zero generation. The ZeroStream is an entity that defines the physical path of the data.

Parameters
  • pipe (ZeroPipe) – Pipe instance that defines the logical path between nodes.

  • session (ZeroSession) – The session allows getting the stream for the pipe.

  • transport

DEFAULT_HEARTBEAT_FAIL_DELAY = 10[source]
READ_DELAY = 0.1[source]
CLASS_PATH = /streams/[source]

ZeroStream instances collection path in the repository

FIELDS_SCHEMA[source]

ZeroStream fields validators

connection_context(self)[source]
property heartbeat_fail_delay(self)[source]
property is_busy(self) → bool[source]

Is some station using the stream?

Return type

bool

open(self, save=True, **kwargs) → 'ZeroStream'[source]

Open stream

Parameters

save (bool) – to save the stream

Returns

self instance

Return type

StreamBase

close(self, save=True, **kwargs) → 'ZeroStream'[source]

Close stream

Parameters

save (bool) – to save the stream

Returns

self instance

Return type

StreamBase

write(self, data_packet: Union[List[Any], Any], many: bool = False, **kwargs)[source]

Write the data_packet to the stream

Parameters
  • data_packet – any data object or list of the data objects (with many=True)

  • many (bool) – if many=True then data_packet’s elements will be sent one-by-one.

read(self, count: int = None, wait_timeout: float = None, **kwargs) → Generator[Tuple[str, Any], None, None][source]

Read the data_packets from the stream. Return Generator.

Parameters
  • count (int) – count of the data_packets

  • wait_timeout (float) – waiting time (seconds)

ack(self, message_key: str, **kwargs)[source]

Acknowledge message

Parameters

message_key (str) – message key for the acknowledgement

redirect_to(self, station: ZeroStation, **kwargs)[source]

Redirect stream processing to the station

Parameters

station (ZeroStation) – Station where the stream can be processed in the near time

heartbeat(self, **kwargs)[source]

Health heartbeat

__enter__(self)[source]
__exit__(self, exc_type, exc_val, exc_tb)[source]