autobahn.wamp.serializer¶
Classes¶
Base class for WAMP serializers. A WAMP serializer is the core glue between |
|
Base class for WAMP serializers. A WAMP serializer is the core glue between |
Module Contents¶
- class JsonObjectSerializer(batched=False, use_binary_hex_encoding=False, use_decimal_from_str=False, use_decimal_from_float=False)[source]¶
Bases:
object- serialize(obj)[source]¶
Implements
autobahn.wamp.interfaces.IObjectSerializer.serialize()
- unserialize(payload)[source]¶
Implements
autobahn.wamp.interfaces.IObjectSerializer.unserialize()
- class JsonSerializer(batched=False, use_binary_hex_encoding=False, use_decimal_from_str=False)[source]¶
Bases:
SerializerBase class for WAMP serializers. A WAMP serializer is the core glue between parsed WAMP message objects and the bytes on wire (the transport).
- MIME_TYPE = 'application/json'[source]¶
MIME type announced in HTTP request/response headers when running WAMP-over-Longpoll HTTP fallback.
- PAYLOAD_SERIALIZER_ID = 'json'[source]¶
Serializer for application payload. For JSON transport, both envelope and payload use JSON serialization.
- class Serializer(serializer)[source]¶
Bases:
objectBase class for WAMP serializers. A WAMP serializer is the core glue between parsed WAMP message objects and the bytes on wire (the transport).
- serialize(msg: autobahn.wamp.interfaces.IMessage) Tuple[bytes, bool][source]¶
- serialize_payload(data)[source]¶
Serialize application payload data (args/kwargs/payload).
Uses the payload serializer configured for this transport serializer. For traditional serializers (JSON, CBOR, MsgPack, UBJSON), this is the same as the envelope serializer. For FlatBuffers, this can be different.
- Parameters:
data – The data to serialize (list for args, dict for kwargs).
- Returns:
Serialized bytes.
- Return type:
- set_stats_autoreset(rated_messages, duration, callback, reset_now=False)[source]¶
Configure a user callback invoked when accumulated stats hit specified threshold. When the specified number of rated messages have been processed or the specified duration has passed, statistics are automatically reset, and the last statistics is provided to the user callback.
- Parameters:
rated_messages (int) – Number of rated messages that should trigger an auto-reset.
duration (int) – Duration in ns that when passed will trigger an auto-reset.
callback (callable) – User callback to be invoked when statistics are auto-reset. The function will be invoked with a single positional argument: the accumulated statistics before the reset.
- stats(reset=True, details=False)[source]¶
Get (and reset) serializer statistics.
- Parameters:
- Returns:
Serializer statistics, eg:
{ "timestamp": 1574156576688704693, "duration": 34000000000, "bytes": 0, "messages": 0, "rated_messages": 0 }
- Return type:
- stats_bytes()[source]¶
Get serializer statistics: bytes (serialized + unserialized).
- Returns:
Number of bytes.
- Return type:
- stats_messages()[source]¶
Get serializer statistics: messages (serialized + unserialized).
- Returns:
Number of messages.
- Return type:
- stats_rated_messages()[source]¶
Get serializer statistics: rated messages (serialized + unserialized).
- Returns:
Number of rated messages.
- Return type:
- stats_reset()[source]¶
Get serializer statistics: timestamp when statistics were last reset.
- Returns:
Last reset time of statistics (UTC, ns since Unix epoch)
- Return type:
- unserialize(payload: bytes, isBinary: bool | None = None) List[autobahn.wamp.interfaces.IMessage][source]¶
Implements
autobahn.wamp.interfaces.ISerializer.unserialize()