Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 18, 2024
1 parent e84003f commit a20977c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
16 changes: 16 additions & 0 deletions sources/mysql/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,19 @@ func retrieveSessionSQLMode(db *sql.DB) ([]string, error) {

return strings.Split(sqlMode, ","), nil
}

func hasGTIDEnabled(ctx context.Context, db *sql.DB) (bool, error) {
requiredVariables := []string{"gtid_mode", "enforce_gtid_consistency"}
for _, requiredVariable := range requiredVariables {
value, err := fetchVariable(ctx, db, requiredVariable)
if err != nil {
return false, err
}

if strings.ToUpper(value) != "ON" {
return false, nil
}
}

return true, nil
}
18 changes: 0 additions & 18 deletions sources/mysql/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"database/sql"
"fmt"
"strings"

"github.com/artie-labs/reader/config"
"github.com/artie-labs/reader/sources/mysql/streaming"
"github.com/artie-labs/reader/writers"
Expand Down Expand Up @@ -45,19 +43,3 @@ func (s Streaming) Run(ctx context.Context, writer writers.Writer) error {
_, err := writer.Write(ctx, s.iterator)
return err
}

func hasGTIDEnabled(ctx context.Context, db *sql.DB) (bool, error) {
requiredVariables := []string{"gtid_mode", "enforce_gtid_consistency"}
for _, requiredVariable := range requiredVariables {
value, err := fetchVariable(ctx, db, requiredVariable)
if err != nil {
return false, err
}

if strings.ToUpper(value) != "ON" {
return false, nil
}
}

return true, nil
}

0 comments on commit a20977c

Please sign in to comment.