dapr / components-contrib

Community driven, reusable components for distributed apps
Apache License 2.0
548 stars 480 forks source link

Schema registry support for kafka.pubsub component #3144

Closed passuied closed 10 months ago

passuied commented 1 year ago

Describe the feature

New to DAPR and really eager to leverage it at my company. I was surprised that there is no Schema registry support or Avro/protobuf serialization in the kafka.pubsub component. Is this on the roadmap? The way it could work is enabling configuring schema registry URL/Authentication. You could add metadata to the subscription to add specific overrides (e.g. schema name)

Release Note

RELEASE NOTE: ADD New feature in Dapr.

passuied commented 1 year ago

Seems there was a mention in https://github.com/dapr/components-contrib/issues/8#issuecomment-1191225512 but the issue was never created...

berndverst commented 1 year ago

It's not supported or on the roadmap, but we will accept contributions for this!

passuied commented 1 year ago

So updating this issue with findings. This work is not trivial as the current sarama Kafka Go implementation doesn't support Schema registry... Based on convo with @berndverst, we cannot switch to the Confluent Kafka client as it's leveraging a C library librdkafka and C bindings are not allowed in Dapr. So the solution might be to re-implement the kafka.pubsub component as a pluggable component, which doesn't have the same limitations... Doesn't seem trivial either but maybe easier?

passuied commented 11 months ago

Hi, so getting ready to help on this issue. I'm looking into adding Schema Registry to the kafka-pubsub component by using the https://github.com/riferrei/srclient library. I'm not experienced in Go but it seems to be pure Go and therefore compatible. Worst case scenario I could just re-implement the SchemaRegistryClient and leverage the underlying github.com/linkedin/goavro/v2 library for serialization/deserialization. I would focus on avro first, since this is our use case.

In terms of interface, I would:

So a subscription would look something like this:

{'pubsubname': 'pubsub',
                      'topic': 'deathStarStatus',
                      'route': 'dsstatus',
                      'metadata': {
                          'valueSchemaType': 'AVRO'
                      } }

Assumptions:

Would love some feedback on the above @berndverst and others

passuied commented 9 months ago

@ItalyPaleAle @yaron2 should this issue receive the 1.13 label? I want to make sure it's included in upcoming version. I assume it will automatically be but just in case...

ItalyPaleAle commented 9 months ago

@ItalyPaleAle @yaron2 should this issue receive the 1.13 label? I want to make sure it's included in upcoming version. I assume it will automatically be but just in case...

Added. We do go through all PRs as part of the final hygiene however, and add labels as needed :)