Support binary mode for CloudEvents
In what area(s)?
/area runtime
Describe the feature
Support CloudEvents binary mode so that payloads for message brokers can more easily work with non-json payload types and dapr can more easily work with non-dapr systems.
For example, if you produce a Kafka message in Avro or Protobuf format, you will want to be able to use the message seamlessly with tools like ksql and confluent connectors.
As it stands right now with dapr, this is not possible. Dapr will encode the message and wrap it in a json data structure. In order to work with other systems, the data needs to be decoded and unwrapped.
About CloudEvents Binary Mode
Most CloudEvents specs support the idea of "binary mode." In this mode, the payload is left in binary and attributes or headers are used for the "envelope."
Some examples of this:
- Kafka binary mode uses headers for envelope data and leave payload as raw message content: https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/bindings/kafka-protocol-binding.md#32-binary-content-mode
- AMQP binary mode uses message properties for envelope data: https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/bindings/amqp-protocol-binding.md#31-binary-content-mode
Some protocols only support structured content mode. For example NATS(https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/bindings/nats-protocol-binding.md) only supports structured content mode.
Possible solutions
- Support
binaryMode=truemetadata. Individual pubsub implementations incomponents-contribwould need to adopt if support is allowed according to standard - Automatically detect content type of message and use binary mode. This seems less ideal because I can imagine some people would want to use "binaryMode" even for json payloads just to make it easier and not wrap the payloads.
Release Note
RELEASE NOTE: ADD Support for binary mode in CloudEvents
Source: dapr/dapr