@@ -32,15 +32,16 @@ const (
3232// Config holds configuration parameters for initializing a DBOS context.
3333// DatabaseURL and AppName are required.
3434type Config struct {
35- DatabaseURL string // PostgreSQL connection string (required)
36- AppName string // Application name for identification (required)
37- Logger * slog.Logger // Custom logger instance (defaults to a new slog logger)
38- AdminServer bool // Enable Transact admin HTTP server (disabled by default)
39- AdminServerPort int // Port for the admin HTTP server (default: 3001)
40- ConductorURL string // DBOS conductor service URL (optional)
41- ConductorAPIKey string // DBOS conductor API key (optional)
42- ApplicationVersion string // Application version (optional, overridden by DBOS__APPVERSION env var)
43- ExecutorID string // Executor ID (optional, overridden by DBOS__VMID env var)
35+ DatabaseURL string // PostgreSQL connection string (required)
36+ AppName string // Application name for identification (required)
37+ Logger * slog.Logger // Custom logger instance (defaults to a new slog logger)
38+ AdminServer bool // Enable Transact admin HTTP server (disabled by default)
39+ AdminServerPort int // Port for the admin HTTP server (default: 3001)
40+ ConductorURL string // DBOS conductor service URL (optional)
41+ ConductorAPIKey string // DBOS conductor API key (optional)
42+ ApplicationVersion string // Application version (optional, overridden by DBOS__APPVERSION env var)
43+ ExecutorID string // Executor ID (optional, overridden by DBOS__VMID env var)
44+ Context context.Context // User Context
4445}
4546
4647// processConfig enforces mandatory fields and applies defaults.
@@ -294,7 +295,13 @@ func (c *dbosContext) GetApplicationID() string {
294295// log.Fatal(err)
295296// }
296297func NewDBOSContext (inputConfig Config ) (DBOSContext , error ) {
297- ctx , cancelFunc := context .WithCancelCause (context .Background ())
298+ var baseCtx context.Context
299+ if inputConfig .Context != nil {
300+ baseCtx = inputConfig .Context
301+ } else {
302+ baseCtx = context .Background ()
303+ }
304+ ctx , cancelFunc := context .WithCancelCause (baseCtx )
298305 initExecutor := & dbosContext {
299306 workflowsWg : & sync.WaitGroup {},
300307 ctx : ctx ,
0 commit comments