Skip to content

Commit

Permalink
Minor Improvements (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored May 24, 2024
1 parent d86fb0b commit b9619ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
21 changes: 10 additions & 11 deletions config/mssql.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"cmp"
"fmt"
"github.com/artie-labs/reader/constants"
"github.com/artie-labs/reader/lib/rdbms/scan"
Expand All @@ -20,12 +21,14 @@ type MSSQL struct {
}

type MSSQLTable struct {
Name string `yaml:"name"`
Schema string `yaml:"schema"`
BatchSize uint `yaml:"batchSize"`
OptionalPrimaryKeyValStart string `yaml:"optionalPrimaryKeyValStart"`
OptionalPrimaryKeyValEnd string `yaml:"optionalPrimaryKeyValEnd"`
ExcludeColumns []string `yaml:"excludeColumns"`
Name string `yaml:"name"`
Schema string `yaml:"schema"`

// Optional settings
BatchSize uint `yaml:"batchSize,omitempty"`
OptionalPrimaryKeyValStart string `yaml:"optionalPrimaryKeyValStart,omitempty"`
OptionalPrimaryKeyValEnd string `yaml:"optionalPrimaryKeyValEnd,omitempty"`
ExcludeColumns []string `yaml:"excludeColumns,omitempty"`
}

func (m *MSSQL) ToDSN() string {
Expand All @@ -43,11 +46,7 @@ func (m *MSSQL) ToDSN() string {
}

func (m *MSSQLTable) GetBatchSize() uint {
if m.BatchSize > 0 {
return m.BatchSize
} else {
return constants.DefaultBatchSize
}
return cmp.Or(m.BatchSize, constants.DefaultBatchSize)
}

func (m *MSSQLTable) GetOptionalPrimaryKeyValStart() []string {
Expand Down
18 changes: 8 additions & 10 deletions config/mysql.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"cmp"
"fmt"
"math"
"strings"
Expand Down Expand Up @@ -32,19 +33,16 @@ func (m *MySQL) ToDSN() string {
}

type MySQLTable struct {
Name string `yaml:"name"`
BatchSize uint `yaml:"batchSize"`
OptionalPrimaryKeyValStart string `yaml:"optionalPrimaryKeyValStart"`
OptionalPrimaryKeyValEnd string `yaml:"optionalPrimaryKeyValEnd"`
ExcludeColumns []string `yaml:"excludeColumns"`
Name string `yaml:"name"`
// Optional settings
BatchSize uint `yaml:"batchSize,omitempty"`
OptionalPrimaryKeyValStart string `yaml:"optionalPrimaryKeyValStart,omitempty"`
OptionalPrimaryKeyValEnd string `yaml:"optionalPrimaryKeyValEnd,omitempty"`
ExcludeColumns []string `yaml:"excludeColumns,omitempty"`
}

func (m *MySQLTable) GetBatchSize() uint {
if m.BatchSize > 0 {
return m.BatchSize
} else {
return constants.DefaultBatchSize
}
return cmp.Or(m.BatchSize, constants.DefaultBatchSize)
}

func (m *MySQLTable) GetOptionalPrimaryKeyValStart() []string {
Expand Down
21 changes: 10 additions & 11 deletions config/postgres.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"cmp"
"fmt"
"math"
"strings"
Expand Down Expand Up @@ -33,20 +34,18 @@ func (p *PostgreSQL) ToDSN() string {
}

type PostgreSQLTable struct {
Name string `yaml:"name"`
Schema string `yaml:"schema"`
BatchSize uint `yaml:"batchSize"`
OptionalPrimaryKeyValStart string `yaml:"optionalPrimaryKeyValStart"`
OptionalPrimaryKeyValEnd string `yaml:"optionalPrimaryKeyValEnd"`
ExcludeColumns []string `yaml:"excludeColumns"`
Name string `yaml:"name"`
Schema string `yaml:"schema"`

// Optional settings
BatchSize uint `yaml:"batchSize,omitempty"`
OptionalPrimaryKeyValStart string `yaml:"optionalPrimaryKeyValStart,omitempty"`
OptionalPrimaryKeyValEnd string `yaml:"optionalPrimaryKeyValEnd,omitempty"`
ExcludeColumns []string `yaml:"excludeColumns,omitempty"`
}

func (p *PostgreSQLTable) GetBatchSize() uint {
if p.BatchSize > 0 {
return p.BatchSize
} else {
return constants.DefaultBatchSize
}
return cmp.Or(p.BatchSize, constants.DefaultBatchSize)
}

func (p *PostgreSQLTable) GetOptionalPrimaryKeyValStart() []string {
Expand Down
2 changes: 1 addition & 1 deletion sources/dynamodb/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *SnapshotStore) streamAndPublish(ctx context.Context, writer writers.Wri
}

// TODO: Create an actual iterator over the files that is passed to the writer.
if _, err := writer.Write(ctx, iterator.Once(messages)); err != nil {
if _, err = writer.Write(ctx, iterator.Once(messages)); err != nil {
return fmt.Errorf("failed to publish messages: %w", err)
}

Expand Down

0 comments on commit b9619ba

Please sign in to comment.