minos.common.protocol.avro.base module¶
- class minos.common.protocol.avro.base.MinosAvroProtocol[source]¶
Bases:
minos.common.protocol.abc.MinosBinaryProtocolMinos Avro Protocol class.
- classmethod decode(data, *args, batch_mode=False, **kwargs)[source]¶
Decode the given bytes of data into a single dictionary or a sequence of dictionaries.
- Parameters
data (
bytes) – A bytes object.args – Additional positional arguments.
batch_mode (
bool) – IfTruethe data is processed as a list of models, otherwise the data is processed as a
single model. :param kwargs: Additional named arguments. :rtype:
typing.Any:return: A dictionary or a list of dictionaries.
- classmethod decode_schema(data, *args, **kwargs)[source]¶
Decode the given bytes of data into a single dictionary or a sequence of dictionaries.
- Parameters
data (
bytes) – A bytes object.args – Additional positional arguments.
kwargs – Additional named arguments.
- Return type
typing.Union[dict[str,typing.Any],list[dict[str,typing.Any]]]- Returns
A tuple or a list of tuples.
- classmethod encode(value, schema, *args, batch_mode=False, **kwargs)[source]¶
Encoder in avro for database Values all the headers are converted in fields with double underscore name the body is a set fields coming from the data type.
- Parameters
value (
typing.Any) – The data to be stored.schema (
typing.Any) – The schema relative to the data.args – Additional positional arguments.
batch_mode (
bool) – IfTruethe data is processed as a list of models, otherwise the data is processed as a
single model. :param kwargs: Additional named arguments. :rtype:
bytes:return: A bytes object.