Skip to content

Commit ee90b42

Browse files
committed
call safeGobRegister
1 parent 323c6b7 commit ee90b42

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

dbos/client.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package dbos
22

33
import (
44
"context"
5-
"encoding/gob"
65
"errors"
76
"fmt"
87
"log/slog"
@@ -242,9 +241,9 @@ func Enqueue[P any, R any](c Client, queueName, workflowName string, input P, op
242241

243242
// Register the input and outputs for gob encoding
244243
var typedInput P
245-
gob.Register(typedInput)
244+
safeGobRegister(typedInput, nil)
246245
var typedOutput R
247-
gob.Register(typedOutput)
246+
safeGobRegister(typedOutput, nil)
248247

249248
// Call the interface method with the same signature
250249
handle, err := c.Enqueue(queueName, workflowName, input, opts...)

dbos/dbos.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dbos
33
import (
44
"context"
55
"crypto/sha256"
6-
"encoding/gob"
76
"encoding/hex"
87
"errors"
98
"fmt"
@@ -317,11 +316,11 @@ func NewDBOSContext(ctx context.Context, inputConfig Config) (DBOSContext, error
317316

318317
// Register types we serialize with gob
319318
var t time.Time
320-
gob.Register(t)
319+
safeGobRegister(t, initExecutor.logger)
321320
var ws []WorkflowStatus
322-
gob.Register(ws)
321+
safeGobRegister(ws, initExecutor.logger)
323322
var si []StepInfo
324-
gob.Register(si)
323+
safeGobRegister(si, initExecutor.logger)
325324

326325
// Initialize global variables from processed config (already handles env vars and defaults)
327326
initExecutor.applicationVersion = config.ApplicationVersion

dbos/workflow.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package dbos
22

33
import (
44
"context"
5-
"encoding/gob"
65
"errors"
76
"fmt"
87
"math"
@@ -439,8 +438,8 @@ func RegisterWorkflow[P any, R any](ctx DBOSContext, fn Workflow[P, R], opts ...
439438
// Registry the input/output types for gob encoding
440439
var p P
441440
var r R
442-
gob.Register(p)
443-
gob.Register(r)
441+
safeGobRegister(p, ctx.(*dbosContext).logger)
442+
safeGobRegister(r, ctx.(*dbosContext).logger)
444443

445444
// Register a type-erased version of the durable workflow for recovery
446445
typedErasedWorkflow := WorkflowFunc(func(ctx DBOSContext, input any) (any, error) {
@@ -1042,7 +1041,7 @@ func RunAsStep[R any](ctx DBOSContext, fn Step[R], opts ...StepOption) (R, error
10421041

10431042
// Register the output type for gob encoding
10441043
var r R
1045-
gob.Register(r)
1044+
safeGobRegister(r, ctx.(*dbosContext).logger)
10461045

10471046
// Append WithStepName option to ensure the step name is set. This will not erase a user-provided step name
10481047
stepName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
@@ -1206,7 +1205,7 @@ func Send[P any](ctx DBOSContext, destinationID string, message P, topic string)
12061205
return errors.New("ctx cannot be nil")
12071206
}
12081207
var typedMessage P
1209-
gob.Register(typedMessage)
1208+
safeGobRegister(typedMessage, ctx.(*dbosContext).logger)
12101209
return ctx.Send(ctx, destinationID, message, topic)
12111210
}
12121211

@@ -1283,7 +1282,7 @@ func SetEvent[P any](ctx DBOSContext, key string, message P) error {
12831282
return errors.New("ctx cannot be nil")
12841283
}
12851284
var typedMessage P
1286-
gob.Register(typedMessage)
1285+
safeGobRegister(typedMessage, ctx.(*dbosContext).logger)
12871286
return ctx.SetEvent(ctx, key, message)
12881287
}
12891288

@@ -1477,7 +1476,7 @@ func RetrieveWorkflow[R any](ctx DBOSContext, workflowID string) (WorkflowHandle
14771476

14781477
// Register the output for gob encoding
14791478
var r R
1480-
gob.Register(r)
1479+
safeGobRegister(r, ctx.(*dbosContext).logger)
14811480

14821481
// Call the interface method
14831482
handle, err := ctx.RetrieveWorkflow(ctx, workflowID)
@@ -1571,7 +1570,7 @@ func ResumeWorkflow[R any](ctx DBOSContext, workflowID string) (WorkflowHandle[R
15711570

15721571
// Register the output for gob encoding
15731572
var r R
1574-
gob.Register(r)
1573+
safeGobRegister(r, ctx.(*dbosContext).logger)
15751574

15761575
_, err := ctx.ResumeWorkflow(ctx, workflowID)
15771576
if err != nil {
@@ -1663,7 +1662,7 @@ func ForkWorkflow[R any](ctx DBOSContext, input ForkWorkflowInput) (WorkflowHand
16631662

16641663
// Register the output for gob encoding
16651664
var r R
1666-
gob.Register(r)
1665+
safeGobRegister(r, ctx.(*dbosContext).logger)
16671666

16681667
handle, err := ctx.ForkWorkflow(ctx, input)
16691668
if err != nil {

0 commit comments

Comments
 (0)