Skip to content

Commit ca353bc

Browse files
committed
Shutdown -> Cancel + cautionary unlock
1 parent fc04f1f commit ca353bc

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

dbos/admin_server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestAdminServer(t *testing.T) {
3030
// Ensure cleanup
3131
defer func() {
3232
if ctx != nil {
33-
ctx.Shutdown()
33+
ctx.Cancel()
3434
}
3535
}()
3636

@@ -73,7 +73,7 @@ func TestAdminServer(t *testing.T) {
7373
// Ensure cleanup
7474
defer func() {
7575
if ctx != nil {
76-
ctx.Shutdown()
76+
ctx.Cancel()
7777
}
7878
}()
7979

dbos/dbos.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type DBOSContext interface {
5858

5959
// Context Lifecycle
6060
Launch() error
61-
Shutdown()
61+
Cancel()
6262

6363
// Workflow operations
6464
RunAsStep(_ DBOSContext, fn StepFunc, input any) (any, error)
@@ -315,9 +315,8 @@ func (c *dbosContext) Launch() error {
315315
return nil
316316
}
317317

318-
// We might consider renaming this to "Cancel" to me more idiomatic
319318
// TODO: shutdown should really have a timeout and return an error if it wasn't able to shutdown everything
320-
func (c *dbosContext) Shutdown() {
319+
func (c *dbosContext) Cancel() {
321320
c.logger.Info("Shutting down DBOS context")
322321

323322
// Cancel the context to signal all resources to stop

dbos/dbos_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestConfigValidationErrorTypes(t *testing.T) {
2020
}
2121
defer func() {
2222
if ctx != nil {
23-
ctx.Shutdown()
23+
ctx.Cancel()
2424
}
2525
}() // Clean up executor
2626

dbos/logger_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestLogger(t *testing.T) {
2424
}
2525
t.Cleanup(func() {
2626
if dbosCtx != nil {
27-
dbosCtx.Shutdown()
27+
dbosCtx.Cancel()
2828
}
2929
})
3030

@@ -62,7 +62,7 @@ func TestLogger(t *testing.T) {
6262
}
6363
t.Cleanup(func() {
6464
if dbosCtx != nil {
65-
dbosCtx.Shutdown()
65+
dbosCtx.Cancel()
6666
}
6767
})
6868

dbos/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func setupDBOS(t *testing.T, dropDB bool, checkLeaks bool) DBOSContext {
7272
t.Cleanup(func() {
7373
dbosCtx.(*dbosContext).logger.Info("Cleaning up DBOS instance...")
7474
if dbosCtx != nil {
75-
dbosCtx.Shutdown()
75+
dbosCtx.Cancel()
7676
}
7777
dbosCtx = nil
7878
if checkLeaks {

dbos/workflows_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,8 @@ func sendIdempotencyWorkflow(ctx DBOSContext, input sendWorkflowInput) (string,
10721072
func receiveIdempotencyWorkflow(ctx DBOSContext, topic string) (string, error) {
10731073
msg, err := Recv[string](ctx, WorkflowRecvInput{Topic: topic, Timeout: 3 * time.Second})
10741074
if err != nil {
1075+
// Unlock the test in this case
1076+
receiveIdempotencyStartEvent.Set()
10751077
return "", err
10761078
}
10771079
receiveIdempotencyStartEvent.Set()

0 commit comments

Comments
 (0)