Skip to content

Conversation

@davidmrdavid
Copy link
Collaborator

@davidmrdavid davidmrdavid commented Jul 15, 2020

Addresses: #62

This PR enables sub-orchestrators and sub-orchestrators with retry options in Python Durable Functions 🥳 !
In implementing this, I had to review the structure of similar features, such as call_activity and call_activity_with_retry to see how those structured their implementation.

What became very clear is that there are many opportunities for refactoring, because there is a lot of shared logic between a function like call_activity and call_sub_orchestrator. Also, there's a lot of shared logic between a function like find_sub_orchestration_created and find_sub_orchestration_completed. To avoid deviating from the tried-and-tested approach, this PR only makes a first attempt at consolidating this shared logic: the find_sub_orchestrator_created, find_sub_orchestration_completed and find_sub_orchestration_failed are all abstracted into a core method find_sub_orchestrator which is able to handle all of their logic by simply including a specializing HistoryEventType as a new parameter.

To show how this approach subsumes the logic of those three functions, I make their implementation be simply a call to find_sub_orchestration with their appropriate HistoryEventType parameter. I believe this refactoring can be done for most awaitable and yieldable functions in this SDK, and I hope we can do that refactor in a future PR.

There are other opportunities for refactoring that I ignored, for time, but I think y'all will be able to spot them quickly.

I'm tracking the new refactoring task here: #167

One thing that is glaringly missing from this PR are tests for the sub-orchestrator. I can add them now, or add them in a future PR scheduled for the next release, especially considering that we are still in beta. Please let me know what you think, I don't mind either way.

@davidmrdavid davidmrdavid changed the title WIP: Sub-orchestrators Sub-orchestrators now available Jul 17, 2020
Copy link

@ConnorMcMahon ConnorMcMahon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for the most part, but let's look to see if we can get some tests for this.

@davidmrdavid
Copy link
Collaborator Author

Added a sample, and tests, and fixed errors. @ConnorMcMahon, when you get the chance, I'd appreciate another look :)

Copy link

@ConnorMcMahon ConnorMcMahon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@davidmrdavid davidmrdavid merged commit e70c357 into dev Jul 28, 2020
@davidmrdavid davidmrdavid deleted the djusto/suborchestrators branch July 28, 2020 22:52
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.

3 participants