Skip to content

Commit e95e5e4

Browse files
committed
RunAsWorkflow -> RunWorkflow
1 parent 9ecdf5b commit e95e5e4

File tree

11 files changed

+164
-163
lines changed

11 files changed

+164
-163
lines changed

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222
with:
2323
fetch-depth: 0
2424

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- 5432:5432
3535

3636
steps:
37-
- uses: actions/checkout@v4
37+
- uses: actions/checkout@v5
3838
with:
3939
fetch-depth: 0
4040
fetch-tags: true

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func main() {
9393
defer ctx.Cancel()
9494

9595
// Run a durable workflow and get its result
96-
handle, err := dbos.RunAsWorkflow(ctx, workflow, "")
96+
handle, err := dbos.RunWorkflow(ctx, workflow, "")
9797
if err != nil {
9898
panic(err)
9999
}
@@ -170,7 +170,7 @@ func main() {
170170
fmt.Println("Enqueuing workflows")
171171
handles := make([]dbos.WorkflowHandle[int], 10)
172172
for i := range 10 {
173-
handle, err := dbos.RunAsWorkflow(ctx, task, i, dbos.WithQueue(queue.Name))
173+
handle, err := dbos.RunWorkflow(ctx, task, i, dbos.WithQueue(queue.Name))
174174
if err != nil {
175175
panic(fmt.Sprintf("failed to enqueue step %d: %v", i, err))
176176
}
@@ -199,7 +199,7 @@ Acknowledge the event immediately while reliably processing it in the background
199199
For example:
200200

201201
```golang
202-
_, err := dbos.RunAsWorkflow(ctx, task, i, dbos.WithWorkflowID(exactlyOnceEventID))
202+
_, err := dbos.RunWorkflow(ctx, task, i, dbos.WithWorkflowID(exactlyOnceEventID))
203203
```
204204
</details>
205205

@@ -224,7 +224,7 @@ func workflow(ctx dbos.DBOSContext, duration time.Duration) (string, error) {
224224
return fmt.Sprintf("Workflow slept for %s", duration), nil
225225
}
226226

227-
handle, err := dbos.RunAsWorkflow(dbosCtx, workflow, time.Second*5)
227+
handle, err := dbos.RunWorkflow(dbosCtx, workflow, time.Second*5)
228228
_, err = handle.GetResult()
229229
```
230230

@@ -251,10 +251,10 @@ func receiveWorkflow(ctx dbos.DBOSContext, topic string) (string, error) {
251251
}
252252

253253
// Start a receiver in the background
254-
recvHandle, err := dbos.RunAsWorkflow(dbosCtx, receiveWorkflow, "topic", dbos.WithWorkflowID("receiverID"))
254+
recvHandle, err := dbos.RunWorkflow(dbosCtx, receiveWorkflow, "topic", dbos.WithWorkflowID("receiverID"))
255255

256256
// Send a message
257-
sendHandle, err := dbos.RunAsWorkflow(dbosCtx, sendWorkflow, "hola!")
257+
sendHandle, err := dbos.RunWorkflow(dbosCtx, sendWorkflow, "hola!")
258258
_, err = sendHandle.GetResult()
259259

260260
// Eventually get the response

dbos/admin_server_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,22 +262,22 @@ func TestAdminServer(t *testing.T) {
262262

263263
// Create workflows with different input/output types
264264
// 1. Integer workflow
265-
intHandle, err := RunAsWorkflow(ctx, intWorkflow, 42)
265+
intHandle, err := RunWorkflow(ctx, intWorkflow, 42)
266266
require.NoError(t, err, "Failed to create int workflow")
267267
intResult, err := intHandle.GetResult()
268268
require.NoError(t, err, "Failed to get int workflow result")
269269
assert.Equal(t, 84, intResult)
270270

271271
// 2. Empty string workflow
272-
emptyStringHandle, err := RunAsWorkflow(ctx, emptyStringWorkflow, "")
272+
emptyStringHandle, err := RunWorkflow(ctx, emptyStringWorkflow, "")
273273
require.NoError(t, err, "Failed to create empty string workflow")
274274
emptyStringResult, err := emptyStringHandle.GetResult()
275275
require.NoError(t, err, "Failed to get empty string workflow result")
276276
assert.Equal(t, "", emptyStringResult)
277277

278278
// 3. Struct workflow
279279
structInput := TestStruct{Name: "test", Value: 10}
280-
structHandle, err := RunAsWorkflow(ctx, structWorkflow, structInput)
280+
structHandle, err := RunWorkflow(ctx, structWorkflow, structInput)
281281
require.NoError(t, err, "Failed to create struct workflow")
282282
structResult, err := structHandle.GetResult()
283283
require.NoError(t, err, "Failed to get struct workflow result")
@@ -385,7 +385,7 @@ func TestAdminServer(t *testing.T) {
385385
endpoint := fmt.Sprintf("http://localhost:3001/%s", strings.TrimPrefix(_WORKFLOWS_PATTERN, "POST /"))
386386

387387
// Create first workflow
388-
handle1, err := RunAsWorkflow(ctx, testWorkflow, "workflow1")
388+
handle1, err := RunWorkflow(ctx, testWorkflow, "workflow1")
389389
require.NoError(t, err, "Failed to create first workflow")
390390
workflowID1 := handle1.GetWorkflowID()
391391

@@ -399,7 +399,7 @@ func TestAdminServer(t *testing.T) {
399399
time.Sleep(500 * time.Millisecond)
400400

401401
// Create second workflow
402-
handle2, err := RunAsWorkflow(ctx, testWorkflow, "workflow2")
402+
handle2, err := RunWorkflow(ctx, testWorkflow, "workflow2")
403403
require.NoError(t, err, "Failed to create second workflow")
404404
result2, err := handle2.GetResult()
405405
require.NoError(t, err, "Failed to get second workflow result")

dbos/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ func TestForkWorkflow(t *testing.T) {
517517
}
518518

519519
// Child workflow 1
520-
child1Handle, err := RunAsWorkflow(ctx, childWorkflow1, input)
520+
child1Handle, err := RunWorkflow(ctx, childWorkflow1, input)
521521
if err != nil {
522522
return "", err
523523
}
@@ -536,7 +536,7 @@ func TestForkWorkflow(t *testing.T) {
536536
}
537537

538538
// Child workflow 2
539-
child2Handle, err := RunAsWorkflow(ctx, childWorkflow2, input)
539+
child2Handle, err := RunWorkflow(ctx, childWorkflow2, input)
540540
if err != nil {
541541
return "", err
542542
}

dbos/dbos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ type DBOSContext interface {
102102

103103
// Workflow operations
104104
RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption) (any, error) // Execute a function as a durable step within a workflow
105-
RunAsWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opts ...WorkflowOption) (WorkflowHandle[any], error) // Start a new workflow execution
105+
RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opts ...WorkflowOption) (WorkflowHandle[any], error) // Start a new workflow execution
106106
Send(_ DBOSContext, destinationID string, message any, topic string) error // Send a message to another workflow
107107
Recv(_ DBOSContext, topic string, timeout time.Duration) (any, error) // Receive a message sent to this workflow
108108
SetEvent(_ DBOSContext, key string, message any) error // Set a key-value event for this workflow

dbos/queue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func WithMaxTasksPerIteration(maxTasks int) QueueOption {
8181
}
8282

8383
// NewWorkflowQueue creates a new workflow queue with the specified name and configuration options.
84-
// The queue must be created before workflows can be enqueued to it using the WithQueue option in RunAsWorkflow.
84+
// The queue must be created before workflows can be enqueued to it using the WithQueue option in RunWorkflow.
8585
// Queues provide controlled execution with support for concurrency limits, priority scheduling, and rate limiting.
8686
//
8787
// Example:
@@ -96,7 +96,7 @@ func WithMaxTasksPerIteration(maxTasks int) QueueOption {
9696
// )
9797
//
9898
// // Enqueue workflows to this queue:
99-
// handle, err := dbos.RunAsWorkflow(ctx, SendEmailWorkflow, emailData, dbos.WithQueue("email-queue"))
99+
// handle, err := dbos.RunWorkflow(ctx, SendEmailWorkflow, emailData, dbos.WithQueue("email-queue"))
100100
func NewWorkflowQueue(dbosCtx DBOSContext, name string, options ...QueueOption) WorkflowQueue {
101101
ctx, ok := dbosCtx.(*dbosContext)
102102
if !ok {

0 commit comments

Comments
 (0)