Skip to content
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 Key deserializer for KafkaSource #1326

Conversation

pierDipi
Copy link
Member

This patch adds a KeyDeserializer that uses the
kafkasources.sources.knative.dev/key-type label to
deserialize a record key.

Part of #312

Proposed Changes

  • Add Key deserializer for KafkaSource

Release Note

None

Docs

None

Signed-off-by: Pierangelo Di Pilato <[email protected]>
Signed-off-by: Pierangelo Di Pilato <[email protected]>
Signed-off-by: Pierangelo Di Pilato <[email protected]>
Signed-off-by: Pierangelo Di Pilato <[email protected]>
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Oct 15, 2021
@knative-prow-robot knative-prow-robot added area/data-plane size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 15, 2021
@pierDipi pierDipi requested review from matzew, aliok and devguyio October 15, 2021 08:42
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-sandbox-eventing-kafka-broker-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
control-plane/pkg/reconciler/source/source.go 73.6% 74.5% 1.0

@codecov
Copy link

codecov bot commented Oct 15, 2021

Codecov Report

Merging #1326 (b767833) into main (21930a5) will increase coverage by 0.23%.
The diff coverage is 90.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1326      +/-   ##
============================================
+ Coverage     75.74%   75.98%   +0.23%     
- Complexity      523      539      +16     
============================================
  Files            94       95       +1     
  Lines          3290     3352      +62     
  Branches        148      154       +6     
============================================
+ Hits           2492     2547      +55     
- Misses          616      619       +3     
- Partials        182      186       +4     
Flag Coverage Δ
java-unittests 81.11% <87.71%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...dispatcher/impl/consumer/BaseConsumerVerticle.java 92.85% <ø> (ø)
...ve/eventing/kafka/broker/dispatcher/main/Main.java 0.00% <0.00%> (ø)
.../core/reconciler/impl/ResourcesReconcilerImpl.java 92.02% <50.00%> (-0.68%) ⬇️
...er/impl/consumer/InvalidCloudEventInterceptor.java 92.13% <89.47%> (-1.11%) ⬇️
...oker/dispatcher/impl/consumer/KeyDeserializer.java 93.10% <93.10%> (ø)
control-plane/pkg/core/config/egress.go 100.00% <100.00%> (ø)
control-plane/pkg/reconciler/source/source.go 48.80% <100.00%> (+1.24%) ⬆️
...a/broker/dispatcher/impl/RecordDispatcherImpl.java 82.55% <100.00%> (+0.20%) ⬆️
...patcher/impl/consumer/OrderedConsumerVerticle.java 90.38% <100.00%> (ø)
...r/dispatcher/main/ConsumerVerticleFactoryImpl.java 85.32% <100.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21930a5...b767833. Read the comment docs.

@@ -61,6 +61,8 @@

public static final String TYPE = "dev.knative.kafka.event";

private static final String KEY_EXTENSION = "key";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we - somewhere, get a little comment/description on the relationship between PARTITION_KEY_EXTENSION and KEY_EXTENSION ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason to use key is for backward compatibility with the exiting source in eventing-kafka.

I'd propose to deprecate that field if possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecate where? Here? or eventing-kafka ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both or here only for the future.

There is a bug report related to this knative-extensions/eventing-kafka#897, so even in eventing-kafka to solve that issue and keep backward compatibility, we would need to set the partitionkey extension to the same value of the key extension.

The problem with the key extension is that is Knative specific while partitionkey is a CloudEvent spec thing.

So, I'd deprecate key and the alternative will be partitionkey.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I'd deprecate key and the alternative will be partitionkey.

sounds good, @pierDipi

@matzew
Copy link
Contributor

matzew commented Oct 15, 2021

Quite a verbose change, due to signature 😅

But overall looks good - added a few comments

@pierDipi pierDipi requested a review from matzew October 18, 2021 15:00
Copy link
Contributor

@matzew matzew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, pierDipi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit ccb0489 into knative-extensions:main Oct 19, 2021
@pierDipi pierDipi deleted the KNATIVE-312-key-deserializer branch October 19, 2021 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/control-plane area/data-plane cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants