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
Utc time #1943
Utc time #1943
Conversation
server/jetstream_api.go
Outdated
Expires time.Time `json:"expires,omitempty"` | ||
Batch int `json:"batch,omitempty"` | ||
NoWait bool `json:"no_wait,omitempty"` | ||
Expires time.Duration `json:"expires,omitempty"` |
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.
fyi for Java client that this one would change /fyi @ColinSullivan1 @scottf
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.
@matthiashanel can we switch this change into a different branch? I think there is consensus on changing this one to duration so we can merge and integrate the change into the clients, but not sure right now on the side effects of changing some of the other ones.
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.
ok, will move the duration into a separate branch
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.
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.
This is quite a change, not talking about code changes, but may surprise some users.
As for having a custom type with own Unmarshal, I would not go there if possible. I had a case where I added a custom marshal, but this because really tricky when using embedded types. For instance if Foo embeds Bar and you have a (un)marshaljson for Bar, then it will apply to Foo which means that all fields from Foo will not be marshaled/unmarshaled, etc..
7d9cf73
to
57b5bcc
Compare
@kozlovic yeah with Unmarshal this became quite unruly. I moved the duration change out as per Wally's suggestion. Now this deals with time only. |
But still, this is what I meant, that changing time to UTC() may still cause issues/surprises, no? I mean what if users had apps/scripts checking those? That may break no? That being said, 2.2.0 would be a good time and could be listed as a |
I think just converting to UTC everywhere we need is fine, that's what we should have done before. We might also look at the places we receive timeTime from the user and converting those before storing, this should be fine and safe. So to me this seems fine - if we already also force all user input to be utc before sticking it into our internal structures? Definitely would not be fine with custom marshallers this late. I wonder if we need a utility function for getting |
@ripienaar I will add utcNow() and replace time.Now().UTC() with it. |
well best ask Ivan or Derek what they think about that :) |
@derekcollison do you have an opinion on this? |
I agree just make sure all time.Now() have a UTC() on the end is best for now. |
This change adds .UTC wherever needed (time is exposed externally). Where we end up using .Unix() or .UnixNano() we essentially convert to UTC already. List remaining calls: |
This also applies to times that end up in that json. Where applicable moved time.Now() to where it is used. Moved calls to .UTC() to where time is created it that time is converted later anyway. Signed-off-by: Matthias Hanel <mh@synadia.com>
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.
LGTM
In #1943 it was adopted to use `UTC()` in some timestamps, but an unintended side effect from this is that it strips the monotonic time, so it can be prone to clock skews when subtracting time in other areas of the code. golang/go@e5646b2
In #1943 it was adopted to use `UTC()` in some timestamps, but an unintended side effect from this is that it strips the monotonic time (golang/go@e5646b2), so it can be prone to clock skews when subtracting time in other areas of the code.
In nats-io#1943 it was adopted to use `UTC()` in some timestamps, but an unintended side effect from this is that it strips the monotonic time, so it can be prone to clock skews when subtracting time in other areas of the code. golang/go@e5646b2
In nats-io#1943 it was adopted to use `UTC()` in some timestamps, but an unintended side effect from this is that it strips the monotonic time, so it can be prone to clock skews when subtracting time in other areas of the code. golang/go@e5646b2
In nats-io#1943 it was adopted to use `UTC()` in some timestamps, but an unintended side effect from this is that it strips the monotonic time, so it can be prone to clock skews when subtracting time in other areas of the code. golang/go@e5646b2
I went through all structs with json fields and replaced them with a custom type UtcTime.
From there I changed all occurrences of time.Time that end up in such a struct as well.
Because if was a different type the changes where rather large.
Because these changes made it all the way to events/monitoring, the new type would break backwards compatibility for the embedding use case. (See commit one of this PR)
Therefore I reverted and stuck with time.Time but added .UTC wherever it was missing.
If we wanted we could use the type (pasted below) in jetstream only where it does not interfere with embedding yet.
The implementation would make sure we use UTC when writing json and only accept times when in UTC.
Comments?