Skip to content

Serde: Enable header modifications by custom serializer #346

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

Open
2 tasks done
MDzajaS opened this issue May 3, 2024 · 6 comments · May be fixed by #509
Open
2 tasks done

Serde: Enable header modifications by custom serializer #346

MDzajaS opened this issue May 3, 2024 · 6 comments · May be fixed by #509
Assignees
Labels
area/serde Serialization & Deserialization (plugins) scope/backend Related to backend changes status/triage/completed Automatic triage completed type/enhancement En enhancement/improvement to an already existing feature

Comments

@MDzajaS
Copy link

MDzajaS commented May 3, 2024

Issue submitter TODO list

  • I've searched for an already existing issues here
  • I'm running a supported version of the application which is listed here and the feature is not present there

Is your proposal related to a problem?

Some schema registries allow placing schema details in message headers instead of the payload. For example, Apicurio Registry serializer enables writing the artifact identifier to message headers.

However, when creating custom serializers that implement the io.kafbat.ui.serde.api.Serde interface with io.kafbat.ui.serde.api.Serde.Serializer, these interfaces don't provide direct access to message headers, which can be limiting.

Describe the feature you're interested in

Expend io.kafbat.ui.serde.api.Serde.Serializer to support message headers editing.

The least complicated solution would be to extend the serializer interface with additional method:

default byte[] serialize(String input, Headers headers) {
    return serialize(input);
}

Where Headers is org.apache.kafka.common.header.Headers, a mutable collection of headers.

If immutable headers are required (e.g., io.kafbat.ui.serde.api.RecordHeaders), then the interface might be extended with this method:

default SerializeResult serialize(String input, RecordHeaders headers) {
    return new SerializeResult(serialize(input), headers);
}

Where SerializeResult would be a new class that contains serialized message and headers.

By adding this method, io.kafbat.ui.serde.api.Serde.Serializer would move one step closer to Kafka's org.apache.kafka.common.serialization.Serializer interface.

Describe alternatives you've considered

There is no alternative for this feature. For instance, when using Apicurio Registry, if a serializer includes schema details directly in the message payload, it prepends a magic byte to the beginning of the message. If the deserializer doesn't expect this magic byte, it will not be able to read the message. So, to use Kafka-UI to produce messages with Apicurio Registry, it is necessary to modify message headers in the serializer.

Version you're running

2956664

Additional context

No response

@MDzajaS MDzajaS added status/triage Issues pending maintainers triage type/feature A brand new feature labels May 3, 2024
@kapybro kapybro bot added status/triage/manual Manual triage in progress area/serde Serialization & Deserialization (plugins) status/triage/completed Automatic triage completed and removed status/triage Issues pending maintainers triage labels May 3, 2024
Copy link

github-actions bot commented May 3, 2024

Hi MDzajaS! 👋

Welcome, and thank you for opening your first issue in the repo!

Please wait for triaging by our maintainers.

As development is carried out in our spare time, you can support us by sponsoring our activities or even funding the development of specific issues.
Sponsorship link

If you plan to raise a PR for this issue, please take a look at our contributing guide.

@Haarolean Haarolean added type/enhancement En enhancement/improvement to an already existing feature scope/backend Related to backend changes status/needs-attention Collective discussion is required and removed type/feature A brand new feature status/triage/manual Manual triage in progress labels May 3, 2024
@Haarolean Haarolean moved this to Backlog in Housekeeping May 3, 2024
@MDzaja
Copy link

MDzaja commented May 6, 2024

Hi, I'm writing from my private account. I took a look at the code and created a solution. I know that this issue is still not in the "Up for grabs" category, but I would like to be assigned to it once it is. Assign it to this account, and I'll make a PR where we can further discuss implementation details.

Thank you.

@Haarolean
Copy link
Member

@MDzaja I remember that we did not support headers on purpose but I don't remember the exact reason for it. Let me discuss it with the team this week and I'll get back to you.

@Haarolean Haarolean self-assigned this May 6, 2024
@Haarolean Haarolean moved this from Backlog to Active in Housekeeping May 6, 2024
@MDzaja
Copy link

MDzaja commented May 23, 2024

@Haarolean Is there any update on this issue.

@MDzaja
Copy link

MDzaja commented Jul 19, 2024

@Haarolean I've created a PR with an initial solution proposal on my personal fork of the repo. Is there any progress on considering this feature?

@Haarolean
Copy link
Member

@MDzaja sorry for the delay. We came to a conclusion that we didn't initially extend the interface for headers serialization just because we thought nobody would need that. Feel free to raise a PR, we'll take a look.

@Haarolean Haarolean assigned MDzaja and unassigned Haarolean Jul 21, 2024
@Haarolean Haarolean removed the status/needs-attention Collective discussion is required label Jul 21, 2024
@Haarolean Haarolean removed this from Housekeeping Jul 21, 2024
@Haarolean Haarolean moved this to Todo in Up for grabs Jul 21, 2024
@MDzaja MDzaja linked a pull request Jul 29, 2024 that will close this issue
13 tasks
@Haarolean Haarolean moved this from Todo to In Review in Up for grabs Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/serde Serialization & Deserialization (plugins) scope/backend Related to backend changes status/triage/completed Automatic triage completed type/enhancement En enhancement/improvement to an already existing feature
Projects
Status: In Review
Development

Successfully merging a pull request may close this issue.

3 participants