hop.io

class hop.io.Deserializer(value)[source]

An enumeration.

classmethod deserialize(message)[source]

Deserialize a stream message and instantiate a model.

Args:

message: A serialized message.

Returns:

A data container corresponding to the format in the serialized message.

Raises:
ValueError: If the message is incorrectly formatted or

if the message format is not recognized.

class hop.io.Stream(auth=True, start_at=<ConsumerStartPosition.LATEST: 2>, persist=False)[source]

Defines an event stream.

Sets up defaults used within the client so that when a stream connection is opened, it will use defaults specified here.

Args:
auth: A bool or Auth instance. Defaults to loading from auth.load_auth()

if set to True. To disable authentication, set to False.

start_at: The message offset to start at in read mode. Defaults to LATEST. persist: Whether to listen to new messages forever or stop

when EOS is received in read mode. Defaults to False.

open(url, mode='r', metadata=False)[source]

Opens a connection to an event stream.

Args:

url: Sets the broker URL to connect to.

Kwargs:

mode: Read (‘r’) or write (‘w’) from the stream. metadata: Whether to receive message metadata along

with payload (read only).

Returns:

An open connection to the client, either an adc Producer instance in write mode or an adc Consumer instance in read mode.

Raises:
ValueError: If the mode is not set to read/write or if more than

one topic is specified in write mode.