-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add header support for consumer/producer records #1086
Add header support for consumer/producer records #1086
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1086 +/- ##
============================================
+ Coverage 82.00% 82.34% +0.34%
- Complexity 464 485 +21
============================================
Files 48 48
Lines 2289 2373 +84
Branches 352 382 +30
============================================
+ Hits 1877 1954 +77
- Misses 264 268 +4
- Partials 148 151 +3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1f3b35f
to
1423f08
Compare
Purpose
$subject
Fixes ballerina-platform/ballerina-library#6196
kafka:AnydataProducerRecord
andkafka:AnydataConsumerRecord
are updated withheaders
field asmap<byte[]|byte[][]|string|string[]>
. Users can use subtypes of this in their consumer records. The runtime will try to match the received header values to the best possible match and populate the header map.As an example, if the received headers are like this -
{"key1": ["header1", "header2"], "key2": "header3"}
and the consumer record header is defined like this -map<string[]|byte[]>
, the headers will be mapped as{"key1": ["header1", "header2"], "key2": [12, 212, 23]}
.We have defined
kafka:BytesConsumerRecord
with headers as typemap<byte[]|byte[][]>
. If there is only one header for a specifc key, the type of the value will bebyte[]
. Otherwise it will bebyte[][]
.For an instance, if a user defines the header type as
map<string|byte[][]>
, the headers will be mapped to match the number of headers for a given type.Producer
Consumer
The existing compiler plugin for the
kafka:Service
is not exactly strict and does not validate some of the scenarios. This needs to be improved with correct semantic api usages. Will create an issue for this.Examples
Checklist