Skip to content

Commit

Permalink
ref: Use float in commit codec instead of complex datetime format (#290)
Browse files Browse the repository at this point in the history
Follow up to #289
  • Loading branch information
lynnagara authored Sep 29, 2023
1 parent f43a9d6 commit 0af36f3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions arroyo/backends/kafka/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class CommitCodec(Codec[KafkaPayload, Commit]):
def encode(self, value: Commit) -> KafkaPayload:
assert value.orig_message_ts is not None

payload = json.dumps(
{
"offset": value.offset,
"orig_message_ts": datetime.timestamp(value.orig_message_ts),
}
).encode("utf-8")

return KafkaPayload(
f"{value.partition.topic.name}:{value.partition.index}:{value.group}".encode(
"utf-8"
),
f"{value.offset}".encode("utf-8"),
[
(
"orig_message_ts",
datetime.strftime(value.orig_message_ts, DATETIME_FORMAT).encode(
"utf-8"
),
)
],
payload,
[],
)

def decode_legacy(self, value: KafkaPayload) -> Commit:
Expand Down

0 comments on commit 0af36f3

Please sign in to comment.