Skip to content

docs(sdk): add invoke operation page#164

Merged
yaythomas merged 2 commits into
mainfrom
docs_sdk/10-invoke
Nov 27, 2025
Merged

docs(sdk): add invoke operation page#164
yaythomas merged 2 commits into
mainfrom
docs_sdk/10-invoke

Conversation

@leandrodamascena
Copy link
Copy Markdown
Contributor

closes #163

Description of changes:

This PR adds docs/core/invoke.md documentation for invoke operations. The guide explains how to use context.invoke() to call other durable functions, including payload serialization, InvokeConfig options, and function composition patterns. It covers error handling for invoked functions, result handling, and a testing section showing how to verify invoke operations with test examples.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread docs/core/invoke.md Outdated
Invoke operations let you call other Lambda functions from within your durable function. You can invoke both durable functions and regular on-demand Lambda functions. This enables function composition, where you break complex workflows into smaller, reusable functions. The calling function suspends while the invoked function executes, and resumes when the result is available.

Use invoke operations to:
- Decompose complex workflows into manageable functions
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, "decompose" is a very particular usage here 🧟 .

"Modularize"?

Comment thread docs/core/invoke.md Outdated

**Raises:**
- `CallableRuntimeError` - If the invoked function fails or times out
- `SuspendExecution` - When the operation is first started or still in progress (internal)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consumer doesn't see this

Comment thread docs/core/invoke.md Outdated

**serdes_payload** - Custom serialization/deserialization for the payload sent to the invoked function. If not provided, uses JSON serialization.

**serdes_result** - Custom serialization/deserialization for the result returned by the invoked function. If not provided, uses JSON serialization.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we have the types:

    timeout: Duration = field(default_factory=Duration)
    serdes_payload: SerDes[P] | None = None
    serdes_result: SerDes[R] | None = None
    tenant_id: str | None = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    timeout: Maximum duration to wait for the invoked function to complete.
        Default is no timeout. Use this to prevent long-running invocations
        from blocking execution indefinitely.

    serdes_payload: Custom serialization/deserialization for the payload
        sent to the invoked function. If None, uses default JSON serialization.

    serdes_result: Custom serialization/deserialization for the result
        returned from the invoked function. If None, uses default JSON serialization.

    tenant_id: Optional tenant identifier for multi-tenant isolation.
        If provided, the invocation will be scoped to this tenant.

Comment thread docs/core/invoke.md Outdated

**Consider cost implications** - Each invoke operation triggers a separate Lambda invocation, which has cost implications.

**Mix durable and on-demand functions** - You can invoke both durable and regular Lambda functions. Use durable functions for complex workflows and on-demand functions for simple operations.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually an interesting/good design pattern!

The orchestrator could be Durable, and then compose regular on-demand functions. The orchestrator provides the durability for the results of the invoked on-demand functions without needing to provide the durabiity on the invoked functions themselves.

Comment thread docs/core/invoke.md

```python
result1 = context.invoke("function-1", payload1)
result2 = context.invoke("function-2", result1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type of the return value is governed by the serdes_result.

@leandrodamascena
Copy link
Copy Markdown
Contributor Author

Hey @yaythomas thanks for the feedback! it's ready to another review.

@yaythomas yaythomas merged commit f4511e6 into main Nov 27, 2025
11 of 12 checks passed
@wangyb-A wangyb-A deleted the docs_sdk/10-invoke branch December 9, 2025 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: add documentation about invoke operations

2 participants