Minor Changes
-
invoke functions synchronously or asynchronously (#1295) (d1667c7)
client.functions.invoke()now takes anoptionsargument and acceptssanity.function.durable
andsanity.function.queuefunctions alongsidesanity.function.pubsub.By default the invocation is queued: the call resolves with
undefinedas soon as the
service accepts it, without waiting for the function to run. Pass{sync: true}to keep the
request open until the function finishes and resolve with its return value — that adds a
?sync=truequery parameter to the invoke request, and remains limited to
sanity.function.pubsub.// Async — resolves once accepted, with no return value. await client.functions.invoke("my-func", { event: { data: { hello: "world" } }, }); // Sync — resolves with whatever the function returns. const result = await client.functions.invoke<Result>( "my-func", { event: { data: { hello: "world" } } }, { sync: true } );
The return type follows the option: a call with
{sync: true}resolves withR, while an async
call resolves withundefined. Callers who pass an explicit type argument without{sync: true}
keep the previousR | undefinedshape. -
collaboration: resolve comment
rangefrom optionalfieldValue(#1299) (88073e6)