Azure / azure-functions-durable-js

JavaScript library for using the Durable Functions bindings
https://www.npmjs.com/package/durable-functions
MIT License
128 stars 47 forks source link

Provide a way to register orchestrations/entities without requiring a durable client starter #419

Open hossam-nasr opened 1 year ago

hossam-nasr commented 1 year ago

In any durable orchestration app, the three most fundamental components are:

  1. An activity function
  2. An orchestrator function
  3. A client function

Similarly, the most fundamental component of an entity app are:

  1. An entity function
  2. A client function

Most of the business logic resides in the activities, orchestrations, and entity functions. Most of the time, the client function is a simple function that starts the orchestration/entity and returns HTTP endpoints to query the orchestration or perform management operations. Most of the time, it would simply follow the simple HTTP example provided in the samples:

const httpStart: HttpHandler = async (request: HttpRequest, context: InvocationContext) => {
    const client = df.getClient(context, clientInput);
    const instanceId = await client.startNew(request.params.orchestratorName, undefined, request.text());
    context.log(`Started orchestration with ID = '${instanceId}'.`);
    return client.createCheckStatusResponse(request, instanceId);
};

app.http('durableOrchestrationStart1', {
    route: 'orchestrators/{orchestratorName}',
    extraInputs: [clientInput],
    handler: httpStart,
});

This issue is to explore the feasibility and cost-effectiveness of providing a convenience method to get rid of the client function boilerplate in the most mainstream use-cases. This could be done by, for example, providing an API that takes in an orchestration, and automatically creates and registers an HTTP client function for the user.