77
88---
99
10+ This package is in alpha -- the roadmap of missing features is listed [ below] ( #roadmap ) .
11+
1012## What is DBOS?
1113
1214DBOS 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.
@@ -32,33 +34,33 @@ You add durable workflows to your existing Golang program by registering ordinar
3234
3335``` golang
3436var (
35- wf = dbos.WithWorkflow (workflow)
37+ wf = dbos.WithWorkflow (workflow)
3638)
3739
3840func workflow (ctx context .Context , _ string ) (string , error ) {
39- _ , err := dbos.RunAsStep (ctx, step1, " " )
40- if err != nil {
41- return " " , err
42- }
43- return dbos.RunAsStep (ctx, step2, " " )
41+ _ , err := dbos.RunAsStep (ctx, step1, " " )
42+ if err != nil {
43+ return " " , err
44+ }
45+ return dbos.RunAsStep (ctx, step2, " " )
4446}
4547
4648func step1 (ctx context .Context , _ string ) (string , error ) {
47- fmt.Println (" Executing step 1" )
48- return " Step 1 completed" , nil
49+ fmt.Println (" Executing step 1" )
50+ return " Step 1 completed" , nil
4951}
5052
5153func step2 (ctx context .Context , _ string ) (string , error ) {
52- fmt.Println (" Executing step 2" )
53- return " Step 2 completed - Workflow finished successfully" , nil
54+ fmt.Println (" Executing step 2" )
55+ return " Step 2 completed - Workflow finished successfully" , nil
5456}
5557
5658func main () {
57- err := dbos.Launch ()
58- if err != nil {
59- panic (err)
60- }
61- defer dbos.Shutdown ()
59+ err := dbos.Launch ()
60+ if err != nil {
61+ panic (err)
62+ }
63+ defer dbos.Shutdown ()
6264
6365 wf (context.Background (), " hello DBOS" )
6466}
@@ -89,45 +91,60 @@ They don't require a separate queueing service or message broker—just Post
8991
9092``` golang
9193var (
92- queue = dbos.NewWorkflowQueue (" example-queue" )
93- taskWf = dbos.WithWorkflow (task)
94+ queue = dbos.NewWorkflowQueue (" example-queue" )
95+ taskWf = dbos.WithWorkflow (task)
9496)
9597
9698func task (ctx context .Context , i int ) (int , error ) {
97- time.Sleep (5 * time.Second )
98- fmt.Printf (" Task %d completed\n " , i)
99- return i, nil
99+ time.Sleep (5 * time.Second )
100+ fmt.Printf (" Task %d completed\n " , i)
101+ return i, nil
100102}
101103
102104func main () {
103- err := dbos.Launch ()
104- if err != nil {
105- panic (err)
106- }
107- defer dbos.Shutdown ()
108-
109- fmt.Println (" Enqueuing workflows" )
110- handles := make ([]dbos.WorkflowHandle [int ], 10 )
111- for i := range 10 {
112- handle , err := taskWf (context.Background (), i, dbos.WithQueue (queue.Name ))
113- if err != nil {
114- panic (fmt.Sprintf (" failed to enqueue step %d : %v " , i, err))
115- }
116- handles[i] = handle
117- }
118- results := make ([]int , 10 )
119- for i , handle := range handles {
120- result , err := handle.GetResult (context.Background ())
121- if err != nil {
122- panic (fmt.Sprintf (" failed to get result for step %d : %v " , i, err))
123- }
124- results[i] = result
125- }
126- fmt.Printf (" Successfully completed %d steps\n " , len (results))
105+ err := dbos.Launch ()
106+ if err != nil {
107+ panic (err)
108+ }
109+ defer dbos.Shutdown ()
110+
111+ fmt.Println (" Enqueuing workflows" )
112+ handles := make ([]dbos.WorkflowHandle [int ], 10 )
113+ for i := range 10 {
114+ handle , err := taskWf (context.Background (), i, dbos.WithQueue (queue.Name ))
115+ if err != nil {
116+ panic (fmt.Sprintf (" failed to enqueue step %d : %v " , i, err))
117+ }
118+ handles[i] = handle
119+ }
120+ results := make ([]int , 10 )
121+ for i , handle := range handles {
122+ result , err := handle.GetResult (context.Background ())
123+ if err != nil {
124+ panic (fmt.Sprintf (" failed to get result for step %d : %v " , i, err))
125+ }
126+ results[i] = result
127+ }
128+ fmt.Printf (" Successfully completed %d steps\n " , len (results))
127129}
128130```
129131</details >
130132
133+ ## Roadmap:
134+ * logging for DBOS internals -- consider accepting a user provided logger
135+ * OTel trace generation and export
136+ * OTel logs -- consider leveraging the user provided logger
137+ * config?
138+ * go doc
139+ * workflows send and recv
140+ * workflows set and get event
141+ * workflow cancellation maps
142+ * queue dedup
143+ * queue priority
144+ * workflow timeouts
145+ * DBOS Client
146+ * datasources & transactions
147+
131148## Getting started
132149
133150Install the DBOS Transact package in your program:
0 commit comments