View Source GRPC.Codec behaviour (grpc v0.8.1)

Contains code to serialize a deserialize the message.

Summary

Callbacks

Name is identity of the codec, which will be suffix after content-type "application/grpc+" such as "proto".

This function is invoked whenever it is defined after the protobuf message has been transformed into a gRPC payload.

This function is invoked before the gRPC payload is transformed into a protobuf message whenever it is defined.

Callbacks

@callback decode(any(), module :: atom()) :: any()
@callback encode(any()) :: binary()
@callback name() :: String.t()

Name is identity of the codec, which will be suffix after content-type "application/grpc+" such as "proto".

Link to this callback

pack_for_channel(iodata)

View Source (optional)
@callback pack_for_channel(iodata()) :: binary()

This function is invoked whenever it is defined after the protobuf message has been transformed into a gRPC payload.

This can be used to apply a transform over the gRPC message before sending it. For instance grpc-web using the application/grpc-web-text content type requires the message to be Base64-encoded, so a server sending messages using grpc-web-text will be required to do a Base64 encode on the payload before sending the gRPC message.

Link to this callback

unpack_from_channel(binary)

View Source (optional)
@callback unpack_from_channel(binary()) :: binary()

This function is invoked before the gRPC payload is transformed into a protobuf message whenever it is defined.

This can be used to apply a transform over the gRPC message before decoding it. For instance grpc-web using the application/grpc-web-text content type requires the message to be Base64-encoded, so a server receving messages using grpc-web-text will be required to do a Base64 decode on the payload before decoding the gRPC message.