Change type Buffer into Uint8Array in publishMessage #1707
Labels
api: pubsub
Issues related to the googleapis/nodejs-pubsub API.
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is your feature request related to a problem? Please describe.
In
publishMessage
method of Topic, it checks if data is instance of Buffer.Some of modern serialization library uses Uint8Array as return value instead of Buffer. Although we can change it into Buffer using
Buffer.from
, it will copy Arraybuffer, which causes performance issue.Since Buffer is subclass of Uint8Array, I think it can be changed into
data && !(data instanceof Uint8Array)
.Describe the solution you'd like
Change src/publisher/index.ts L195 into
if (data && !(data instanceof Uint8Array)) {
.Describe alternatives you've considered
We can change Uint8Array into Buffer using
Buffer.from
method, but it will 'copy' array and create new one.Additional context
.
The text was updated successfully, but these errors were encountered: