Skip to content

Commit

Permalink
Make idle timeout configurable
Browse files Browse the repository at this point in the history
`PEERDB_CDC_IDLE_TIMEOUT_SECONDS` is the env var
  • Loading branch information
iskakaushik committed Oct 22, 2023
1 parent 3405093 commit d605a0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flow/activities/flowable.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,16 @@ func (a *FlowableActivity) StartFlow(ctx context.Context,
tblNameMapping[v.SourceTableIdentifier] = v.DestinationTableIdentifier
}

idleTimeout := utils.GetEnvInt("PEERDB_CDC_IDLE_TIMEOUT_SECONDS", 10)

startTime := time.Now()
recordsWithTableSchemaDelta, err := srcConn.PullRecords(&model.PullRecordsRequest{
FlowJobName: input.FlowConnectionConfigs.FlowJobName,
SrcTableIDNameMapping: input.FlowConnectionConfigs.SrcTableIdNameMapping,
TableNameMapping: tblNameMapping,
LastSyncState: input.LastSyncState,
MaxBatchSize: uint32(input.SyncFlowOptions.BatchSize),
IdleTimeout: 10 * time.Second,
IdleTimeout: time.Duration(idleTimeout) * time.Second,
TableNameSchemaMapping: input.FlowConnectionConfigs.TableNameSchemaMapping,
OverridePublicationName: input.FlowConnectionConfigs.PublicationName,
OverrideReplicationSlotName: input.FlowConnectionConfigs.ReplicationSlotName,
Expand Down
17 changes: 17 additions & 0 deletions flow/connectors/utils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,20 @@ func GetEnvBool(name string, defaultValue bool) bool {

return b
}

// GetEnvInt returns the value of the environment variable with the given name
// or defaultValue if the environment variable is not set or is not a valid
// integer value.
func GetEnvInt(name string, defaultValue int) int {
val, ok := GetEnv(name)
if !ok {
return defaultValue
}

i, err := strconv.Atoi(val)
if err != nil {
return defaultValue
}

return i
}

0 comments on commit d605a0b

Please sign in to comment.