-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add support for UTC offset serialization/deserialization. #8
base: main
Are you sure you want to change the base?
Conversation
cpp/src/ffi_go/ir/deserializer.cpp
Outdated
auto try_deserialize_utc_offset_changes( | ||
BufferReader& ir_buf, | ||
encoded_tag_t& tag, | ||
Deserializer* deserializer | ||
) -> IRErrorCode { | ||
if (UtcOffsetChange != tag) { | ||
return IRErrorCode::IRErrorCode_Success; | ||
} | ||
|
||
UtcOffset utc_offset{0}; | ||
while (UtcOffsetChange == tag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just simplify this by taking out the while loop and drop the try
part. If we find multiple offset change packets in a row it will get handled by the next log event while loop anyway, so lets just keep this function as simple as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that this PR doesn't deprecate the tzid in the stream initialization yet. This is because the tzid is not formally deprecated in the CLP core. We can have another PR to update the serializer API so it doesn't take a tzid for creation.
This is fair reasoning, but lets just drop the tzid support completely to simplify things as no one is depending on continued tzid support.
encoded_tag_t tag{}; | ||
epoch_time_ms_t timestamp{}; | ||
IRErrorCode err{}; | ||
std::optional<clp::UtcOffset> utc_offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using std::optional
for deserialized utc offsets, and set it only when we return success. This will ensure the state of deserializer is unchanged if an error happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is possible to fail outside of deserialize_to_next_log_event
(even when it returns success), this isn't actually a complete defense... We would need to only update the stored utc_offset after we decide to return an updated ir position.
…d checking for repetiting.
Shall we close this PR now that we're moving to the new IR format which works on the basis of IR units? |
References
Description
In our latest IR format, we decided to deprecate IANA timezone ID and represent timezone information using UTC offset (in milliseconds) directly. This PR introduces the necessary changes to achieve this goal:
For IR serialization, we provide an API for users to serialize a packet indicating the UTC offset changes. This can be used when the timezone of a stream changes. By default, the offset is 0 (which indicates the UTC timezone). The effect of this change is that each IR stream doesn't stick to one timezone anymore.
For IR deserialization, we use the deserializer to keep track of the current UTC offset. For each deserialized log event, the UTC offset is stored as a member along with log message and timestamp. The effect of this change is that the timezone information is associated with each individual log event now.
Notice that this PR doesn't deprecate the tzid in the stream initialization yet. This is because the tzid is not formally deprecated in the CLP core. We can have another PR to update the serializer API so it doesn't take a tzid for creation.
Validation performed
Add unit tests for new features. Ensure serialization -> deserialization works as expected.