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

pubish() should be able to take a JS object as input #121

Closed
steren opened this issue Apr 28, 2018 · 7 comments
Closed

pubish() should be able to take a JS object as input #121

steren opened this issue Apr 28, 2018 · 7 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: enhancement type: question Request for information or clarification. Not an issue.

Comments

@steren
Copy link

steren commented Apr 28, 2018

I wanted to publish a JSON payload to a topic:

Observed:

const data = JSON.stringify({ hello : "world" });
const dataBuffer = Buffer.from(data);
await publisher.publish(dataBuffer);

Expected:

await publisher.publish({ hello : "world" });

@callmehiphop
Copy link
Contributor

We used to support this, but the PubSub team specifically requested we remove this feature and only accept Buffers. I'm not sure if they still have strong feelings on this subject. @kir-titievsky any thoughts here?

@callmehiphop callmehiphop added priority: p2 Moderately-important priority. Fix may not be included in next release. type: enhancement type: question Request for information or clarification. Not an issue. labels Apr 30, 2018
@kir-titievsky
Copy link

I don't remember why we said this. But I presume that one can have non-json Buffers.

@steren
Copy link
Author

steren commented Apr 30, 2018

To clarify: I am not asking for .publish() to only take JS objects, I am asking that when I pass a JS object to publish()that is not a buffer, it gets transformed into a buffer for me.

@stephenplusplus
Copy link
Contributor

Here's the origin discussion for anyone that can see it: https://docs.google.com/document/d/12QHQnF7ThXcNnFTOyQgsmygAYk8QiWvPjUfoYs_kKng/edit?disco=AAAABEGnPOE

@kir-titievsky
Copy link

kir-titievsky commented May 1, 2018 via email

@steren
Copy link
Author

steren commented May 1, 2018

This would improve the developer experience by simplifying a very common use case. See my first message in this issue to understand the difference.

@marcusradell
Copy link

I'd love for it to be another method name for such a function, like .publishJson().
Having the same method do multiple things and then sending it over the wire makes things harder to debug when someone sends in the wrong argument. And not even typescript will help in this case since any object shape will be allowed.

stephenplusplus pushed a commit to stephenplusplus/nodejs-pubsub that referenced this issue Aug 31, 2018
@JustinBeckwith JustinBeckwith added the 🚨 This issue needs some love. label Oct 25, 2018
@google-cloud-label-sync google-cloud-label-sync bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Jan 31, 2020
feywind pushed a commit to feywind/nodejs-pubsub that referenced this issue Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: enhancement type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

6 participants