1
0
Fork 0

Rename slave package to driver

The package contains driver code that was supplemented with additional slave commands.
This commit is contained in:
Gregory Eremin 2019-10-28 19:32:35 +01:00
parent 05009b19d7
commit 610336a34e
37 changed files with 12 additions and 12 deletions

View File

@ -12,7 +12,7 @@ import (
"time" "time"
"github.com/juju/errors" "github.com/juju/errors"
"github.com/localhots/bocadillo/mysql/slave" "github.com/localhots/bocadillo/mysql/driver"
"github.com/localhots/bocadillo/reader" "github.com/localhots/bocadillo/reader"
) )
@ -27,7 +27,7 @@ func main() {
validate((*id != 0), "Server ID is not set") validate((*id != 0), "Server ID is not set")
validate((*file != ""), "Binary log file is not set") validate((*file != ""), "Binary log file is not set")
reader, err := reader.New(*dsn, slave.Config{ reader, err := reader.New(*dsn, driver.Config{
ServerID: uint32(*id), ServerID: uint32(*id),
File: *file, File: *file,
Offset: uint32(*offset), Offset: uint32(*offset),

View File

@ -1,4 +1,4 @@
package slave package driver
import ( import (
"context" "context"
@ -6,7 +6,7 @@ import (
"os" "os"
"github.com/localhots/bocadillo/buffer" "github.com/localhots/bocadillo/buffer"
"github.com/localhots/bocadillo/mysql/slave/internal/mysql" "github.com/localhots/bocadillo/mysql/driver/internal/mysql"
) )
// Conn is a slave connection used to issue a binlog dump command. // Conn is a slave connection used to issue a binlog dump command.

View File

@ -9,7 +9,7 @@ import (
"github.com/juju/errors" "github.com/juju/errors"
"github.com/localhots/bocadillo/binlog" "github.com/localhots/bocadillo/binlog"
"github.com/localhots/bocadillo/mysql" "github.com/localhots/bocadillo/mysql"
"github.com/localhots/bocadillo/mysql/slave" "github.com/localhots/bocadillo/mysql/driver"
"github.com/localhots/bocadillo/reader/schema" "github.com/localhots/bocadillo/reader/schema"
) )
@ -29,7 +29,7 @@ type EnhancedRowsEvent struct {
} }
// NewEnhanced creates a new enhanced binary log reader. // NewEnhanced creates a new enhanced binary log reader.
func NewEnhanced(dsn string, sc slave.Config) (*EnhancedReader, error) { func NewEnhanced(dsn string, sc driver.Config) (*EnhancedReader, error) {
r, err := New(dsn, sc) r, err := New(dsn, sc)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -5,12 +5,12 @@ import (
"github.com/juju/errors" "github.com/juju/errors"
"github.com/localhots/bocadillo/binlog" "github.com/localhots/bocadillo/binlog"
"github.com/localhots/bocadillo/mysql/slave" "github.com/localhots/bocadillo/mysql/driver"
) )
// Reader is a binary log reader. // Reader is a binary log reader.
type Reader struct { type Reader struct {
conn *slave.Conn conn *driver.Conn
state binlog.Position state binlog.Position
format binlog.FormatDescription format binlog.FormatDescription
tableMap map[uint64]binlog.TableDescription tableMap map[uint64]binlog.TableDescription
@ -34,8 +34,8 @@ var (
) )
// New creates a new binary log reader. // New creates a new binary log reader.
func New(dsn string, sc slave.Config) (*Reader, error) { func New(dsn string, sc driver.Config) (*Reader, error) {
conn, err := slave.Connect(dsn, sc) conn, err := driver.Connect(dsn, sc)
if err != nil { if err != nil {
return nil, errors.Annotate(err, "establish slave connection") return nil, errors.Annotate(err, "establish slave connection")
} }

View File

@ -10,7 +10,7 @@ import (
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"github.com/localhots/bocadillo/binlog" "github.com/localhots/bocadillo/binlog"
"github.com/localhots/bocadillo/mysql/slave" "github.com/localhots/bocadillo/mysql/driver"
"github.com/localhots/bocadillo/reader" "github.com/localhots/bocadillo/reader"
) )
@ -46,7 +46,7 @@ func TestMain(m *testing.M) {
os.Exit(exitCode) os.Exit(exitCode)
} }
func getConfig() (dsn string, conf slave.Config) { func getConfig() (dsn string, conf driver.Config) {
envOrDefault := func(name, def string) string { envOrDefault := func(name, def string) string {
if val := os.Getenv(name); val != "" { if val := os.Getenv(name); val != "" {
return val return val