-
Notifications
You must be signed in to change notification settings - Fork 604
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
No 'publishTime' field in PubSub messages #1837
Comments
The issue was worth the wait :) And a PR would be great! What do you think about naming it 'timestamp' instead of publishTime? |
Thanks @stephenplusplus! It's only a few lines to add that & update the doc comments, so I'll make a PR in a mo. Personally I prefer |
I think start with |
Sure thing. However on looking into it I've realised that I also just read the 'Contributing' section in a bit more detail, and it's a fair bit more involved than I thought - not just the testing, but even just clearing the CLA is kind of a big deal, especially for a few lines of code. On top of that it seems the pubsub client requires So it might take me a little longer than I expected to do this. Will look further into it tomorrow. Thanks for taking the time to respond! |
Good call, we should convert it to a Date object. Here's a snippet from the Datastore API (https://github.com/GoogleCloudPlatform/google-cloud-node/blob/baf0986e58a667b2cf406c07fd15171857e92afe/packages/datastore/src/entity.js#L201): var milliseconds = parseInt(value.nanos, 10) / 1e6;
return new Date(parseInt(value.seconds, 10) * 1000 + milliseconds);
Yeah :\ Let me know what you decide. Even just the issue and idea is helpful enough, so no worries.
Yeah, we can ignore that for now. We will update all of our modules soon which depend on that. |
Thanks @stephenplusplus, that's great. I've made a commit in my fork (and pasted the diffs in a gist) which does the conversion, tests it, and inserts a couple doc lines in relevant examples. I won't be able to get on to the CLA and system test stuff today; it's literally a few lines though, so if it's in line with what you expect, then if anyone who'd already done the CLA wanted to make a PR with their version of the changes that'd be fine with me :-) |
Thank you very much! I've sent a PR in #1843. Feel free to take a look! |
Looks good to me, thanks @stephenplusplus 👍 |
Hi folks, as per the doc, the
message
objects provided to thesubscription.on( 'message' )
listener/callback function don't contain thepublishTime
field:IIUC PubSub doesn't guarantee message ordering, so having that timestamp in the messages would help with trying to buffer & order at the recipient end - but it's not there. From the comment it seems this was deliberately not included in the node.js client message implementation:
Is this still desired? Might it make it in? Would a PR to include it be welcome, or is there a strong reason why it's not there?
Thanks!
Igor
Environment details
alpine:latest
inside Docker container running on OSXnpm install --save @google-cloud/pubsub
)Steps to reproduce
google-cloud/pubsub
console.log( JSON.stringify( message ) );
I added
console.log( msg );
on line 341 ofnode_modules/@google-cloud/pubsub/src/subscription.js
to check thepublishTime
data is returned by PubSub, and it certainly seems to be:(NB when running against the emulator, the
nanos
field is always 0.)The text was updated successfully, but these errors were encountered: