dotnet-sdk icon indicating copy to clipboard operation
dotnet-sdk copied to clipboard

Support publishing other content type than json

Open mtaghavi2005 opened this issue 4 years ago • 2 comments

We are considering to publish custom CloudEvent to the broker, but currently sdk doesn't support it (The only supported content type is json). It would be great if we could do something similar to invokeBinding and pass ContentType and Data in a raw format encapsulated into the request object to the publishAsync method. It can also address #718 as well)

DaprClientGrpc image

Suggestion:

  public class PublishEventRequest
    {
        public PublishEventRequest(string pubsubName, string topicName)
        {
            ArgumentVerifier.ThrowIfNullOrEmpty(pubsubName, nameof(pubsubName));
            ArgumentVerifier.ThrowIfNullOrEmpty(topicName, nameof(topicName));

            this.PubSubName = pubsubName;
            this.TopicName = topicName;

            this.Metadata = new Dictionary<string, string>();
        }

        public string PubSubName { get; }

        public string TopicName { get; }

        public ReadOnlyMemory<byte> Data { get; set; }

        public string DataContentType { get; set; }

        public Dictionary<string, string> Metadata { get; }
    }
    
Task PublishEventAsync(PublishEventRequest publishEventRequest, CancellationToken cancellationToken = default)

mtaghavi2005 avatar Jul 22 '21 11:07 mtaghavi2005

@msfussell can you please add this issue to our project?

fabistb avatar Jul 22 '21 11:07 fabistb

We'll add a new method that will skip the json serialization portion and work on raw bytes instead.

halspang avatar Nov 12 '21 19:11 halspang

@fabistb - As we discussed in the last call, this issue seems to be really nice to have feature. Please review and close the issue as appropriate.

rabollin avatar Jun 26 '23 08:06 rabollin

@rabollin , thanks for getting back here. I checked with @mtaghavi2005 and this topic isn't relevant from our point of view anymore and the issue can be closed.

fabistb avatar Jun 26 '23 13:06 fabistb