pythia.event_stream.base#

Event stream interface and common definitions.

class pythia.event_stream.base.Backend(uri: str)[source]#

Bases: ABC

Even stream backend.

This class has three pruposes:
  • Interface for custom backends

  • Skeleton for their internal workings.

  • Factory to choose implementation.

Initialize a backend from its uri.

Parameters:

uri – connection string.

__init__(uri: str) None[source]#

Initialize a backend from its uri.

Parameters:

uri – connection string.

_abc_impl = <_abc_data object>#
abstract connect()[source]#

Ensure internal connection to the remote service is ok.

classmethod from_uri(uri: str) Backend[source]#

Factory to select Backend from its schema.

Parameters:

uri – connection string.

Returns:

The instantiated backend for the requested schema.

abstract post(data)[source]#

Send single packet of data.

Parameters:

data – the data to send.

This method gets called once for each element yielded from the buffer probe.

Any kind of batching should be implemented here and coordinated with the respective buffer probe.

pythia.event_stream.base._parse_netloc(netloc: str)[source]#
pythia.event_stream.base.parse_uri(uri: EventStreamUri) Tuple[dict[str, Any], Dict[Any, list]][source]#

Get information from the uri.

Parameters:

uri – uri to parse.

Returns:

scheme, netloc, path, params, query, fragment - as contained in the uri, and (b) query parameters form the uri.

Return type:

A tuple containing (a) dictionary containing the following keys