You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/19 01:29:28 UTC
[GitHub] [pulsar-client-go] aymkhalil opened a new pull request, #865: Fix marshalling time.Time{} to uint64
aymkhalil opened a new pull request, #865:
URL: https://github.com/apache/pulsar-client-go/pull/865
Signed-off-by: Ayman Khalil <ay...@datastax.com>
### Motivation
When producing messages via the go client, if the user doesn't assign an explicit `EventTime` to the message, the following `uint64` will end up on the wire:
`11651379494838`
This is because [TimestampMillis](https://github.com/aymkhalil/pulsar-client-go/blob/7fbfbaac9532efd3dbab7f768daca045a86d9966/pulsar/internal/utils.go#L30) calls UnixNano, but UnixNano on the zero Time is undefined.
[This](https://go.dev/play/p/mDPKyxFCKLL) code mimic what happens when TimestampMillis is called on the Zero value
Please note that go consumers (like this[ ](https://github.com/apache/pulsar-client-go/blob/a013ff0b7353fab87a7eb7599377bb06b46eb7b7/pulsar/consumer_test.go#L624)test) will NOT notice this issue, because this is handled correctly when [unmarshalling](https://github.com/apache/pulsar-client-go/blob/649d992f26349835d7dc1e7632d60e399bd4eaa5/pulsar/internal/pulsar_proto/PulsarApi.pb.go#L1634) on the consumer side
### Modifications
*Describe the modifications you've done.*
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
This change is already covered by existing tests, such as https://github.com/apache/pulsar-client-go/blob/a013ff0b7353fab87a7eb7599377bb06b46eb7b7/pulsar/consumer_test.go#L593. Also added simple unit test to verify `time.Time{}` marshals to `0`
### Does this pull request potentially affect one of the following parts:
*If `yes` was chosen, please highlight the changes*
- Dependencies (does it add or upgrade a dependency): ( no)
- The public API: ( no)
- The schema: ( no )
- The default values of configurations: (no)
- The wire protocol: (yes) : The wire will have 0 instead of 11651379494838 for unset EventTime values. This behavior is noticed only by non-go consumers.
### Documentation
- Does this pull request introduce a new feature? ( no)
- If yes, how is the feature documented? (not applicable / docs / GoDocs / not documented)
- If a feature is not applicable for documentation, explain why?
- If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] aymkhalil commented on pull request #865: Fix marshalling time.Time{} to uint64
Posted by GitBox <gi...@apache.org>.
aymkhalil commented on PR #865:
URL: https://github.com/apache/pulsar-client-go/pull/865#issuecomment-1284205818
@liangyuanpeng thanks for confirming. Seems this PR is optional, I think it is better to protect the TimestampMillis with the `IsZero` because it relied on `t.UnixNano()` which undefined on zero, but I don't have a strong preference tbh. Let me know, otherwise will just close this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] liangyuanpeng commented on pull request #865: Fix marshalling time.Time{} to uint64
Posted by GitBox <gi...@apache.org>.
liangyuanpeng commented on PR #865:
URL: https://github.com/apache/pulsar-client-go/pull/865#issuecomment-1283770320
does https://github.com/apache/pulsar-client-go/pull/843 addresses the same issue?
@aymkhalil Yes, I have intentionally left this unmodified because it is customary for golang developers to use `IsZero()` judgments. And this change also look good to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] eolivelli merged pull request #865: Fix marshalling time.Time{} to uint64
Posted by GitBox <gi...@apache.org>.
eolivelli merged PR #865:
URL: https://github.com/apache/pulsar-client-go/pull/865
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] aymkhalil commented on pull request #865: Fix marshalling time.Time{} to uint64
Posted by GitBox <gi...@apache.org>.
aymkhalil commented on PR #865:
URL: https://github.com/apache/pulsar-client-go/pull/865#issuecomment-1283329614
@liangyuanpeng does https://github.com/apache/pulsar-client-go/pull/843 solve the same issue? seems the issue I'm solving was reported on client `v0.8.1`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org