Skip to content

Commit 816162b

Browse files
committed
rewrite step docs
- Rewrite step.md as concise reference doc, replacing FAQ/ToC structure with direct API reference format - Move all step examples from core/steps to operations/steps and testing examples to testing-patterns/basic-tests across all three languages; verify all samples against SDK source - Add Java examples for all step and testing-patterns sections - Add passing-data-wrong and passing-data-correct examples in all three languages showing mutation-lost-on-replay anti-pattern using register-user/wait/send-follow-up-email flow - Update retries.md, basic-tests.md, key-concepts.md - Run mdformat on updated doc files closes #40, closes #76, closes #58
1 parent 38cfe0e commit 816162b

83 files changed

Lines changed: 1199 additions & 782 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/getting-started/key-concepts.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,21 @@ durable operation calls on every invocation.
122122
## Determinism
123123

124124
Because your code runs again on replay, it must be **deterministic**. Deterministic
125-
means that the code always produces the same results given the same inputs. Given the
126-
same inputs and checkpoint log, your function must make the same sequence of durable
127-
operation calls. Avoid operations with side effects (like generating random numbers or
128-
getting the current time) outside of steps, as these can produce different values during
129-
replay and cause non-deterministic behavior.
125+
means that the code always produces the same results given the same inputs. During
126+
replay, your function runs from the beginning and must follow the same execution path as
127+
the original run. Given the same inputs and checkpoint log, your function must make the
128+
same sequence of durable operation calls. Avoid operations with side effects outside of
129+
steps, as these can produce different values during replay and cause non-deterministic
130+
behavior.
131+
132+
These are some examples of non-deterministic code:
133+
134+
- Random number generation and UUIDs
135+
- Current time or timestamps
136+
- External API calls and database queries
137+
- File system operations
138+
139+
Wrap such non-deterministic code in [steps](../sdk-reference/operations/step.md).
130140

131141
### Rules for deterministic durable operations
132142

Lines changed: 36 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,94 @@
1-
# Retries
1+
# Retry strategies
22

3-
## Table of Contents
3+
Retry strategies configure how the SDK responds to failures in steps. You control the
4+
number of attempts, delay between retries, backoff rate, and which exceptions trigger a
5+
retry. If no retry strategy is configured on a step, any exception propagates
6+
immediately and fails the execution.
47

