Skip to content

Commit c77d70c

Browse files
tuannguyensn2001maxdml
authored andcommitted
Add package level launch , shutdown
1 parent 6ce631f commit c77d70c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

dbos/dbos.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,40 @@ func getDBOSVersion() string {
579579
}
580580
return "unknown"
581581
}
582+
583+
// Launch launches the DBOS runtime using the provided DBOSContext.
584+
// This is a package-level wrapper for the DBOSContext.Launch() method.
585+
//
586+
// Example:
587+
//
588+
// ctx, err := dbos.NewDBOSContext(context.Background(), config)
589+
// if err != nil {
590+
// log.Fatal(err)
591+
// }
592+
//
593+
// if err := dbos.Launch(ctx); err != nil {
594+
// log.Fatal(err)
595+
// }
596+
func Launch(ctx DBOSContext) error {
597+
if ctx == nil {
598+
return fmt.Errorf("ctx cannot be nil")
599+
}
600+
return ctx.Launch()
601+
}
602+
603+
// Shutdown gracefully shuts down the DBOS runtime using the provided DBOSContext and timeout.
604+
// This is a package-level wrapper for the DBOSContext.Shutdown() method.
605+
//
606+
// Example:
607+
//
608+
// ctx, err := dbos.NewDBOSContext(context.Background(), config)
609+
// if err != nil {
610+
// log.Fatal(err)
611+
// }
612+
// defer dbos.Shutdown(ctx, 30*time.Second)
613+
func Shutdown(ctx DBOSContext, timeout time.Duration) {
614+
if ctx == nil {
615+
return
616+
}
617+
ctx.Shutdown(timeout)
618+
}

0 commit comments

Comments
 (0)