Skip to content

Commit 62000c0

Browse files
committed
pass logger through
1 parent 6f29660 commit 62000c0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

dbos/serialization.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ func isNilValue(data any) bool {
2626
return false
2727
}
2828

29-
func serialize(data any) (string, error) {
29+
func serialize(data any, logger *slog.Logger) (string, error) {
3030
// Handle nil and nil-able type cases (pointer, slice, map, chan, func, interface)
3131
if isNilValue(data) {
3232
return base64.StdEncoding.EncodeToString([]byte{}), nil
3333
}
3434

3535
// Lazy registration of the type for gob encoding
36-
safeGobRegister(data, nil)
36+
safeGobRegister(data, logger)
3737

3838
var buf bytes.Buffer
3939
enc := gob.NewEncoder(&buf)

dbos/system_database.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ func (s *sysDB) insertWorkflowStatus(ctx context.Context, input insertWorkflowSt
440440
timeoutMs = &millis
441441
}
442442

443-
inputString, err := serialize(input.status.Input)
443+
inputString, err := serialize(input.status.Input, s.logger)
444444
if err != nil {
445445
return nil, fmt.Errorf("failed to serialize input: %w", err)
446446
}
@@ -830,7 +830,7 @@ func (s *sysDB) updateWorkflowOutcome(ctx context.Context, input updateWorkflowO
830830
SET status = $1, output = $2, error = $3, updated_at = $4, deduplication_id = NULL
831831
WHERE workflow_uuid = $5 AND NOT (status = $6 AND $1 in ($7, $8))`, pgx.Identifier{s.schema}.Sanitize())
832832

833-
outputString, err := serialize(input.output)
833+
outputString, err := serialize(input.output, s.logger)
834834
if err != nil {
835835
return fmt.Errorf("failed to serialize output: %w", err)
836836
}
@@ -1105,7 +1105,7 @@ func (s *sysDB) forkWorkflow(ctx context.Context, input forkWorkflowDBInput) (st
11051105
recovery_attempts
11061106
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)`, pgx.Identifier{s.schema}.Sanitize())
11071107

1108-
inputString, err := serialize(originalWorkflow.Input)
1108+
inputString, err := serialize(originalWorkflow.Input, s.logger)
11091109
if err != nil {
11101110
return "", fmt.Errorf("failed to serialize input: %w", err)
11111111
}
@@ -1220,7 +1220,7 @@ func (s *sysDB) recordOperationResult(ctx context.Context, input recordOperation
12201220
errorString = &e
12211221
}
12221222

1223-
outputString, err := serialize(input.output)
1223+
outputString, err := serialize(input.output, s.logger)
12241224
if err != nil {
12251225
return fmt.Errorf("failed to serialize output: %w", err)
12261226
}
@@ -1785,7 +1785,7 @@ func (s *sysDB) send(ctx context.Context, input WorkflowSendInput) error {
17851785
}
17861786

17871787
// Serialize the message. It must have been registered with encoding/gob by the user if not a basic type.
1788-
messageString, err := serialize(input.Message)
1788+
messageString, err := serialize(input.Message, s.logger)
17891789
if err != nil {
17901790
return fmt.Errorf("failed to serialize message: %w", err)
17911791
}
@@ -2020,7 +2020,7 @@ func (s *sysDB) setEvent(ctx context.Context, input WorkflowSetEventInput) error
20202020
}
20212021

20222022
// Serialize the message. It must have been registered with encoding/gob by the user if not a basic type.
2023-
messageString, err := serialize(input.Message)
2023+
messageString, err := serialize(input.Message, s.logger)
20242024
if err != nil {
20252025
return fmt.Errorf("failed to serialize message: %w", err)
20262026
}

dbos/workflow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (h *workflowHandle[R]) GetResult() (R, error) {
171171
workflowState, ok := h.dbosContext.Value(workflowStateKey).(*workflowState)
172172
isWithinWorkflow := ok && workflowState != nil
173173
if isWithinWorkflow {
174-
encodedOutput, encErr := serialize(outcome.result)
174+
encodedOutput, encErr := serialize(outcome.result, h.dbosContext.(*dbosContext).logger)
175175
if encErr != nil {
176176
return *new(R), newWorkflowExecutionError(workflowState.workflowID, fmt.Errorf("serializing child workflow result: %w", encErr))
177177
}
@@ -210,7 +210,7 @@ func (h *workflowPollingHandle[R]) GetResult() (R, error) {
210210
workflowState, ok := h.dbosContext.Value(workflowStateKey).(*workflowState)
211211
isWithinWorkflow := ok && workflowState != nil
212212
if isWithinWorkflow {
213-
encodedOutput, encErr := serialize(typedResult)
213+
encodedOutput, encErr := serialize(typedResult, h.dbosContext.(*dbosContext).logger)
214214
if encErr != nil {
215215
return *new(R), newWorkflowExecutionError(workflowState.workflowID, fmt.Errorf("serializing child workflow result: %w", encErr))
216216
}

0 commit comments

Comments
 (0)