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

Simplify the `client.startNew()` experience #415

Closed hossam-nasr closed 1 year ago

hossam-nasr commented 1 year ago

Based on discussion here. Currently, the default HTTP starter client.startNew() call looks like this:

const instanceId = await client.startNew(request.params.orchestratorName, undefined, request.text());

Ideally, client.startNew() should accept one single object as an argument, rather than 3 distinct arguments, so that:

  1. It's clearer what each argument is for
  2. Order doesn't matter
  3. Unnecessary arguments can be omitted instead of passing in undefined.

Since this would be a breaking change, it might be better to include this change with the rest of the v3.x new programming model changes.

davidmrdavid commented 1 year ago

@hossam-nasr: With the single object approach, is there a way to ensure that the orchestrator name is always present? That argument should always be required, as it is the name of the Function to invoke.

hossam-nasr commented 1 year ago

@davidmrdavid We could enforce it for TS users using types, and also error out if it's not present. However, if that's the case, I'd say maybe let's make the orchestrator name the first argument, and the second argument the options object with all other additional parameters