Azure / Azure/azure-functions-durable-python

create or get instance of orchestrator

Open
#137 2 comments 0 reactions 0 assignees View on GitHub
Enhancement P3
Dominant language
Python
Stars
157
Forks
70
Avg merge
2d 10h
Merged PRs (30d)
2

Description

I was creating a orchestration that was waiting for three events (from EventGrid) and then calls another two activities and got it working, but noticed that my code is needlessly complex, this is what happens in my trigger (with EventHubTrigger), after creating a blob object with a order_id attribute, I need this code:
```python
try:
status = await client.get_status(blob.order_id)
instance_id = status.instance_id
except Exception:
instance_id = await client.start_new("Orchestrator", blob.order_id, None)
if instance_id:
await client.raise_event(instance_id, blob.file_type, True)
else:
logging.error("Could not start orchestrator for instance: %s", blob.order_id)
```

I would expect either the `client.start_new` call to either create a new one or get an existing one, or for there to be a something like a `get_or_start_new` function on client.

The reason I needed to do it like this is that I have a single input (EventGrid triggered by storage) and need to both start a orchestration and raise an event, I do have an instance_id I can use to align the different events to the same orchestrator instance but the fact that I can't just have this function call `start_new` three times is very unintuitive and hard to debug.

Contributor guide

Open the contributing guide

Research direction

Start by reading the client methods mentioned in the issue: get_status, start_new, and raise_event. Define how a create-or-get operation should behave when several events target the same order_id, then verify that the resulting instance can receive the requested event without the caller's status-and-start sequence.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.