Azure / Azure/azure-functions-durable-python
create or get instance of orchestrator
- Langage dominant
- Python
- Étoiles
- 157
- Forks
- 70
- Merge moyen
- 2 j 10 h
- PR mergées (30 j)
- 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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par lire les méthodes du client mentionnées dans l’issue : get_status, start_new et raise_event. Définissez le comportement attendu d’une opération de création ou de récupération lorsque plusieurs événements ciblent le même order_id, puis vérifiez que l’instance résultante peut recevoir l’événement demandé sans que l’appelant ait à exécuter la séquence status-and-start.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- api, backend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100