Skip to content

Commit

Permalink
Refactor the kafka producer-message constructing logic
Browse files Browse the repository at this point in the history
Co-authored-by: Nipuna Ransinghe  <[email protected]>
  • Loading branch information
ayeshLK and NipunaRanasinghe authored Nov 20, 2024
1 parent 3550385 commit c2dfddd
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions examples/kafka-hub/hub/modules/persistence/persistence.bal
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,5 @@ isolated function produceKafkaMessage(string topicName, json payload,
isolated function getProducerMsg(string topic, json payload,
map<string|string[]> headers) returns kafka:AnydataProducerRecord {
byte[] value = payload.toJsonString().toBytes();
if headers.length() == 0 {
return { topic, value };
}
return { topic, value, headers };
return headers.length() == 0 ? { topic, value } : { topic, value, headers };
}

0 comments on commit c2dfddd

Please sign in to comment.