[Event Hubs] Update the create and send batch as per feedback#4346
[Event Hubs] Update the create and send batch as per feedback#4346ShivangiReja merged 11 commits intoAzure:masterfrom
Conversation
…ing producers that were created using a partition id` when creating batch instead of send()
Co-Authored-By: Ramya Rao <ramya.rao.a@outlook.com>
Co-Authored-By: Ramya Rao <ramya.rao.a@outlook.com>
Co-Authored-By: Ramya Rao <ramya.rao.a@outlook.com>
…r right after _throwIfSenderOrConnectionClosed
| log.error(`[${this._context.connectionId}] Empty array was passed. No events to send.`); | ||
| return; | ||
| } | ||
| if (eventData instanceof EventDataBatch && !eventData.batchMessage) { |
There was a problem hiding this comment.
Now that we have count exposed on the batch, maybe we should check the count instead of !eventData.batchMessage. We can also initialize the eventData.batchMessage to an empty Buffer in the constructor for EventDataBatch and remove the undefined from its type. That way no one ever has to check for !eventData.batchMessage.
Thoguhts?
There was a problem hiding this comment.
Now that we have count exposed on the batch, maybe we should check the count instead of !eventData.batchMessage.
Agreed!
We can also initialize the eventData.batchMessage to an empty Buffer in the constructor for EventDataBatch and remove the undefined from its type
It will not add any extra value, right?
There was a problem hiding this comment.
The extra value is that we dont have to check for if (eventData.batchMessage) or use eventData.batchMessage! before using that property
There was a problem hiding this comment.
If we initialize batchMessage = Buffer.alloc(); in the EventDataBatch constructor, It will create a new buffer object of the specified size(in our case empty Buffer object).
Buffer object will use memory, so my point was why waste memory? If It is not adding any extra value other than this check if (eventData.batchMessage) or eventData.batchMessage!
Partition key is not supported when using producers that were created using a partition id when creating batch instead of send()|
There are some merge conflicts here, can you take a look? |
Co-Authored-By: Ramya Rao <ramya.rao.a@outlook.com>
This PR updates the following:
Partition key is not supported when using producers that were created using a partition idwhen creating batch instead of send()countand getter forcountin EventDataBatch which returns number of events in the batchsize->sizeInBytesinEventDataBatchFor more details: #4307, #4302