feat: Added an implementation of Kafka Binding#114
Merged
dazuma merged 18 commits intocloudevents:mainfrom Feb 10, 2026
Merged
Conversation
…ration Scaffold the KafkaBinding class with initialize, self.default singleton, DEFAULT_KEY_MAPPER/DEFAULT_REVERSE_KEY_MAPPER constants, and formatter registration methods mirroring HttpBinding. Add require to cloud_events.rb and constructor unit tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Quick header-only check to determine if a Kafka message is likely a CloudEvent (checks for ce_specversion header or application/cloudevents content-type). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Decode CloudEvents from Kafka messages in binary content mode. Supports text/JSON data decoding, extension attributes, tombstones (nil value), configurable reverse_key_mapper for partition key mapping, and proper error handling for bad specversion and non-CE messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Decode CloudEvents from Kafka messages in structured content mode. Supports JSON format, charset variants, opaque fallback for unrecognized formats, and reverse_key_mapper application to structured events. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Encode CloudEvents to Kafka messages in binary content mode. Supports text/JSON data encoding, extension attributes, tombstones (nil value for no data), and configurable key_mapper for partition key derivation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Encode CloudEvents to Kafka messages in structured content mode using named format encoders. Supports opaque event passthrough and key_mapper in structured mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Verify encode-then-decode round trips for binary mode, structured mode, and with partitionkey extension attribute. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Replace pending Kafka steps with real implementations that decode Kafka messages using KafkaBinding.default. All 7 conformance scenarios (HTTP and Kafka) now pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Use parenthesized raise calls, move constant above private modifier, extract populate_data_attributes to reduce method length, and fix SymbolProc offense in tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Kafka protocol binding to the CloudEvents Ruby SDK, enabling encoding/decoding CloudEvents to/from Kafka message hashes (binary and structured modes), and wires it into the library plus conformance steps/tests.
Changes:
- Introduces
CloudEvents::KafkaBindingwith binary/structured encoding & decoding, tombstone handling, and configurable key mapping. - Adds a comprehensive Minitest suite covering Kafka binding behavior and round-trips.
- Updates Cucumber step definitions and project docs to reflect Kafka binding support, and requires the binding from
cloud_events.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/cloud_events/kafka_binding.rb | New Kafka binding implementation (encode/decode, formatter registry, key mapping). |
| lib/cloud_events.rb | Requires the new Kafka binding so it’s available via require "cloud_events". |
| test/test_kafka_binding.rb | New unit tests validating Kafka binding behavior across modes and edge cases. |
| features/step_definitions/steps.rb | Enables Kafka binding in conformance steps (no longer pending). |
| CLAUDE.md | Documents Kafka binding capabilities and usage patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace raw string comparison with ContentType parsing so that mixed-case content-type values (e.g. Application/CloudEvents+JSON) are correctly detected as CloudEvents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Add BatchNotSupportedError to the error hierarchy and raise it from KafkaBinding#decode_event when given an application/cloudevents-batch content type, since the Kafka protocol binding does not support batch content mode per the spec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
The binary decode path already raised SpecVersionError for non-1.x spec versions, but structured mode would accept and return a V0 event. Now decode_structured_content checks the decoded event's spec_version and raises SpecVersionError if it does not start with "1". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Raise SpecVersionError when encode_event receives an event with a specversion that does not start with "1", ensuring V0.3 events cannot be encoded via the Kafka binding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Daniel Azuma <dazuma@gmail.com>
Signed-off-by: Daniel Azuma <dazuma@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Daniel Azuma <dazuma@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Done in collaboration with Claude Code.
Closes #80.