Skip to content

Commit

Permalink
Apply gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
driv3r committed Oct 19, 2023
1 parent bee17ff commit 6d8005c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
13 changes: 7 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ type ControlServerConfig struct {
ServerBindAddr string

// Path to `web` base dir
WebBasedir string
WebBasedir string

// TODO: refactor control server config out of the base ferry at some point
// This adds optional buttons in the web ui that runs a script located at the
Expand Down Expand Up @@ -319,7 +319,8 @@ func (c *ControlServerConfig) Validate() error {

// SchemaName => TableName => ColumnName => CompressionAlgorithm
// Example: blog1 => articles => body => snappy
// (SELECT body FROM blog1.articles => returns compressed blob)
//
// (SELECT body FROM blog1.articles => returns compressed blob)
type ColumnCompressionConfig map[string]map[string]map[string]string

func (c ColumnCompressionConfig) CompressedColumnsFor(schemaName, tableName string) map[string]string {
Expand Down Expand Up @@ -835,7 +836,7 @@ func (c *Config) ValidateConfig() error {
return fmt.Errorf("control_server: %s", err)
}

if c.DBWriteRetries == 0 {
if c.DBWriteRetries == 0 {
c.DBWriteRetries = 5
}

Expand Down Expand Up @@ -870,7 +871,7 @@ func (c *Config) ValidateConfig() error {
return nil
}

func (c *Config) checkForDeprecatedConfig() {
func (c *Config) checkForDeprecatedConfig() {
if c.DataIterationBatchSize != 0 {
c.logDeprecated("DataIterationBatchSize", "UpdatableConfig.DataIterationBatchSize")
c.UpdatableConfig.DataIterationBatchSize = c.DataIterationBatchSize
Expand All @@ -888,11 +889,11 @@ func (c *Config) checkForDeprecatedConfig() {

if len(c.ControlServerCustomScripts) != 0 {
c.logDeprecated("ControlServerCustomScripts", "ControlServerConfig.CustomScripts")
c.ControlServerConfig.CustomScripts= c.ControlServerCustomScripts
c.ControlServerConfig.CustomScripts = c.ControlServerCustomScripts
}
}

func (c *Config) logDeprecated(deprecatedConfig string, newConfig string) {
func (c *Config) logDeprecated(deprecatedConfig string, newConfig string) {
logrus.Warnf("Config.%s is deprecated in favour of Config.%s", deprecatedConfig, newConfig)
}

Expand Down
5 changes: 2 additions & 3 deletions control_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ControlServerTableStatus struct {
LastSuccessfulPaginationKey uint64
TargetPaginationKey uint64

BatchSize uint64
BatchSize uint64
}

type CustomScriptStatus struct {
Expand Down Expand Up @@ -214,7 +214,7 @@ func (this *ControlServer) HandleStatus(w http.ResponseWriter, r *http.Request)

// Converting time values to seconds manually for json output
status.TimeTaken = status.TimeTaken / time.Second
status.BinlogStreamerLag = status.BinlogStreamerLag / time.Second
status.BinlogStreamerLag = status.BinlogStreamerLag / time.Second
status.ETA = status.ETA / time.Second

w.Header().Set("Content-Type", "application/json")
Expand Down Expand Up @@ -295,7 +295,6 @@ func (this *ControlServer) fetchStatus() *ControlServerStatus {
LastSuccessfulPaginationKey: lastSuccessfulPaginationKey,
TargetPaginationKey: tableProgress.TargetPaginationKey,
BatchSize: tableProgress.BatchSize,

}

tablesGroupByStatus[tableStatus] = append(tablesGroupByStatus[tableStatus], controlStatus)
Expand Down
4 changes: 2 additions & 2 deletions cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type CursorConfig struct {
DB *sql.DB
Throttler Throttler

ColumnsToSelect []string
BuildSelect func([]string, *TableSchema, uint64, uint64) (squirrel.SelectBuilder, error)
ColumnsToSelect []string
BuildSelect func([]string, *TableSchema, uint64, uint64) (squirrel.SelectBuilder, error)
// BatchSize is a pointer to the BatchSize in Config.UpdatableConfig which can be independently updated from this code.
// Having it as a pointer allows the updated value to be read without needing additional code to copy the batch size value into the cursor config for each cursor we create.
BatchSize *uint64
Expand Down
24 changes: 12 additions & 12 deletions dml_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ type RowData []interface{}
// https://github.com/Shopify/ghostferry/issues/165.
//
// In summary:
// - This code receives values from both go-sql-driver/mysql and
// go-mysql-org/go-mysql.
// - go-sql-driver/mysql gives us int64 for signed integer, and uint64 in a byte
// slice for unsigned integer.
// - go-mysql-org/go-mysql gives us int64 for signed integer, and uint64 for
// unsigned integer.
// - We currently make this function deal with both cases. In the future we can
// investigate alternative solutions.
// - This code receives values from both go-sql-driver/mysql and
// go-mysql-org/go-mysql.
// - go-sql-driver/mysql gives us int64 for signed integer, and uint64 in a byte
// slice for unsigned integer.
// - go-mysql-org/go-mysql gives us int64 for signed integer, and uint64 for
// unsigned integer.
// - We currently make this function deal with both cases. In the future we can
// investigate alternative solutions.
func (r RowData) GetUint64(colIdx int) (uint64, error) {
u64, ok := Uint64Value(r[colIdx])
if ok {
Expand Down Expand Up @@ -501,10 +501,10 @@ func Int64Value(value interface{}) (int64, bool) {
//
// This is specifically mentioned in the the below link:
//
// When BINARY values are stored, they are right-padded with the pad value
// to the specified length. The pad value is 0x00 (the zero byte). Values
// are right-padded with 0x00 for inserts, and no trailing bytes are removed
// for retrievals.
// When BINARY values are stored, they are right-padded with the pad value
// to the specified length. The pad value is 0x00 (the zero byte). Values
// are right-padded with 0x00 for inserts, and no trailing bytes are removed
// for retrievals.
//
// ref: https://dev.mysql.com/doc/refman/5.7/en/binary-varbinary.html
func appendEscapedString(buffer []byte, value string, rightPadToLengthWithZeroBytes int) []byte {
Expand Down

0 comments on commit 6d8005c

Please sign in to comment.