Skip to content

Commit 28d50f8

Browse files
authored
small cleanup (#168)
1 parent 846b6bd commit 28d50f8

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

cmd/dbos/migrate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func init() {
2929

3030
func runMigrate(cmd *cobra.Command, args []string) error {
3131
// Get database URL
32-
dbURL, err := getDBURL(cmd)
32+
dbURL, err := getDBURL()
3333
if err != nil {
3434
return err
3535
}

cmd/dbos/reset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func runReset(cmd *cobra.Command, args []string) error {
3434
}
3535

3636
// Get database URL
37-
dbURL, err := getDBURL(cmd)
37+
dbURL, err := getDBURL()
3838
if err != nil {
3939
return err
4040
}

cmd/dbos/utils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"os"
1010

1111
"github.com/dbos-inc/dbos-transact-golang/dbos"
12-
"github.com/spf13/cobra"
1312
"github.com/spf13/viper"
1413
)
1514

@@ -43,7 +42,7 @@ func maskPassword(dbURL string) string {
4342
}
4443

4544
// getDBURL resolves the database URL from flag, config, or environment variable
46-
func getDBURL(_ *cobra.Command) (string, error) {
45+
func getDBURL() (string, error) {
4746
var resolvedURL string
4847
var source string
4948

cmd/dbos/workflow.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func init() {
8585

8686
func runWorkflowList(cmd *cobra.Command, args []string) error {
8787
// Get database URL
88-
dbURL, err := getDBURL(cmd)
88+
dbURL, err := getDBURL()
8989
if err != nil {
9090
return err
9191
}
@@ -192,7 +192,7 @@ func runWorkflowGet(cmd *cobra.Command, args []string) error {
192192
workflowID := args[0]
193193

194194
// Get database URL
195-
dbURL, err := getDBURL(cmd)
195+
dbURL, err := getDBURL()
196196
if err != nil {
197197
return err
198198
}
@@ -227,7 +227,7 @@ func runWorkflowSteps(cmd *cobra.Command, args []string) error {
227227
workflowID := args[0]
228228

229229
// Get database URL
230-
dbURL, err := getDBURL(cmd)
230+
dbURL, err := getDBURL()
231231
if err != nil {
232232
return err
233233
}
@@ -259,7 +259,7 @@ func runWorkflowCancel(cmd *cobra.Command, args []string) error {
259259
workflowID := args[0]
260260

261261
// Get database URL
262-
dbURL, err := getDBURL(cmd)
262+
dbURL, err := getDBURL()
263263
if err != nil {
264264
return err
265265
}
@@ -285,7 +285,7 @@ func runWorkflowResume(cmd *cobra.Command, args []string) error {
285285
workflowID := args[0]
286286

287287
// Get database URL
288-
dbURL, err := getDBURL(cmd)
288+
dbURL, err := getDBURL()
289289
if err != nil {
290290
return err
291291
}
@@ -318,7 +318,7 @@ func runWorkflowFork(cmd *cobra.Command, args []string) error {
318318
workflowID := args[0]
319319

320320
// Get database URL
321-
dbURL, err := getDBURL(cmd)
321+
dbURL, err := getDBURL()
322322
if err != nil {
323323
return err
324324
}

dbos/workflow.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,14 +839,11 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
839839
return earlyReturnPollingHandle, nil
840840
}
841841

842-
outcomeChan := make(chan workflowOutcome[any], 1)
843-
844842
// Create workflow state to track step execution
845843
wfState := &workflowState{
846844
workflowID: workflowID,
847845
stepID: -1, // Steps are O-indexed
848846
}
849-
850847
workflowCtx := WithValue(c, workflowStateKey, wfState)
851848

852849
// If the workflow has a timeout but no deadline, compute the deadline from the timeout.
@@ -863,7 +860,7 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
863860
if !durableDeadline.IsZero() {
864861
workflowCtx, _ = WithTimeout(workflowCtx, time.Until(durableDeadline))
865862
// Register a cancel function that cancels the workflow in the DB as soon as the context is cancelled
866-
dbosCancelFunction := func() {
863+
workflowCancelFunction := func() {
867864
c.logger.Info("Cancelling workflow", "workflow_id", workflowID)
868865
err = retry(c, func() error {
869866
return c.systemDB.cancelWorkflow(uncancellableCtx, workflowID)
@@ -873,10 +870,11 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
873870
}
874871
close(cancelFuncCompleted)
875872
}
876-
stopFunc = context.AfterFunc(workflowCtx, dbosCancelFunction)
873+
stopFunc = context.AfterFunc(workflowCtx, workflowCancelFunction)
877874
}
878875

879876
// Run the function in a goroutine
877+
outcomeChan := make(chan workflowOutcome[any], 1)
880878
c.workflowsWg.Add(1)
881879
go func() {
882880
defer c.workflowsWg.Done()

0 commit comments

Comments
 (0)