Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactor #237

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions lib/cdc/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,9 @@ type Event interface {
GetColumns(ctx context.Context) *columns.Columns
}

// FieldLabelKind is used when the schema is turned on. Each schema object will be labelled.
// FieldLabelKind is used when the schema is turned on.
type FieldLabelKind string

const (
Before FieldLabelKind = "before"
After FieldLabelKind = "after"
Source FieldLabelKind = "source"
Op FieldLabelKind = "op"
TsMs FieldLabelKind = "ts_ms"
Transaction FieldLabelKind = "transaction"
After FieldLabelKind = "after"
)
7 changes: 0 additions & 7 deletions lib/cdc/mongo/debezium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"time"

"github.com/artie-labs/transfer/lib/cdc"
"github.com/artie-labs/transfer/lib/config/constants"
"github.com/artie-labs/transfer/lib/debezium"

Expand Down Expand Up @@ -442,12 +441,6 @@ func (p *MongoTestSuite) TestMongoDBEventWithSchema() {
schemaEvt, isOk := evt.(*SchemaEventPayload)
assert.True(p.T(), isOk)
assert.Equal(p.T(), schemaEvt.Schema.SchemaType, "struct")
assert.Equal(p.T(), schemaEvt.Schema.GetSchemaFromLabel(cdc.Source).Fields[0], debezium.Field{
Optional: false,
FieldName: "version",
DebeziumType: "",
Type: "string",
})
assert.False(p.T(), evt.DeletePayload())
cols := schemaEvt.GetColumns(p.ctx)
assert.NotNil(p.T(), cols)
Expand Down
5 changes: 5 additions & 0 deletions lib/cdc/util/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (

// ParseField returns a `parsedValue` as type interface{}
func parseField(ctx context.Context, field debezium.Field, value interface{}) interface{} {
if value == nil {
// Early exit.
return nil
}

// Check if the field is an integer and requires us to cast it as such.
if field.IsInteger() {
valFloat, isOk := value.(float64)
Expand Down
5 changes: 5 additions & 0 deletions lib/cdc/util/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func (u *UtilTestSuite) TestParseField() {
}

testCases := []_testCase{
{
name: "nil",
value: nil,
expectedValue: nil,
},
{
name: "string",
value: "robin",
Expand Down
4 changes: 0 additions & 4 deletions lib/stringutil/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (

// Override - pass in a list of vals, the right most value that is not empty will override.
func Override(vals ...string) string {
if len(vals) == 0 {
return ""
}

var retVal string
for _, val := range vals {
if val != "" {
Expand Down