faust.serializers.registry

Registry of supported codecs (serializers, compressors, etc.).

class faust.serializers.registry.Registry(key_serializer: Union[faust.types.codecs.CodecT, str, None] = None, value_serializer: Union[faust.types.codecs.CodecT, str, None] = 'json') → None[source]

Serializing message keys/values.

Parameters:
  • key_serializer (Union[CodecT, str, None]) – Default key serializer to use when none provided.
  • value_serializer (Union[CodecT, str, None]) – Default value serializer to use when none provided.
loads_key(typ: Union[Type[faust.types.models.ModelT], Type[bytes], Type[str], None], key: Optional[bytes], *, serializer: Union[faust.types.codecs.CodecT, str, None] = None) → Union[bytes, faust.types.core._ModelT, Any, None][source]

Deserialize message key.

Parameters:
Return type:

Union[bytes, _ModelT, Any, None]

loads_value(typ: Union[Type[faust.types.models.ModelT], Type[bytes], Type[str], None], value: Optional[bytes], *, serializer: Union[faust.types.codecs.CodecT, str, None] = None) → Any[source]

Deserialize value.

Parameters:
Return type:

Any

dumps_key(typ: Union[Type[faust.types.models.ModelT], Type[bytes], Type[str], None], key: Union[bytes, faust.types.core._ModelT, Any, None], *, serializer: Union[faust.types.codecs.CodecT, str, None] = None, skip: Tuple[Type, ...] = (<class 'bytes'>,)) → Optional[bytes][source]

Serialize key.

Parameters:
  • typ (Union[Type[ModelT], Type[bytes], Type[str], None]) – Model hint (can also be str/bytes). When typ=str or bytes, raw serializer is assumed.
  • key (Union[bytes, _ModelT, Any, None]) – The key value to serializer.
  • serializer (Union[CodecT, str, None]) – Codec to use for this key, if it is not a model type. If not set the default will be used (key_serializer).
Return type:

Optional[bytes]

dumps_value(typ: Union[Type[faust.types.models.ModelT], Type[bytes], Type[str], None], value: Union[bytes, faust.types.core._ModelT, Any], *, serializer: Union[faust.types.codecs.CodecT, str, None] = None, skip: Tuple[Type, ...] = (<class 'bytes'>,)) → Optional[bytes][source]

Serialize value.

Parameters:
  • typ (Union[Type[ModelT], Type[bytes], Type[str], None]) – Model hint (can also be str/bytes). When typ=str or bytes, raw serializer is assumed.
  • key – The value to serializer.
  • serializer (Union[CodecT, str, None]) – Codec to use for this value, if it is not a model type. If not set the default will be used (value_serializer).
Return type:

Optional[bytes]

Model[source]