minos.networks.brokers.messages.models.abc
Classes
Broker Message base class. |
- class BrokerMessage[source]
-
Broker Message base class.
- abstract property identifier: uuid.UUID
Get the identifier of the message.
- Returns
An
UUID
instance.
- abstract property reply_topic: Optional[str]
Get the reply topic of the message if there is someone.
- Returns
A
str
value orNone
.
- abstract class property version: int
Get the version of the message.
- Returns
A strictly positive
int
value.
- abstract property content: Any
Get the content of the message.
- Returns
Any value.
- abstract property ok: bool
Check if the message is okay or not.
- Returns
True
if the message is okay orFalse
otherwise.
- abstract property headers: dict[str, str]
Get the headers of the message.
- Returns
A
dict
instance withstr
keys andstr
values.
- classmethod encode_schema(encoder, target, **kwargs)[source]
Encode schema with the given encoder.
- Parameters
encoder (SchemaEncoder) – The encoder instance.
target (ModelType) – An optional pre-encoded schema.
- Returns
The encoded schema of the instance.
- Return type
- classmethod encode_data(encoder, target, **kwargs)[source]
Encode data with the given encoder.
- Parameters
encoder (DataEncoder) – The encoder instance.
target (Any) – An optional pre-encoded data.
- Returns
The encoded data of the instance.
- Return type
- classmethod decode_data(decoder, target, type_, **kwargs)[source]
Decode data with the given decoder.
- Parameters
decoder (DataDecoder) – The decoder instance.
target (Any) – The data to be decoded.
type – The data type.
type_ (ModelType) –
- Returns
A decoded instance.
- Return type
- __init__(fields=None, **kwargs)
Class constructor.
- property avro_bytes: bytes
Generate bytes representation of the current instance.
- Returns
A bytes object.
- property avro_data: dict[str, Any]
Compute the avro data of the model.
- Returns
A dictionary object.
- avro_schema = [{'name': 'BrokerMessage', 'namespace': 'minos.networks.brokers.messages.models.abc.308f73a6-4d51-4e6e-ab25-8e1fd9a801f8', 'type': 'record', 'fields': []}]
- property avro_str: str
Generate bytes representation of the current instance.
- Returns
A bytes object.
- classname = 'minos.networks.brokers.messages.models.abc.BrokerMessage'
- static decode_schema(decoder, target, **kwargs)
Decode schema with the given encoder.
- Parameters
decoder (SchemaDecoder) – The decoder instance.
target (Any) – The schema to be decoded.
kwargs – Additional named arguments.
- Returns
The decoded schema as a type.
- Return type
- property fields: dict[str, minos.common.model.fields.Field]
Fields getter
- classmethod from_avro(schema, data)
Build a new instance from the
avro
schema and data.
- classmethod from_avro_bytes(raw, batch_mode=False, **kwargs)
Build a single instance or a sequence of instances from bytes.
- Parameters
- Returns
A single instance or a sequence of instances.
- Return type
- classmethod from_avro_str(raw, **kwargs)
Build a single instance or a sequence of instances from bytes
- abstract classmethod from_model_type(model_type, *args, **kwargs)
Build a
Model
from aModelType
.- Parameters
model_type (ModelType) –
ModelType
object containing the DTO’s structureargs – Positional arguments to be passed to the model constructor.
kwargs – Named arguments to be passed to the model constructor.
- Returns
A new
DeclarativeModel
instance.- Return type
T
- classmethod from_typed_dict(typed_dict, *args, **kwargs)
Build a
Model
from aTypeDict
anddata
.- Parameters
typed_dict (TypedDict) –
TypeDict
object containing the DTO’s structureargs – Positional arguments to be passed to the model constructor.
kwargs – Named arguments to be passed to the model constructor.
- Returns
A new
DataTransferObject
instance.- Return type
T
- get(k[, d]) D[k] if k in D, else d. d defaults to None.
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- model_type
alias of
BrokerMessage
- classmethod to_avro_bytes(models)
Create a
bytes
representation of the given object instances.
- classmethod to_avro_str(models)
Build the avro string representation of the given object instances.
- type_hints = {}
- type_hints_parameters = ()
- values() an object providing a view on D's values