Skip to content

Commit

Permalink
Use cfg.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Mar 22, 2024
1 parent 6f66d60 commit 7ac7dfb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions sources/mysql/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import (
)

type Source struct {
cfg config.MySQL
db *sql.DB
dbName string
cfg config.MySQL
db *sql.DB
}

func Load(cfg config.MySQL) (*Source, error) {
Expand All @@ -29,9 +28,8 @@ func Load(cfg config.MySQL) (*Source, error) {
return nil, fmt.Errorf("failed to connect to MySQL: %w", err)
}
return &Source{
cfg: cfg,
db: db,
dbName: cfg.Database,
cfg: cfg,
db: db,
}, nil
}

Expand All @@ -52,7 +50,7 @@ func (s Source) snapshotTable(ctx context.Context, writer kafkalib.BatchWriter,
logger := slog.With(slog.String("table", tableCfg.Name))
snapshotStartTime := time.Now()

adapter, err := adapter.NewMySQLAdapter(s.db, s.dbName, tableCfg)
adapter, err := adapter.NewMySQLAdapter(s.db, s.cfg.Database, tableCfg)
if err != nil {
return fmt.Errorf("failed to create MySQL adapter: %w", err)
}
Expand Down

0 comments on commit 7ac7dfb

Please sign in to comment.