event-driven-dotnet / EventDriven.EventBus.Dapr

Event bus abstraction over Dapr pub/sub
MIT License
22 stars 5 forks source link

Question on "subscribers" in "pub/sub" #16

Closed Shawn-Fan closed 3 years ago

Shawn-Fan commented 3 years ago

Hi Anthony, Thanks for your great library. not sure if it is a proper question here, or else please ignore it.

As what you mentioned, subscribers need to decorate controller actions with the Topic attribute and the source code is in DaprEndpointRouteBuilderExtensions.cs. I am wondering if it is a good idea to write a "subscribers" method (just like "publish~" in DaprClientgrpc.cs) directly?

tonysneed commented 3 years ago

In DaprEndpointRouteBuilderExtensions we map a post endpoint for each topic, so there is no need to decorate controller actions with a Topic attribute, and no need for modifying DaprClientgrpc.cs.

I hope this answers your question.

Shawn-Fan commented 3 years ago

Yeah, "subscripber" functionality declared in startup.cs and mapped to controller actions automatically. It looks like it is very convenient but I am not sure if it is a better way than a seperate "subscribers" method.

Thanks.

tonysneed commented 3 years ago

Appreciate your question. IEventBus offers an abstraction so that both publishers and subscribers do not need to be aware of Dapr (except of course in Startup).