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
#### This Golang version of DBOS Transact is in Alpha!
14
+
For production ready Transacts, check our [Python](https://github.com/dbos-inc/dbos-transact-py) and [TypeScript](https://github.com/dbos-inc/dbos-transact-ts) versions.
9
15
10
-
This package is in alpha -- the roadmap of missing features is listed [below](#roadmap).
16
+
---
11
17
12
18
## What is DBOS?
13
19
14
-
DBOS provides lightweight durable workflows on top of Postgres. Instead of managing your own workflow orchestrator or task queue system, you can use DBOS to add durable workflows and queues to your program in just a few lines of code.
20
+
DBOS provides lightweight durable workflow orchestration on top of Postgres. Instead of managing your own workflow orchestrator or task queue system, you can use DBOS to add durable workflows and queues to your program in just a few lines of code.
15
21
16
22
17
23
## When Should I Use DBOS?
@@ -33,36 +39,67 @@ If your program ever fails, when it restarts all your workflows will automatical
33
39
You add durable workflows to your existing Golang program by registering ordinary functions as workflows or running them as steps:
Pause your workflow executions until a notification is received, or emit events from your workflow to send progress updates to external clients.
236
+
All notifications are stored in Postgres, so they can be sent and received with exactly-once semantics.
237
+
Set durable timeouts when waiting for events, so you can wait for as long as you like (even days or weeks) through interruptions or restarts, then resume once a notification arrives or the timeout is reached.
238
+
239
+
For example, build a reliable billing workflow that durably waits for a notification from a payments service, processing it exactly-once:
A workflow can be any function with the following signature:
136
271
```golang
137
-
typeWorkflowFunc[P any, R any] func(ctx context.Context, input P) (R, error)
272
+
typeGenericWorkflowFunc[P any, R any] func(ctx context.Context, input P) (R, error)
138
273
```
139
274
140
-
`P` and `R` must be concrete types (not `any`).
275
+
To register a workflow call `dbos.RegisterWorkflow(dbosCtx, workflow)` after having initialized a DBOS Context. Workflows can only be registered before DBOS is launched.
141
276
142
-
Workflows must be registered with DBOS using the `WithWorkflow` method before DBOS is launched.
143
277
144
278
Workflows can run steps, which can be any function with the following signature:
145
279
```golang
146
-
typeStepFunc[P any, R any] func(ctx context.Context, input P) (R, error)
To run a step within a workflow, use `RunAsStep`. Importantly, you must pass to `RunAsStep` the context received in the workflow function.
283
+
To run a step within a workflow, use `RunAsStep`. Importantly, you must pass to `RunAsStep` the context received in the workflow function (see examples above.)
150
284
151
285
The input and output of workflows and steps are memoized in your Postgres database for workflow recovery. Under the hood, DBOS uses the [encoding/gob](https://pkg.go.dev/encoding/gob) package for serialization (this means that only exported fields will be memoized and types without exported fields will generate an error.)
152
286
153
-
## Roadmap:
154
-
* logging for DBOS internals -- consider accepting a user provided logger
155
-
* OTel trace generation and export
156
-
* OTel logs -- consider leveraging the user provided logger
157
-
* config?
158
-
* go doc
159
-
* workflows send and recv
160
-
* workflows set and get event
161
-
* workflow cancellation maps
162
-
* queue dedup
163
-
* queue priority
164
-
* workflow timeouts
165
-
* DBOS Client
166
-
* datasources & transactions
167
-
168
287
## Getting started
169
288
170
289
Install the DBOS Transact package in your program:
171
290
172
291
```shell
173
-
github.com/dbos-inc/dbos-transact-go
292
+
go get github.com/dbos-inc/dbos-transact-go
174
293
```
175
294
176
-
You can store and export a Postgres connection string in the `DBOS_SYSTEM_DATABASE_URL` environment variable for DBOS to manage your workflows state. By default, DBOS will use `postgres://postgres:${PGPASSWORD}@localhost:5432/dbos?sslmode=disable`.
295
+
You can store and export a Postgres connection string in the `DBOS_SYSTEM_DATABASE_URL` environment variable for DBOS to manage your workflows state. By default, DBOS will use `postgres://postgres:${PGPASSWORD}@localhost:5432/dbos?sslmode=disable`.
296
+
297
+
298
+
## ⭐️ Like this project?
299
+
300
+
[Star it on GitHub](https://github.com/dbos-inc/dbos-transact-go)
0 commit comments