-
Notifications
You must be signed in to change notification settings - Fork 334
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
Add support for subscribing to raw messages #709
Comments
@rynowak Any thoughts on this? |
We'd be happy to accept a PR that adds one or both of these options.
I would suggest adding a new overload that takes an options class. This is preferrable to a boolean argument for scannability and makes it easy to add other settings in the future without changing the signature. Something like: public static IEndpointConventionBuilder MapSubscribeHandler(this IEndpointRouteBuilder endpoints, SubscribeOptions options)
{
}
public class SubscribeOptions
{
public bool EnableRawPayload { get; set; }
}
It seems really useful to have both of these options. You have the ability to configure globally, as well as per-topic for the app. I'd suggest something like: public class TopicAttribute : Attribute, ITopicMetadata, IRawTopicMetadata
{
...
public bool? EnableRawPayload { get; set; }
}
public interface IRawTopicMetadata
{
bool? EnableRawPayload { get; set; }
} The extra interface is needed because we can't add properties to The attribute uses
|
I often wonder why method signatures like this don't do more of what HTTP did with the payload . Don't get me wrong, I think Http is so loosely opinionated that it results in so many bad practices.
That said, why not have that overloaded parameter do what cloud events did, in that the interface describes the contract as well as the payload?
With three properties, your done
Contract Name,
Contract Version,
MessagePayload (string, as I now serialize to JSON after the demise if binary serialization)
Then in the SDK, you can have either strongly typed methods which package to this contract, or expose a serialization class which populates these three properties, or simply expose this contract and never have a breaking change.
Serious question as to why this isn't considered in more publicly exposed API for versioning?
Richard
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Ryan Nowak ***@***.***>
Sent: Tuesday, July 13, 2021 9:07:17 AM
To: dapr/dotnet-sdk ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [dapr/dotnet-sdk] Add support for subscribing to raw messages (#709)
Hi @sapinderpalsingh<https://github.com/sapinderpalsingh>
We can either change the current MapSubscribeHandler by adding a boolean flag to it or we can create a new extension method to support subscribing to raw messages.
I would suggest adding a new overload that takes an options class. This is preferrable to a boolean argument for scannability and makes it easy to add other settings in the future without changing the signature. Something like:
public static IEndpointConventionBuilder MapSubscribeHandler(this IEndpointRouteBuilder endpoints, SubscribeOptions options)
{
}
public class SubscribeOptions
{
public bool EnableRawPayload { get; set; }
}
Also third option is configuring it at the topic level by adding one more boolean argument for processing raw messages, which can provide more flexibility where we can have one topic configured for cloud events and other for raw messages.
It seems really useful to have both of these options. You have the ability to configure globally, as well as per-topic for the app.
I'd suggest something like:
public class TopicAttribute : Attribute, ITopicMetadata, IRawTopicMetadata
{
...
public bool? EnableRawPayload { get; set; }
}
public interface IRawTopicMetadata
{
bool? EnableRawPayload { get; set; }
}
The extra interface is needed because we can't add properties to ITopicMetadata without a breaking change.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#709 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAEVJVJX64MNTREJ7RX3LTLTXRQDLANCNFSM47252MFA>.
|
Thanks @rynowak , I am working on this and will update you once I submit the PR. |
@codeputer - it sounds like you're talking about something completely different from this issue. I'd suggest opening a new issue and using that to discuss. |
@rynowak @sapinderpalsingh I have posted an issue here #989 |
Describe the proposal
Dapr 1.2 supports subscribing to raw messages which are non cloud events. We can either change the current
MapSubscribeHandler
by adding a boolean flag to it or we can create a new extension method to support subscribing to raw messages.Also third option is configuring it at the topic level by adding one more boolean argument for processing raw messages, which can provide more flexibility where we can have one topic configured for cloud events and other for raw messages.
Currently i have created a separate extension method to support this in our recent client engagement.
The text was updated successfully, but these errors were encountered: