-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Change int64 nanoseconds to timestamppb in proto messages #7060
Milestone
Comments
This was referenced Sep 6, 2023
pgporada
added a commit
that referenced
this issue
Sep 15, 2023
Rename all of int64 timestamp fields to `<fieldname>NS` to indicate they are Unix nanosecond timestamps. Part 1 of 4 related to #7060
pgporada
added a commit
that referenced
this issue
Oct 11, 2023
* Adds new `google.protobuf.Timestamp` fields to each .proto file where we had been using `int64` fields as a timestamp. * Updates relevant gRPC messages to populate the new `google.protobuf.Timestamp` fields in addition to the old `int64` timestamp fields. * Added tests for each `<x>ToPB` and `PBto<x>` functions to ensure that new fields passed into a gRPC message arrive as intended. * Removed an unused error return from `PBToCert` and `PBToCertStatus` and cleaned up each call site. Built on-top of #7069 Part 2 of 4 related to #7060
jsha
pushed a commit
that referenced
this issue
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
We have lots of proto messages with fields like this:
boulder/sa/proto/sa.proto
Lines 197 to 202 in 66a4c11
Those int64s are nanoseconds since the unix epoch, which is so unclear that we have to comment it in every single proto file. Clients have to produce them with
boulder/ca/ca.go
Line 187 in 66a4c11
and servers have to parse them with
boulder/sa/sa.go
Line 166 in 66a4c11
And of course, just using an integer for this leads to fun times if you mess up, because the go zero value for time.Time{} is not the same thing as 0 nanoseconds since the unix epoch.
Thankfully, gRPC offers an alternative: timestamppb. We use it in a couple places:
boulder/sa/proto/sa.proto
Lines 354 to 359 in 66a4c11
Client code is much clearer:
boulder/crl/updater/updater.go
Line 371 in 66a4c11
as is accessing the value as a server:
boulder/sa/sa.go
Line 1004 in 66a4c11
So it would be nice to change all of our usages of int64 nanoseconds into timestamppb instead. I think the process will look like this:
notBefore
) to their name plus "NS" for nanoseconds (e.g.notBeforeNS
). This change should be safe and deployable because gRPC field names are not sent across the wire, they're process local, so no client or server cares what other clients or servers name the message fields.The text was updated successfully, but these errors were encountered: