You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/golang/reference/dbos-context.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,14 @@ title: DBOS Context
4
4
pagination_prev: null
5
5
---
6
6
7
-
A DBOS Context is at the center of a DBOS-enabled application. Use it to register [workflows](./workflow-tutorial.md), [queues](./queue-tutorial.md) and perform [workflow management](./workflow-management.md) tasks.
7
+
A DBOS Context is at the center of a DBOS-enabled application. Use it to register [workflows](../tutorials/workflow-tutorial.md), [queues](../tutorials/queue-tutorial.md) and perform [workflow management](../tutorials/workflow-management.md) tasks.
8
8
9
-
[`DBOSContext`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#DBOSContext) extends Go's [`context.Context`](https://pkg.go.dev/context#Context) interface and carries essential state across workflow execution. Workflows and steps receive a new `DBOSContext` spun out of the root `DBOSContext` you manage. In addition, a `DBOSContext` can be used to set [workflow timeouts](./workflow-tutorial.md#workflow-timeouts).
9
+
`DBOSContext` extends Go's [`context.Context`](https://pkg.go.dev/context#Context) interface and carries essential state across workflow execution. Workflows and steps receive a new `DBOSContext` spun out of the root `DBOSContext` you manage. In addition, a `DBOSContext` can be used to set [workflow timeouts](../tutorials/workflow-tutorial.md#workflow-timeouts).
10
10
11
+
## Lifecycle
11
12
### Initialization
12
13
13
-
You can create a DBOS context using [`NewDBOSContext`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#NewDBOSContext), which takes a [`Config`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#Config) object where `AppName` and `DatabaseURL` are mandatory.
14
+
You can create a DBOS context using `NewDBOSContext`, which takes a `Config` object where `AppName` and `DatabaseURL` are mandatory.
Launch the following resources managed by a `DBOSContext`:
51
52
- A [system database connection pool](../../explanations/system-tables.md)
52
-
- A [workflow scheduler](./workflow-tutorial.md#scheduled-workflows)
53
-
- A [workflow queue runner](./queue-tutorial.md)
53
+
- A [workflow scheduler](../tutorials/workflow-tutorial.md#scheduled-workflows)
54
+
- A [workflow queue runner](../tutorials/queue-tutorial.md)
54
55
- (Optionally) an admin server
55
56
- (Optionally) a conductor connection
56
57
@@ -66,14 +67,15 @@ Gracefully shutdown the DBOS runtime, waiting for workflows to complete and clea
66
67
**Parameters:**
67
68
-**timeout**: The time to wait for workflows to complete. After the timeout elapses, execution of incomplete workflows is terminated (the workflows may then be recovered by other processes).
WithTimeout returns a copy of the DBOS context with a timeout. The returned context will be canceled after the specified duration. See [workflow timeouts](./workflow-tutorial.md#workflow-timeouts) for usage.
78
+
WithTimeout returns a copy of the DBOS context with a timeout. The returned context will be canceled after the specified duration. See [workflow timeouts](../tutorials/workflow-tutorial.md#workflow-timeouts) for usage.
GetStepID retrieves the current step ID from the context if called within a DBOS workflow. Returns -1 and an error if not called from within a workflow context.
Start a new execution of a workflow from a specific step. The input step ID (`startStep`) must match the step number of the step returned by workflow introspection. The specified `startStep` is the step from which the new workflow will start, so any steps whose ID is less than `startStep` will not be re-executed.
295
295
296
296
**Parameters:**
297
297
- **ctx**: The DBOS context.
298
-
- **workflowID**: The ID of the workflow to fork.
299
-
- **startStep**: The ID of the step from which to start the forked workflow.
You can then enqueue any workflow using [`WithQueue`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithQueue) when calling `RunWorkflow`.
17
-
Enqueuing a function submits it for execution and returns a [handle](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WorkflowHandle) to it.
16
+
You can then enqueue any workflow using [`WithQueue`](../reference/workflows-steps#withqueue) when calling `RunWorkflow`.
17
+
Enqueuing a function submits it for execution and returns a [handle](../reference/workflows-steps#workflowhandle) to it.
18
18
Queued tasks are started in first-in, first-out (FIFO) order.
19
19
20
20
```go
@@ -144,7 +144,7 @@ Rate limits are especially useful when working with a rate-limited API, such as
144
144
145
145
### Deduplication
146
146
147
-
You can set a deduplication ID for an enqueued workflow using [`WithDeduplicationID`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithDeduplicationID) when calling `RunWorkflow`.
147
+
You can set a deduplication ID for an enqueued workflow using [`WithDeduplicationID`](../reference/workflows-steps#withdeduplicationid) when calling `RunWorkflow`.
148
148
At any given time, only one workflow with a specific deduplication ID can be enqueued in the specified queue.
149
149
If a workflow with a deduplication ID is currently enqueued or actively executing (status `ENQUEUED` or `PENDING`), subsequent workflow enqueue attempts with the same deduplication ID in the same queue will return an error.
You can set a priority for an enqueued workflow using [`WithPriority`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithPriority) when calling `RunWorkflow`.
186
+
You can set a priority for an enqueued workflow using [`WithPriority`](../reference/workflows-steps#withpriority) when calling `RunWorkflow`.
187
187
Workflows with the same priority are dequeued in **FIFO (first in, first out)** order. Priority values can range from `1` to `2,147,483,647`, where **a low number indicates a higher priority**.
188
-
If using priority, you must set [`WithPriorityEnabled`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithPriorityEnabled) on your queue.
188
+
If using priority, you must set [`WithPriorityEnabled`](../reference/queues#withpriorityenabled) on your queue.
189
189
190
190
:::tip
191
191
Workflows without assigned priorities have the highest priority and are dequeued before workflows with assigned priorities.
Copy file name to clipboardExpand all lines: docs/golang/tutorials/step-tutorial.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: Steps
6
6
When using DBOS workflows, you should call any function that performs complex operations or accesses external APIs or services as a _step_.
7
7
If a workflow is interrupted, upon restart it automatically resumes execution from the **last completed step**.
8
8
9
-
You can use [`RunAsStep`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#RunAsStep) to call a function as a step.
9
+
You can use [`RunAsStep`](../reference/workflows-steps#runasstep) to call a function as a step.
10
10
For a function to be used as a step, it should return a serializable ([gob-encodable](https://pkg.go.dev/encoding/gob)) value and an error and have this signature:
11
11
12
12
```go
@@ -50,11 +50,11 @@ This is useful for automatically handling transient failures, like making reques
50
50
Retries are configurable through step options that can be passed to `RunAsStep`.
51
51
52
52
Available retry configuration options include:
53
-
-[`WithStepName`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithStepName) - Custom name for the step (default to the [Go runtime reflection value](https://pkg.go.dev/runtime#FuncForPC))
54
-
-[`WithStepMaxRetries`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithStepMaxRetries) - Maximum number of times this step is automatically retried on failure (default 0)
55
-
-[`WithMaxInterval`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithMaxInterval) - Maximum delay between retries (default 5s)
56
-
-[`WithBackoffFactor`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithBackoffFactor) - Exponential backoff multiplier between retries (default 2.0)
57
-
-[`WithBaseInterval`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#WithBaseInterval) - Initial delay between retries (default 100ms)
53
+
-[`WithStepName`](../reference/workflows-steps#withstepname) - Custom name for the step (default to the [Go runtime reflection value](https://pkg.go.dev/runtime#FuncForPC))
54
+
-[`WithStepMaxRetries`](../reference/workflows-steps#withstepmaxretries) - Maximum number of times this step is automatically retried on failure (default 0)
55
+
-[`WithMaxInterval`](../reference/workflows-steps#withmaxinterval) - Maximum delay between retries (default 5s)
56
+
-[`WithBackoffFactor`](../reference/workflows-steps#withbackofffactor) - Exponential backoff multiplier between retries (default 2.0)
57
+
-[`WithBaseInterval`](../reference/workflows-steps#withbaseinterval) - Initial delay between retries (default 100ms)
58
58
59
59
For example, let's configure this step to retry failures (such as if `example.com` is temporarily down) up to 10 times:
Copy file name to clipboardExpand all lines: docs/golang/tutorials/testing.md
+32-3Lines changed: 32 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,40 @@ title: Testing & Mocking
4
4
---
5
5
6
6
7
-
[`DBOSContext`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#DBOSContext) is a fully mockable interface, which you manually mock, or can generate mocks using tools like [mockery](https://github.com/vektra/mockery).
7
+
[`DBOSContext`](../reference/dbos-context) is a fully mockable interface, which you manually mock, or can generate mocks using tools like [mockery](https://github.com/vektra/mockery).
Copy file name to clipboardExpand all lines: docs/golang/tutorials/workflow-management.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ You can view and manage your durable workflow executions via a web UI ([self-hos
7
7
8
8
## Listing Workflows
9
9
10
-
You can list your application's workflows programmatically via [`ListWorkflows`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#ListWorkflows).
10
+
You can list your application's workflows programmatically via [`ListWorkflows`](../reference/methods#listworkflows).
11
11
12
12
You can also view a searchable and expandable list of your application's workflows from its page on the DBOS Console (either [self-hosted](../../production/self-hosting/workflow-management.md) or on [DBOS Cloud](../../production/dbos-cloud/workflow-management.md)).
13
13
@@ -22,14 +22,14 @@ For example, here is the graph of a workflow that processes multiple tasks concu
22
22
23
23
## Cancelling Workflows
24
24
25
-
You can cancel the execution of a workflow from the web UI or programmatically via [`CancelWorkflow`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#CancelWorkflow).
25
+
You can cancel the execution of a workflow from the web UI or programmatically via [`CancelWorkflow`](../reference/methods#cancelworkflow).
26
26
27
27
If the workflow is currently executing, cancelling it preempts its execution (interrupting it at the beginning of its next step).
28
28
If the workflow is enqueued, cancelling removes it from the queue.
29
29
30
30
## Resuming Workflows
31
31
32
-
You can resume a workflow from its last completed step from the web UI or programmatically via [`ResumeWorkflow`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#ResumeWorkflow).
32
+
You can resume a workflow from its last completed step from the web UI or programmatically via [`ResumeWorkflow`](../reference/methods#resumeworkflow).
33
33
34
34
You can use this to resume workflows that are cancelled or that have exceeded their maximum recovery attempts.
35
35
You can also use this to start an enqueued workflow immediately, bypassing its queue.
@@ -41,7 +41,7 @@ When you fork a workflow, DBOS generates a new workflow with a new workflow ID,
41
41
42
42
Forking a workflow is useful for recovering from outages in downstream services (by forking from the step that failed after the outage is resolved) or for "patching" workflows that failed due to a bug in a previous application version (by forking from the bugged step to an appliation version on which the bug is fixed).
43
43
44
-
You can fork a workflow programmatically using [`ForkWorkflow`](https://pkg.go.dev/github.com/dbos-inc/dbos-transact-golang/dbos#ForkWorkflow).
44
+
You can fork a workflow programmatically using [`ForkWorkflow`](../reference/methods#forkworkflow).
45
45
You can also fork a workflow from a step from the web UI by clicking on that step in the workflow's graph visualization:
0 commit comments