Skip to content

Add request types to allow for mediator pattern invocation of tasks#121

Open
jviau wants to merge 13 commits intomicrosoft:mainfrom
jviau:mediator
Open

Add request types to allow for mediator pattern invocation of tasks#121
jviau wants to merge 13 commits intomicrosoft:mainfrom
jviau:mediator

Conversation

@jviau
Copy link
Member

@jviau jviau commented Feb 7, 2023

This PR introduces the mediator pattern for invoking of orchestrations and activities. This allows for users to invoke activities and orchestrations via strongly-typed request objects and also to build up complex invocation patterns through additional TaskOrchestrationContext extension methods and more derived request types. Some examples would be:

  1. A polling pattern. We can introduce a ILongRuningActivityRequest<TResult> and a RunAsync extension method for it which will handle enqueuing a polling orchestration and polling activity.
  2. A paging activity pattern - we can leverage our AsyncPageable<T> classes to allow for paging over activities via IAsyncEnumerable<T> in your code.

This will also replace the code-generation approach for strongly typed orchestration/activity invocations. In my opinion, I prefer this route over code-generation. It is more flexible and avoids function-name conflicts. We can still explore how we can leverage code-generation to add value to this pattern though - but it will always be an optional addition.

resolves #73

TODO:

  • unit tests
  • samples
  • DurableTaskClient extension method for enqueuing orchestrations.

@jviau jviau requested a review from cgillum February 7, 2023 19:34
@YunchuWang
Copy link
Member

Hi @jviau , thanks for opening this! any update on this?

@jviau
Copy link
Member Author

jviau commented Dec 18, 2025

@YunchuWang this PR is quite old, would need some updates and could potentially leverage some new CSharp language features for an improved experience.

Next steps would be to first have a design discussion to see if the durable team wants to take this. I highly recommend it. In my usage of durable, it is far more convenient to use a mediator-style API then the source generated strongly-typed APIs. There is opportunity to leverage source-gen to help the mediator APIs also, so can get best of both worlds.

But if you are interested in this, lets sync with interested parties to go over what mediator offers and how it can be the path forward for durable APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt Mediator pattern to provide type-enforced invocations of orchestration and activities

3 participants