Skip to content

Commit

Permalink
Merge pull request #1862 from falnyr/patch-1
Browse files Browse the repository at this point in the history
fix: key was missing in kafka record
  • Loading branch information
mnapoli authored Sep 25, 2024
2 parents a4b7744 + cffe79f commit a8eaf87
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Event/Kafka/KafkaRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function __construct(mixed $record)
$this->record = $record;
}

public function getKey(): string
{
return $this->record['key'];
}

public function getTopic(): string
{
return $this->record['topic'];
Expand Down
1 change: 1 addition & 0 deletions tests/Event/Kafka/KafkaEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function test canonical case()
self::assertSame(15, $record->getOffset());
self::assertSame(1545084650987, $record->getTimestamp());
self::assertSame('Hello, this is a test.', $record->getValue());
self::assertSame('SGVsbG8gV29ybGQ=', $record->getKey());
self::assertSame(
[
'type' => 'core',
Expand Down
1 change: 1 addition & 0 deletions tests/Event/Kafka/kafka.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"offset":15,
"timestamp":1545084650987,
"timestampType":"CREATE_TIME",
"key": "SGVsbG8gV29ybGQ=",
"value":"SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==",
"headers":[
{
Expand Down

0 comments on commit a8eaf87

Please sign in to comment.