feat: add DBOS skills for TypeScript, Python, and Go (#94)
Add three DBOS SDK skills with reference documentation for building reliable, fault-tolerant applications with durable workflows. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
53
skills/dbos-python/references/workflow-determinism.md
Normal file
53
skills/dbos-python/references/workflow-determinism.md
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: Keep Workflows Deterministic
|
||||
impact: CRITICAL
|
||||
impactDescription: Non-deterministic workflows cannot recover correctly
|
||||
tags: workflow, determinism, recovery, reliability
|
||||
---
|
||||
|
||||
## Keep Workflows Deterministic
|
||||
|
||||
Workflow functions must be deterministic: given the same inputs and step return values, they must invoke the same steps in the same order. Non-deterministic operations must be moved to steps.
|
||||
|
||||
**Incorrect (non-deterministic workflow):**
|
||||
|
||||
```python
|
||||
import random
|
||||
|
||||
@DBOS.workflow()
|
||||
def example_workflow():
|
||||
# Random number in workflow breaks recovery!
|
||||
choice = random.randint(0, 1)
|
||||
if choice == 0:
|
||||
step_one()
|
||||
else:
|
||||
step_two()
|
||||
```
|
||||
|
||||
**Correct (non-determinism in step):**
|
||||
|
||||
```python
|
||||
import random
|
||||
|
||||
@DBOS.step()
|
||||
def generate_choice():
|
||||
return random.randint(0, 1)
|
||||
|
||||
@DBOS.workflow()
|
||||
def example_workflow():
|
||||
# Random number generated in step - result is saved
|
||||
choice = generate_choice()
|
||||
if choice == 0:
|
||||
step_one()
|
||||
else:
|
||||
step_two()
|
||||
```
|
||||
|
||||
Non-deterministic operations that must be in steps:
|
||||
- Random number generation
|
||||
- Getting current time
|
||||
- Accessing external APIs
|
||||
- Reading files
|
||||
- Database queries (use transactions or steps)
|
||||
|
||||
Reference: [Workflow Determinism](https://docs.dbos.dev/python/tutorials/workflow-tutorial#determinism)
|
||||
Reference in New Issue
Block a user