Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/guides/function/builtin-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,24 @@ const executionId = await tailor.workflow.triggerWorkflow(
},
);

// Trigger a job function
const result = await tailor.workflow.triggerJobFunction("calculateTax", {
// Execute a job function
const result = await tailor.workflow.execJobFunction("calculateTax", {
amount: 1000,
});

// Route the dispatch through a workspace-registered execution policy for
// per-key concurrency control (see the SDK Workflow guide for policy setup).
const scoped = await tailor.workflow.triggerJobFunction(
const scoped = await tailor.workflow.execJobFunction(
"syncTenant",
{ tenantId: "acme" },
{ executionPolicyKey: `tenant-api.acme` },
);
```

| Function | Returns | Description |
| ------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `triggerWorkflow(name, args?, options?)` | `Promise<string>` | Trigger a workflow. Returns the execution ID |
| `triggerJobFunction(name, args?, options?)` | `Promise<any>` | Trigger a job function and return its result. `options.executionPolicyKey` routes the dispatch through a matching execution policy for per-key concurrency control |
| Function | Returns | Description |
| ---------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `triggerWorkflow(name, args?, options?)` | `Promise<string>` | Trigger a workflow. Returns the execution ID |
| `execJobFunction(name, args?, options?)` | `Promise<any>` | Execute a job function and return its result. `options.executionPolicyKey` routes the dispatch through a matching execution policy for per-key concurrency control |

For details on declaring execution policies and the key grammar, see [Execution Policies](/sdk/services/workflow#execution-policies) in the SDK Workflow reference.

Expand Down
8 changes: 4 additions & 4 deletions docs/guides/workflow/creating-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,21 @@ export function main(args) {
console.log("Starting workflow with orderId:", args.orderId);

// Step 1: Fetch order data
const order = tailor.workflow.triggerJobFunction("fetchOrder", {
const order = tailor.workflow.execJobFunction("fetchOrder", {
orderId: args.orderId,
});

// Step 2: Validate order
const validated = tailor.workflow.triggerJobFunction("validateOrder", order);
const validated = tailor.workflow.execJobFunction("validateOrder", order);

// Step 3: Process payment
const payment = tailor.workflow.triggerJobFunction("processPayment", {
const payment = tailor.workflow.execJobFunction("processPayment", {
orderId: validated.id,
amount: validated.total,
});

// Step 4: Send confirmation
tailor.workflow.triggerJobFunction("sendConfirmation", {
tailor.workflow.execJobFunction("sendConfirmation", {
orderId: validated.id,
Comment thread
k1LoW marked this conversation as resolved.
email: validated.customerEmail,
paymentId: payment.id,
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/workflow/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ Workflows support nested function calls, similar to regular programming:
```javascript
export function main(args) {
// Call functions sequentially
const data = tailor.workflow.triggerJobFunction("fetchData", {});
const processed = tailor.workflow.triggerJobFunction("processData", data);
const data = tailor.workflow.execJobFunction("fetchData", {});
const processed = tailor.workflow.execJobFunction("processData", data);
Comment thread
k1LoW marked this conversation as resolved.
return processed;
}
```
Expand Down Expand Up @@ -127,7 +127,7 @@ See [Concurrency Policy](/sdk/services/workflow#concurrency-policy) in the SDK W

### Job Function Execution Policies

Declare workspace-scoped execution policies with a per-key `maxConcurrentExecutions` cap, then route job function dispatches through them by passing `executionPolicyKey` on `job.trigger()` / `tailor.workflow.triggerJobFunction()`.
Declare workspace-scoped execution policies with a per-key `maxConcurrentExecutions` cap, then route job function dispatches through them by passing `executionPolicyKey` on `job.trigger()` / `tailor.workflow.execJobFunction()`.

- Enforced by the **runner** at dispatch time — a separate mechanism from the scheduler-level workflow cap above. The two stack: a workflow that is allowed to start can still have its job function dispatches suspended by an execution policy.
- Dispatches that would exceed the cap are suspended and resume automatically as slots free up.
Expand Down Expand Up @@ -191,7 +191,7 @@ export const syncTenant = createWorkflowJob({
});
```

The same `executionPolicyKey` option is available on `tailor.workflow.triggerJobFunction(name, args, options)` when dispatching by name from a Function-service script.
The same `executionPolicyKey` option is available on `tailor.workflow.execJobFunction(name, args, options)` when dispatching by name from a Function-service script.

**Matching modes:**

Expand Down
8 changes: 4 additions & 4 deletions docs/guides/workflow/wait-resolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Suspends the current workflow execution and waits for an external signal.

```javascript
export async function main(args) {
const order = tailor.workflow.triggerJobFunction("createOrder", args);
const order = tailor.workflow.execJobFunction("createOrder", args);

// Pause and wait for approval
const approval = await tailor.workflow.wait("approval", {
Expand All @@ -71,7 +71,7 @@ export async function main(args) {
});

if (approval.approved) {
tailor.workflow.triggerJobFunction("fulfillOrder", {
tailor.workflow.execJobFunction("fulfillOrder", {
orderId: order.id,
});
Comment thread
k1LoW marked this conversation as resolved.
}
Expand Down Expand Up @@ -147,7 +147,7 @@ export async function main(args) {
```javascript
// Workflow job function
export async function main(args) {
const order = tailor.workflow.triggerJobFunction("prepareOrder", args);
const order = tailor.workflow.execJobFunction("prepareOrder", args);

// Pause and wait for human approval
const decision = await tailor.workflow.wait("approval", {
Expand All @@ -158,7 +158,7 @@ export async function main(args) {

// Resume after approval
if (decision.approved) {
tailor.workflow.triggerJobFunction("processOrder", {
tailor.workflow.execJobFunction("processOrder", {
orderId: order.id,
});
}
Expand Down
Loading