Skip to content

Conversation

@kapilthareja
Copy link
Contributor

@kapilthareja kapilthareja commented Oct 24, 2025

Summary

This pull request enhances the bulk publishing feature to natively support raw byte[] payloads through the generic BulkPublishEventAsync method. This provides a unified and efficient way for developers to publish both structured (JSON) and raw binary data in a single bulk operation.

Key Changes

Enhanced MakeBulkPublishRequest Logic: The internal MakeBulkPublishRequest method in DaprClientGrpc.cs has been updated to inspect the type of each event being published.
This change improves the flexibility of the bulk publish API without introducing a new method, making the SDK cleaner and more intuitive.

Description

When an event is a byte[], it is now correctly handled as raw binary data. The Content-Type is set to application/octet-stream, and the payload is sent directly, bypassing JSON serialization. For all other event types, the existing behavior of serializing the payload to JSON is preserved. Added Unit Test: A new test case, BulkPublishEventAsync_CanPublishTopicWithByteArrayEvents, has been added to BulkPublishEventApiTest.cs. This test validates that calling BulkPublishEventAsync with a List<byte[]> correctly constructs the gRPC request with the application/octet-stream content type and ensures the byte payloads are sent unmodified.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Kapil Thareja and others added 2 commits October 23, 2025 21:44
Summary
This pull request enhances the bulk publishing feature to natively support raw byte[] payloads through the generic BulkPublishEventAsync<TValue> method. This provides a unified and efficient way for developers to publish both structured (JSON) and raw binary data in a single bulk operation.

Key Changes
Enhanced MakeBulkPublishRequest Logic: The internal MakeBulkPublishRequest method in DaprClientGrpc.cs has been updated to inspect the type of each event being published.

When an event is a byte[], it is now correctly handled as raw binary data. The Content-Type is set to application/octet-stream, and the payload is sent directly, bypassing JSON serialization.
For all other event types, the existing behavior of serializing the payload to JSON is preserved.
Added Unit Test: A new test case, BulkPublishEventAsync_CanPublishTopicWithByteArrayEvents, has been added to BulkPublishEventApiTest.cs. This test validates that calling BulkPublishEventAsync with a List<byte[]> correctly constructs the gRPC request with the application/octet-stream content type and ensures the byte payloads are sent unmodified.

This change improves the flexibility of the bulk publish API without introducing a new method, making the SDK cleaner and more intuitive.
@kapilthareja kapilthareja marked this pull request as ready for review October 24, 2025 03:58
@kapilthareja kapilthareja requested review from a team as code owners October 24, 2025 03:58
@WhitWaldo
Copy link
Contributor

@kapilthareja Could you please fix the DCO on your commits?

Kapil Thareja and others added 12 commits October 24, 2025 12:50
Summary
This pull request enhances the bulk publishing feature to natively support raw byte[] payloads through the generic BulkPublishEventAsync<TValue> method. This provides a unified and efficient way for developers to publish both structured (JSON) and raw binary data in a single bulk operation.

Key Changes
Enhanced MakeBulkPublishRequest Logic: The internal MakeBulkPublishRequest method in DaprClientGrpc.cs has been updated to inspect the type of each event being published.

When an event is a byte[], it is now correctly handled as raw binary data. The Content-Type is set to application/octet-stream, and the payload is sent directly, bypassing JSON serialization.
For all other event types, the existing behavior of serializing the payload to JSON is preserved.
Added Unit Test: A new test case, BulkPublishEventAsync_CanPublishTopicWithByteArrayEvents, has been added to BulkPublishEventApiTest.cs. This test validates that calling BulkPublishEventAsync with a List<byte[]> correctly constructs the gRPC request with the application/octet-stream content type and ensures the byte payloads are sent unmodified.

This change improves the flexibility of the bulk publish API without introducing a new method, making the SDK cleaner and more intuitive.

Signed-off-by: Kapil Thareja <[email protected]>
* Enhance bulk publish to support raw byte array payload

Signed-off-by: Kapil Thareja <[email protected]>
* Enhance bulk publish to support raw byte array payload

Signed-off-by: Kapil Thareja <[email protected]>
* Enhance bulk publish to support raw byte array payload

Signed-off-by: Kapil Thareja <[email protected]>
…Enhance bulk publish to support raw byte array payload Signed-off-by: Kapil Thareja <[email protected]>

Enhance bulk publish to support raw byte array payload (dapr#1645)

* Enhance bulk publish to support raw byte array payload

Signed-off-by: Kapil Thareja <[email protected]>

Signed-off-by: kapilthareja <[email protected]>
kapilthareja added a commit to kapilthareja/dotnet-sdk that referenced this pull request Oct 24, 2025
* Enhance bulk publish to support raw byte array payload

Signed-off-by: Kapil Thareja <[email protected]>
WhitWaldo pushed a commit that referenced this pull request Nov 7, 2025
* Enhance bulk publish to support raw byte array payload

Signed-off-by: Kapil Thareja <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants