Azure / Azure/azure-functions-durable-python
create or get instance of orchestrator
- Vorherrschende Sprache
- Python
- Sterne
- 157
- Forks
- 70
- Ø Merge
- 2 T. 10 Std.
- Gemergte PRs (30 T.)
- 2
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
Lesen Sie zunächst die im Issue erwähnten Client-Methoden: get_status, start_new und raise_event. Definieren Sie, wie sich eine Create-or-get-Operation verhalten sollte, wenn mehrere Ereignisse auf dieselbe order_id abzielen, und überprüfen Sie anschließend, dass die resultierende Instanz das angeforderte Ereignis empfangen kann, ohne dass der Aufrufer die status-and-start-Sequenz ausführen muss.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api, backend
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100