From c77d70c091a9efa21d6c5028736341f416d08c03 Mon Sep 17 00:00:00 2001 From: tuannguyensn2001 Date: Thu, 25 Sep 2025 09:06:18 +0700 Subject: [PATCH] Add package level launch , shutdown --- dbos/dbos.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/dbos/dbos.go b/dbos/dbos.go index 1cbf6c26..63b1fefe 100644 --- a/dbos/dbos.go +++ b/dbos/dbos.go @@ -579,3 +579,40 @@ func getDBOSVersion() string { } return "unknown" } + +// Launch launches the DBOS runtime using the provided DBOSContext. +// This is a package-level wrapper for the DBOSContext.Launch() method. +// +// Example: +// +// ctx, err := dbos.NewDBOSContext(context.Background(), config) +// if err != nil { +// log.Fatal(err) +// } +// +// if err := dbos.Launch(ctx); err != nil { +// log.Fatal(err) +// } +func Launch(ctx DBOSContext) error { + if ctx == nil { + return fmt.Errorf("ctx cannot be nil") + } + return ctx.Launch() +} + +// Shutdown gracefully shuts down the DBOS runtime using the provided DBOSContext and timeout. +// This is a package-level wrapper for the DBOSContext.Shutdown() method. +// +// Example: +// +// ctx, err := dbos.NewDBOSContext(context.Background(), config) +// if err != nil { +// log.Fatal(err) +// } +// defer dbos.Shutdown(ctx, 30*time.Second) +func Shutdown(ctx DBOSContext, timeout time.Duration) { + if ctx == nil { + return + } + ctx.Shutdown(timeout) +}