Skip to content

Commit

Permalink
snapshot_flow: use OriginalRunID over uuid.New
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Feb 16, 2024
1 parent 7583072 commit e6857ea
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions flow/workflows/snapshot_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"
"time"

"github.com/google/uuid"
"go.temporal.io/sdk/log"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
Expand Down Expand Up @@ -97,18 +96,11 @@ func (s *SnapshotFlowExecution) cloneTable(

srcName := mapping.SourceTableIdentifier
dstName := mapping.DestinationTableIdentifier
childWorkflowIDSideEffect := workflow.SideEffect(ctx, func(ctx workflow.Context) interface{} {
childWorkflowID := fmt.Sprintf("clone_%s_%s_%s", flowName, dstName, uuid.New().String())
reg := regexp.MustCompile("[^a-zA-Z0-9]+")
return reg.ReplaceAllString(childWorkflowID, "_")
})
originalRunID := workflow.GetInfo(ctx).OriginalRunID

var childWorkflowID string
if err := childWorkflowIDSideEffect.Get(&childWorkflowID); err != nil {
s.logger.Error(fmt.Sprintf("failed to get child id for source table %s and destination table %s",
srcName, dstName), slog.Any("error", err), cloneLog)
return fmt.Errorf("failed to get child workflow ID: %w", err)
}
childWorkflowID := fmt.Sprintf("clone_%s_%s_%s", flowName, dstName, originalRunID)
reg := regexp.MustCompile("[^a-zA-Z0-9_]+")
childWorkflowID = reg.ReplaceAllString(childWorkflowID, "_")

s.logger.Info(fmt.Sprintf("Obtained child id %s for source table %s and destination table %s",
childWorkflowID, srcName, dstName), cloneLog)
Expand Down

0 comments on commit e6857ea

Please sign in to comment.