Skip to content
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

grpc: Read timestamps from timestamppb fields instead of int64 fields #7121

Conversation

pgporada
Copy link
Member

Switch to reading grpc timestamp values from the new timestamppb protofbuf fields, completely ignoring the old int64 fields.

Part 3 of 4 for #7060

@pgporada pgporada requested a review from a team as a code owner October 26, 2023 18:02
@pgporada pgporada requested a review from jsha October 26, 2023 18:02
@pgporada
Copy link
Member Author

pgporada commented Oct 26, 2023

I've got some faulty IsZero() checks that I need to reevaluate for correctness.
Should be all fixed now.

Copy link
Contributor

@jsha jsha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

This makes me think we need some sort of guidance on how to express "optional" timestamps. Something like this:

Timestamps in protocol buffers must always be expressed as timestamppb.Timestamp. Timestamps must never be zero, in the sense of timestamp.AsTime().AsZero(). When a timestamp field is optional, absence must be expressed through the absence of the field, rather than presence with a zero value.

Senders must check that timestamps are non-zero before sending them. Receivers must check that timestamps are non-zero before accepting them.

@pgporada
Copy link
Member Author

pgporada commented Oct 30, 2023

This makes me think we need some sort of guidance on how to express "optional" timestamps. Something like this:

@jsha Where do you see this text being added? I think either docs/DESIGN.md or docs/CONTRIBUTING.md make sense.

@jsha
Copy link
Contributor

jsha commented Oct 30, 2023

CONTRIBUTING.md IMO

@pgporada
Copy link
Member Author

I'll get that added in the next PR which is a big cleanup of all the old int64 timestamp fields.

@pgporada pgporada merged commit fdaab3e into main Oct 30, 2023
20 checks passed
@pgporada pgporada deleted the i-can-say-that-i-dont-know-what-im-doing-but-i-cant-say-i-have-the-time branch October 30, 2023 19:51
jsha pushed a commit that referenced this pull request Nov 27, 2023
This is a cleanup PR finishing the migration from int64 timestamps to
protobuf `*timestamppb.Timestamps` by removing all usage of the old
int64 fields. In the previous PR
#7121 all fields were
switched to read from the protobuf timestamppb fields.

Adds a new case to `core.IsAnyNilOrZero` to check various properties of
a `*timestamppb.Timestamp` reducing the visual complexity for receivers.

Fixes #7060
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants