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

Address issue #1699 (config option to deserialize proto message keys) #1729

Merged
merged 15 commits into from
Apr 5, 2022

Conversation

jdechicchis
Copy link
Contributor

@jdechicchis jdechicchis commented Mar 14, 2022

Closes #1699

  • Breaking change? (if so, please describe the impact and migration path for existing application instances)

What changes did you make? (Give an overview)
Add protobufMessageNameForKeyByTopic option to config. Message keys are deserialized using a protobuf schema if the config is set. Otherwise message keys are treated as strings.

Is there anything you'd like reviewers to focus on?
Name of configuration and unit tests as well as style.

How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)

  • No need to
  • Manually (please, describe, if necessary)
  • Unit checks
  • Integration checks
  • Covered by existing automation

Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (e.g. ENVIRONMENT VARIABLES)
  • My changes generate no new warnings (e.g. Sonar is happy)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Check out Contributing and Code of Conduct

A picture of a cute animal (not mandatory but encouraged)

deserialized using a protobuf schema if the config is set. Otherwise
message keys are treated as strings.

Closes provectus#1699
@jdechicchis jdechicchis changed the title Add protobufMessageNameForKeyByTopic option to config. Message keys are Address issue #1699 (config option to deserialize proto message keys) Mar 14, 2022
@Haarolean
Copy link
Contributor

@jdechicchis thanks for the contribution!

@Haarolean Haarolean self-assigned this Mar 15, 2022
@Haarolean Haarolean added type/enhancement En enhancement to an already existing feature scope/backend labels Mar 15, 2022
@iliax
Copy link
Contributor

iliax commented Mar 20, 2022

Hi @jdechicchis!
Thank you for your PR, please see comments.

In addition to them -> we should also edit serialize method to support sending messages with proto keys via kafka-ui.
Logic should be:

  1. if there is no descriptor for topic's k or v -> treat (k or v) as a string - kOrV.getBytes();
  2. if there is a descriptor for k/v -> use descriptor for serialization. If there is an serialization error - you should throw ValidationException exception

@jdechicchis
Copy link
Contributor Author

@iliax Thank you for the review. I was wondering what to do about defaultMessageDescriptor based on your feedback. It's currently only used as a fallback to deserialize the message's value, but based on your feedback I think it may make sense to remove defaultMessageDescriptor and fallback to FALLBACK_FORMATTER (StringMessageFormatter) if the descriptor isn't found (for either key or value)

@iliax
Copy link
Contributor

iliax commented Mar 24, 2022

@jdechicchis Thank you for highlighting it, I actually forgot defaultMessageDescriptor logic... We currently can't remove this, because it will break backward-compatibility.
I think most the most proper way is to add Cluster.protobufMessageNameForKey property and use it as default for topic's keys that have no explicit mapping. If protobufMessageNameForKey is not specified or there was an error during initializing - we should fallback to StringMessageFormatter

@jdechicchis
Copy link
Contributor Author

@iliax Thanks for the clarification, updated based on the feedback.

By the way, the "Documentation / build-and-test (pull_request)" check is failing with the error:

Done. The following urls did not pass:
https://dev-a63ggcut.auth0.com/

even though I didn't add that URL. What's the best way to resolve it?

@Haarolean
Copy link
Contributor

Haarolean commented Mar 29, 2022 via email

@iliax iliax self-requested a review March 30, 2022 11:28
@iliax
Copy link
Contributor

iliax commented Apr 4, 2022

Hi @jdechicchis !
Thank you for great job - I added just a couple of small comments - pls fix them and we will be ready to merge

@jdechicchis
Copy link
Contributor Author

@iliax Fixed log levels and added the @ Nullable annotations!

@Haarolean Haarolean requested a review from iliax April 4, 2022 16:23
@Haarolean Haarolean merged commit 1796fd5 into provectus:master Apr 5, 2022
javalover123 pushed a commit to javalover123/kafka-ui that referenced this pull request Dec 7, 2022
…us#1729)

* Add protobufMessageNameForKeyByTopic option to config. Message keys are
deserialized using a protobuf schema if the config is set. Otherwise
message keys are treated as strings.

Closes provectus#1699

* Add documentation around kafkaui's protobuf support

* Add protobufMessageNameForKey config option

* Update README with info about default types

* Imeplement support for protobufMessageNameForKeyByTopic

* fallback to FALLBACK_FORMATTER

* Add ability to publish message with protobuf key

* Change log levels to debug and add @nullable annotations

* Attempt at fixing documentation workflow

Co-authored-by: Ilya Kuramshin <ilia-2k@rambler.ru>
Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>
Co-authored-by: Roman Zabaluev <github@haarolean.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/backend type/enhancement En enhancement to an already existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support deserializing binary protobuf encoded message keys
3 participants