Kombu.Serialization (Kombu v0.1.0)

Copy Markdown View Source

Serializer registry and message payload encoding/decoding matching kombu.serialization.

Summary

Functions

Disable a serializer by name or content-type.

Disable all registered decoders except allowed (defaults to ["json"]).

Return the MapSet of currently disabled content-types.

Encode data into {content_type, content_encoding, serialized_binary}.

Enable a serializer by name or content-type.

Enable insecure serializers (pickle, yaml, msgpack by default, or given choices).

Decode data given content_type, content_encoding, and options (:accept, :force).

Returns the registered content type for a short name, or nil if not registered.

Replace serializer short-name aliases in content_types with full MIME content-types. Raises Kombu.SerializerNotInstalledError if an unknown alias is given.

Encode raw data without serialization (kombu.serialization.raw_encode).

Register a new serializer with name, encoder, decoder, content_type, and content_encoding.

Reset and register default serializers (json enabled by default; yaml, pickle, msgpack registered as unavailable stubs matching zero-extra-dependency configuration).

Register JSON serializer (application/json).

Set the default serializer by name.

Returns the registered short name for a content type, or nil if not registered.

Unregister a serializer by name. Raises Kombu.SerializerNotInstalledError if not found.

Functions

disable(name)

@spec disable(String.t()) :: :ok

Disable a serializer by name or content-type.

disable_insecure_serializers(allowed \\ :notset)

@spec disable_insecure_serializers([String.t()] | :notset | nil) :: :ok

Disable all registered decoders except allowed (defaults to ["json"]).

disabled_content_types()

@spec disabled_content_types() :: MapSet.t()

Return the MapSet of currently disabled content-types.

dumps(data, serializer \\ nil)

@spec dumps(term(), String.t() | atom() | nil) :: {String.t(), String.t(), binary()}

Encode data into {content_type, content_encoding, serialized_binary}.

enable(name)

@spec enable(String.t()) :: :ok

Enable a serializer by name or content-type.

enable_insecure_serializers(choices \\ :notset)

@spec enable_insecure_serializers([String.t()] | :notset | nil) :: :ok

Enable insecure serializers (pickle, yaml, msgpack by default, or given choices).

loads(data, content_type, content_encoding \\ "utf-8", opts \\ [])

@spec loads(term(), String.t() | nil, String.t() | nil, keyword()) :: term()

Decode data given content_type, content_encoding, and options (:accept, :force).

name_to_type(name)

@spec name_to_type(String.t()) :: String.t() | nil

Returns the registered content type for a short name, or nil if not registered.

prepare_accept_content(content_types, name_to_type \\ nil)

@spec prepare_accept_content(Enumerable.t() | nil, map() | nil) :: MapSet.t() | nil

Replace serializer short-name aliases in content_types with full MIME content-types. Raises Kombu.SerializerNotInstalledError if an unknown alias is given.

raw_encode(data)

@spec raw_encode(term()) :: {String.t(), String.t(), binary()}

Encode raw data without serialization (kombu.serialization.raw_encode).

register(name, encoder, decoder, content_type, content_encoding \\ "utf-8")

@spec register(
  String.t() | nil,
  (term() -> binary()) | nil,
  (binary() -> term()) | nil,
  String.t() | nil,
  String.t()
) :: :ok

Register a new serializer with name, encoder, decoder, content_type, and content_encoding.

register_defaults()

Reset and register default serializers (json enabled by default; yaml, pickle, msgpack registered as unavailable stubs matching zero-extra-dependency configuration).

register_json()

Register JSON serializer (application/json).

set_default_serializer(name)

@spec set_default_serializer(String.t()) :: :ok

Set the default serializer by name.

skip_decode()

trusted_content()

type_to_name(ctype)

@spec type_to_name(String.t()) :: String.t() | nil

Returns the registered short name for a content type, or nil if not registered.

unregister(name)

@spec unregister(String.t()) :: :ok

Unregister a serializer by name. Raises Kombu.SerializerNotInstalledError if not found.