From 543524c16590aeb40c5e0a41cb5cf130f2adaa83 Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Sat, 11 Nov 2023 17:33:03 +0000 Subject: [PATCH] Move NameAndExclude set contruction to constructor --- flow/activities/flowable.go | 9 +-------- flow/model/model.go | 8 ++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/flow/activities/flowable.go b/flow/activities/flowable.go index e96df083ac..76b55c0e8e 100644 --- a/flow/activities/flowable.go +++ b/flow/activities/flowable.go @@ -187,14 +187,7 @@ func (a *FlowableActivity) StartFlow(ctx context.Context, tblNameMapping := make(map[string]model.NameAndExclude) for _, v := range input.FlowConnectionConfigs.TableMappings { - exclude := make(map[string]struct{}, len(v.Exclude)) - for _, col := range v.Exclude { - exclude[col] = struct{}{} - } - tblNameMapping[v.SourceTableIdentifier] = model.NameAndExclude{ - Name: v.DestinationTableIdentifier, - Exclude: exclude, - } + tblNameMapping[v.SourceTableIdentifier] = model.NewNameAndExclude(v.DestinationTableIdentifier, v.Exclude) } idleTimeout := utils.GetEnvInt("PEERDB_CDC_IDLE_TIMEOUT_SECONDS", 10) diff --git a/flow/model/model.go b/flow/model/model.go index ffc2c296bd..5d7c627f60 100644 --- a/flow/model/model.go +++ b/flow/model/model.go @@ -17,6 +17,14 @@ type NameAndExclude struct { Exclude map[string]struct{} } +func NewNameAndExclude(name string, exclude []string) NameAndExclude { + exset := make(map[string]struct{}, len(exclude)) + for _, col := range exclude { + exset[col] = struct{}{} + } + return NameAndExclude{Name: name, Exclude: exset} +} + type PullRecordsRequest struct { // FlowJobName is the name of the flow job. FlowJobName string