Skip to content

Commit f450782

Browse files
committed
no cancel for now, just shutdown
1 parent 5fde81e commit f450782

File tree

1 file changed

+14
-31
lines changed

1 file changed

+14
-31
lines changed

dbos/dbos.go

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ type DBOSContext interface {
7272

7373
// Context Lifecycle
7474
Launch() error // Launch the DBOS runtime including system database, queues, admin server, and workflow recovery
75-
Cancel(timeout time.Duration) // Cancel the DBOS context and wait for workflows to complete within timeout
7675
Shutdown(timeout time.Duration) // Gracefully shutdown all DBOS runtime components with ordered cleanup sequence
7776

7877
// Workflow operations
@@ -373,17 +372,22 @@ func (c *dbosContext) Launch() error {
373372
return nil
374373
}
375374

376-
// Cancel cancels the DBOS context and waits for all running workflows to complete within the specified timeout.
377-
// This is the core cancellation functionality that signals all workflows and steps to stop processing
378-
// by canceling their contexts, which can be detected using their context's Done() method.
375+
// Shutdown gracefully shuts down the DBOS runtime by performing a complete, ordered cleanup
376+
// of all system components. The shutdown sequence includes:
379377
//
380-
// The method blocks until all workflows complete or the timeout expires. If the timeout is reached
381-
// while workflows are still running, a warning is logged but the method continues.
378+
// 1. Calls Cancel to stop workflows and cancel the context
379+
// 2. Waits for the queue runner to complete processing
380+
// 3. Stops the workflow scheduler and waits for scheduled jobs to finish
381+
// 4. Shuts down the system database connection pool and notification listener
382+
// 5. Shuts down the admin server
383+
// 6. Marks the context as not launched
382384
//
383-
// Cancel is called internally by Shutdown.
384-
// It is a permanent operation that should be used when the application is shutting down or deactivated.
385-
func (c *dbosContext) Cancel(timeout time.Duration) {
386-
c.logger.Info("Cancelling DBOS context")
385+
// Each step respects the provided timeout. If any component doesn't shut down within the timeout,
386+
// a warning is logged and the shutdown continues to the next component.
387+
//
388+
// Shutdown is a permanent operation and should be called when the application is terminating.
389+
func (c *dbosContext) Shutdown(timeout time.Duration) {
390+
c.logger.Info("Shutting down DBOS context")
387391

388392
// Cancel the context to signal all resources to stop
389393
c.ctxCancelFunc(errors.New("DBOS cancellation initiated"))
@@ -402,27 +406,6 @@ func (c *dbosContext) Cancel(timeout time.Duration) {
402406
// For now just log a warning: eventually we might want Cancel to return an error.
403407
c.logger.Warn("Timeout waiting for workflows to complete", "timeout", timeout)
404408
}
405-
}
406-
407-
// Shutdown gracefully shuts down the DBOS runtime by performing a complete, ordered cleanup
408-
// of all system components. The shutdown sequence includes:
409-
//
410-
// 1. Calls Cancel to stop workflows and cancel the context
411-
// 2. Waits for the queue runner to complete processing
412-
// 3. Stops the workflow scheduler and waits for scheduled jobs to finish
413-
// 4. Shuts down the system database connection pool and notification listener
414-
// 5. Shuts down the admin server
415-
// 6. Marks the context as not launched
416-
//
417-
// Each step respects the provided timeout. If any component doesn't shut down within the timeout,
418-
// a warning is logged and the shutdown continues to the next component.
419-
//
420-
// Shutdown is a permanent operation and should be called when the application is terminating.
421-
func (c *dbosContext) Shutdown(timeout time.Duration) {
422-
c.logger.Info("Shutting down DBOS context")
423-
424-
// Signal cancellation to the core DBOS operations and resources
425-
c.Cancel(timeout)
426409

427410
// Wait for queue runner to finish
428411
if c.queueRunner != nil && c.launched.Load() {

0 commit comments

Comments
 (0)