5-
- [Overview](#overview)
6-
- [Creating retry strategies](#creating-retry-strategies)
7-
- [RetryStrategyConfig parameters](#retrystrategyconfig-parameters)
8-
- [Retry presets](#retry-presets)
9-
- [Retrying specific exceptions](#retrying-specific-exceptions)
10-
- [Exponential backoff](#exponential-backoff)
8+
## Creating a retry strategy
119

12-
[← Back to main index](../index.md)
13-
14-
## Overview
15-
16-
Retry strategies configure how the SDK responds to transient failures in steps. You can control the number of attempts, delay between retries, backoff rate, and which exceptions trigger a retry.
17-
18-
[↑ Back to top](#table-of-contents)
19-
20-
## Creating retry strategies
21-
22-
Use `RetryStrategyConfig` to define retry behavior:
10+
Use `createRetryStrategy()` (TypeScript/Python) or
11+
`RetryStrategies.exponentialBackoff()` (Java) to build a strategy, then pass it to
12+
`StepConfig`:
2313

2414
=== "TypeScript"
2515

26-
``` typescript
27-
--8<-- "examples/typescript/core/steps/unreliable-operation.ts"
16+
```typescript
17+
--8<-- "examples/typescript/advanced/error-handling/exponential-backoff.ts"
2818
```
2919

3020
=== "Python"
3121

32-
``` python
33-
--8<-- "examples/python/core/steps/unreliable-operation.py"
22+
```python
23+
--8<-- "examples/python/advanced/error-handling/exponential-backoff.py"
3424
```
3525

3626
=== "Java"
3727

38-
``` java
39-
--8<-- "examples/java/core/steps/unreliable-operation.java"
28+
```java
29+
--8<-- "examples/java/advanced/error-handling/exponential-backoff.java"
4030
```
4131

42-
[↑ Back to top](#table-of-contents)
43-
4432
## RetryStrategyConfig parameters
4533

46-
**max_attempts** - Maximum number of attempts (including the initial attempt). Default: 3.
34+
**max_attempts / maxAttempts** Maximum number of attempts including the initial attempt.
35+
Default: 3.
4736

48-
**initial_delay_seconds** - Initial delay before first retry in seconds. Default: 5.
37+
**initial_delay / initialDelay** Delay before the first retry. Default: 5 seconds.
4938

50-
**max_delay_seconds** - Maximum delay between retries in seconds. Default: 300 (5 minutes).
39+
**max_delay / maxDelay** Maximum delay between retries. Default: 5 minutes.
5140

52-
**backoff_rate** - Multiplier for exponential backoff. Default: 2.0.
41+
**backoff_rate / backoffRate** Multiplier for exponential backoff. Default: 2.0.
5342

54-
**jitter_strategy** - Jitter strategy to add randomness to delays. Default: `JitterStrategy.FULL`.
43+
**jitter_strategy / jitter** Jitter strategy to spread retries. Default: `FULL`.
5544

56-
**retryable_errors** - List of error message patterns to retry (strings or regex patterns). Default: matches all errors.
45+
**retryable_errors / retryableErrors** Error message patterns to retry (strings or
46+
regex). Default: matches all errors.
5747

58-
**retryable_error_types** - List of exception types to retry. Default: empty (retry all).
59-
60-
[↑ Back to top](#table-of-contents)
48+
**retryable_error_types / retryableErrorTypes** Exception types to retry. Default: empty
49+
(retries all).
6150

6251
## Retry presets
6352

64-
The SDK provides preset retry strategies for common scenarios:
65-
6653
=== "TypeScript"
6754

68-
``` typescript
55+
```typescript
6956
--8<-- "examples/typescript/advanced/error-handling/retry-presets.ts"
7057
```
7158

7259
=== "Python"
7360

74-
``` python
61+
```python
7562
--8<-- "examples/python/advanced/error-handling/retry-presets.py"
7663
```
7764

7865
=== "Java"
7966

80-
``` java
67+
```java
8168
--8<-- "examples/java/advanced/error-handling/retry-presets.java"
8269
```
8370

84-
[↑ Back to top](#table-of-contents)
85-
8671
## Retrying specific exceptions
8772

88-
Only retry certain exception types:
89-
9073
=== "TypeScript"
9174

92-
``` typescript
93-
--8<-- "examples/typescript/advanced/error-handling/retry-specific-exceptions.ts"
75+
```typescript
76+
--8<-- "examples/typescript/sdk-reference/error-handling/unreliable-operation.ts"
9477
```
9578

9679
=== "Python"
9780

98-
``` python
99-
--8<-- "examples/python/advanced/error-handling/retry-specific-exceptions.py"
81+
```python
82+
--8<-- "examples/python/sdk-reference/error-handling/unreliable-operation.py"
10083
```
10184

10285
=== "Java"
10386

104-
``` java
105-
--8<-- "examples/java/advanced/error-handling/retry-specific-exceptions.java"
87+
```java
88+
--8<-- "examples/java/sdk-reference/error-handling/unreliable-operation.java"
10689
```
10790

108-
[↑ Back to top](#table-of-contents)
109-
110-
## Exponential backoff
111-
112-
Configure exponential backoff to avoid overwhelming failing services:
113-
114-
=== "TypeScript"
115-
116-
``` typescript
117-
--8<-- "examples/typescript/advanced/error-handling/exponential-backoff.ts"
118-
```
119-
120-
=== "Python"
121-
122-
``` python
123-
--8<-- "examples/python/advanced/error-handling/exponential-backoff.py"
124-
```
125-
126-
=== "Java"
127-
128-
``` java
129-
--8<-- "examples/java/advanced/error-handling/exponential-backoff.java"
130-
```
131-
132-
With this configuration:
133-
- Attempt 1: Immediate
134-
- Attempt 2: After 1 second
135-
- Attempt 3: After 2 seconds
136-
- Attempt 4: After 4 seconds
137-
- Attempt 5: After 8 seconds
138-
139-
[↑ Back to top](#table-of-contents)
140-
14191
## See also
14292

143-
- [Errors](errors.md) - Exception types and error responses
144-
- [Step](../operations/step.md) - Configure retry for steps
93+
- [Errors](errors.md)
94+
- [Steps](../operations/step.md)

0 commit comments

Comments
 (0)