Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimov committed Oct 26, 2023
1 parent 5753c3d commit be0bb24
Show file tree
Hide file tree
Showing 161 changed files with 992 additions and 988 deletions.
4 changes: 2 additions & 2 deletions examples/local/vstream_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
)

/*
This is a sample client for streaming using the vstream API. It is setup to work with the local example and you can
either stream from the unsharded commerce keyspace or the customer keyspace after the sharding step.
This is a sample client for streaming using the vstream API. It is setup to work with the local example and you can
either stream from the unsharded commerce keyspace or the customer keyspace after the sharding step.
*/
func main() {
ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions go/acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ limitations under the License.
//
// For convenience, there are two other built-in policies that also do NOT do
// any authentication, but allow you to globally disable some roles entirely:
// * `deny-all` disallows all roles for everyone. Note that access is still
// - `deny-all` disallows all roles for everyone. Note that access is still
// allowed to endpoints that are considered "public" (no ACL check at all).
// * `read-only` allows anyone to act as DEBUGGING or MONITORING, but no one
// - `read-only` allows anyone to act as DEBUGGING or MONITORING, but no one
// is allowed to act as ADMIN. It also disallows any other custom roles that
// are requested.
package acl
Expand Down
3 changes: 2 additions & 1 deletion go/cache/ristretto/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const (
// policy is the interface encapsulating eviction/admission behavior.
//
// TODO: remove this interface and just rename defaultPolicy to policy, as we
// are probably only going to use/implement/maintain one policy.
//
// are probably only going to use/implement/maintain one policy.
type policy interface {
ringConsumer
// Add attempts to Add the key-cost pair to the Policy. It returns a slice
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/vtbackup/plugin_cephbackupstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/vtbackup/plugin_filebackupstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/vtbackup/plugin_gcsbackupstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/vtbackup/plugin_s3backupstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
36 changes: 18 additions & 18 deletions go/cmd/vtbackup/vtbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ When run periodically for each shard, vtbackup can ensure these configurable pol
* Old backups for the shard are removed.
Whatever system launches vtbackup is responsible for the following:
* Running vtbackup with similar flags that would be used for a vttablet and
mysqlctld in the target shard to be backed up.
* Provisioning as much disk space for vtbackup as would be given to vttablet.
The data directory MUST be empty at startup. Do NOT reuse a persistent disk.
* Running vtbackup periodically for each shard, for each backup storage location.
* Ensuring that at most one instance runs at a time for a given pair of shard
and backup storage location.
* Retrying vtbackup if it fails.
* Alerting human operators if the failure is persistent.
- Running vtbackup with similar flags that would be used for a vttablet and
mysqlctld in the target shard to be backed up.
- Provisioning as much disk space for vtbackup as would be given to vttablet.
The data directory MUST be empty at startup. Do NOT reuse a persistent disk.
- Running vtbackup periodically for each shard, for each backup storage location.
- Ensuring that at most one instance runs at a time for a given pair of shard
and backup storage location.
- Retrying vtbackup if it fails.
- Alerting human operators if the failure is persistent.
The process vtbackup follows to take a new backup is as follows:
1. Restore from the most recent backup.
2. Start a mysqld instance (but no vttablet) from the restored data.
3. Instruct mysqld to connect to the current shard primary and replicate any
transactions that are new since the last backup.
4. Ask the primary for its current replication position and set that as the goal
for catching up on replication before taking the backup, so the goalposts
don't move.
5. Wait until replication is caught up to the goal position or beyond.
6. Stop mysqld and take a new backup.
1. Restore from the most recent backup.
2. Start a mysqld instance (but no vttablet) from the restored data.
3. Instruct mysqld to connect to the current shard primary and replicate any
transactions that are new since the last backup.
4. Ask the primary for its current replication position and set that as the goal
for catching up on replication before taking the backup, so the goalposts
don't move.
5. Wait until replication is caught up to the goal position or beyond.
6. Stop mysqld and take a new backup.
Aside from additional replication load while vtbackup's mysqld catches up on
new transactions, the shard should be otherwise unaffected. Existing tablets
Expand Down
1 change: 1 addition & 0 deletions go/cmd/vtctldclient/command/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ exception here, not the rule). Commands should also prevent individual flag
names from polluting the package namespace.
A good pattern we have found is to do the following:
package command
// (imports ...)
Expand Down
4 changes: 2 additions & 2 deletions go/flagutil/sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var (
//
// For example, defining the following:
//
// var x flagutil.StringSetFlag
// flag.Var(&x, "foo", "")
// var x flagutil.StringSetFlag
// flag.Var(&x, "foo", "")
//
// And then specifying "-foo x -foo y -foo x", will result in a set of {x, y}.
//
Expand Down
1 change: 1 addition & 0 deletions go/internal/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func warnOnMixedPositionalAndFlagArguments(posargs []string, warningf func(msg s
}

// From the standard library documentation:
//
// > If a Value has an IsBoolFlag() bool method returning true, the
// > command-line parser makes -name equivalent to -name=true rather than
// > using the next command-line argument.
Expand Down
2 changes: 1 addition & 1 deletion go/internal/flag/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
87 changes: 46 additions & 41 deletions go/mysql/binlog_event_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,24 @@ import (
// into flavor-specific event types to pull in common parsing code.
//
// The default v4 header format is:
// offset : size
// +============================+
// | timestamp 0 : 4 |
// +----------------------------+
// | type_code 4 : 1 |
// +----------------------------+
// | server_id 5 : 4 |
// +----------------------------+
// | event_length 9 : 4 |
// +----------------------------+
// | next_position 13 : 4 |
// +----------------------------+
// | flags 17 : 2 |
// +----------------------------+
// | extra_headers 19 : x-19 |
// +============================+
// http://dev.mysql.com/doc/internals/en/event-header-fields.html
//
// offset : size
// +============================+
// | timestamp 0 : 4 |
// +----------------------------+
// | type_code 4 : 1 |
// +----------------------------+
// | server_id 5 : 4 |
// +----------------------------+
// | event_length 9 : 4 |
// +----------------------------+
// | next_position 13 : 4 |
// +----------------------------+
// | flags 17 : 2 |
// +----------------------------+
// | extra_headers 19 : x-19 |
// +============================+
// http://dev.mysql.com/doc/internals/en/event-header-fields.html
type binlogEvent []byte

// dataBytes returns the event bytes without header prefix and without checksum suffix
Expand Down Expand Up @@ -192,15 +193,16 @@ func (ev binlogEvent) IsCompressed() bool {
// Format implements BinlogEvent.Format().
//
// Expected format (L = total length of event data):
// # bytes field
// 2 format version
// 50 server version string, 0-padded but not necessarily 0-terminated
// 4 timestamp (same as timestamp header field)
// 1 header length
// p (one byte per packet type) event type header lengths
// Rest was inferred from reading source code:
// 1 checksum algorithm
// 4 checksum
//
// # bytes field
// 2 format version
// 50 server version string, 0-padded but not necessarily 0-terminated
// 4 timestamp (same as timestamp header field)
// 1 header length
// p (one byte per packet type) event type header lengths
// Rest was inferred from reading source code:
// 1 checksum algorithm
// 4 checksum
func (ev binlogEvent) Format() (f BinlogFormat, err error) {
// FORMAT_DESCRIPTION_EVENT has a fixed header size of 19
// because we have to read it before we know the header_length.
Expand Down Expand Up @@ -229,15 +231,16 @@ func (ev binlogEvent) Format() (f BinlogFormat, err error) {
// Query implements BinlogEvent.Query().
//
// Expected format (L = total length of event data):
// # bytes field
// 4 thread_id
// 4 execution time
// 1 length of db_name, not including NULL terminator (X)
// 2 error code
// 2 length of status vars block (Y)
// Y status vars block
// X+1 db_name + NULL terminator
// L-X-1-Y SQL statement (no NULL terminator)
//
// # bytes field
// 4 thread_id
// 4 execution time
// 1 length of db_name, not including NULL terminator (X)
// 2 error code
// 2 length of status vars block (Y)
// Y status vars block
// X+1 db_name + NULL terminator
// L-X-1-Y SQL statement (no NULL terminator)
func (ev binlogEvent) Query(f BinlogFormat) (query Query, err error) {
const varsPos = 4 + 4 + 1 + 2 + 2

Expand Down Expand Up @@ -310,9 +313,10 @@ varsLoop:
// IntVar implements BinlogEvent.IntVar().
//
// Expected format (L = total length of event data):
// # bytes field
// 1 variable ID
// 8 variable value
//
// # bytes field
// 1 variable ID
// 8 variable value
func (ev binlogEvent) IntVar(f BinlogFormat) (byte, uint64, error) {
data := ev.Bytes()[f.HeaderLength:]

Expand All @@ -328,9 +332,10 @@ func (ev binlogEvent) IntVar(f BinlogFormat) (byte, uint64, error) {
// Rand implements BinlogEvent.Rand().
//
// Expected format (L = total length of event data):
// # bytes field
// 8 seed 1
// 8 seed 2
//
// # bytes field
// 8 seed 1
// 8 seed 2
func (ev binlogEvent) Rand(f BinlogFormat) (seed1 uint64, seed2 uint64, err error) {
data := ev.Bytes()[f.HeaderLength:]
seed1 = binary.LittleEndian.Uint64(data[0:8])
Expand Down
7 changes: 4 additions & 3 deletions go/mysql/binlog_event_filepos.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ func (ev *filePosBinlogEvent) nextPosition(f BinlogFormat) int {
// rotate implements BinlogEvent.Rotate().
//
// Expected format (L = total length of event data):
// # bytes field
// 8 position
// 8:L file
//
// # bytes field
// 8 position
// 8:L file
func (ev *filePosBinlogEvent) rotate(f BinlogFormat) (int, string) {
data := ev.Bytes()[f.HeaderLength:]
pos := binary.LittleEndian.Uint64(data[0:8])
Expand Down
4 changes: 2 additions & 2 deletions go/mysql/binlog_event_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ https://github.com/noplay/python-mysql-replication/blob/175df28cc8b536a68522ff9b
*/

//region debug-only
//TODO remove once the json refactor is tested live
// region debug-only
// TODO remove once the json refactor is tested live
var jsonDebug = false

func jlog(tpl string, vals ...any) {
Expand Down
9 changes: 5 additions & 4 deletions go/mysql/binlog_event_mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ func (ev mariadbBinlogEvent) IsGTID() bool {
// GTID implements BinlogEvent.GTID().
//
// Expected format:
// # bytes field
// 8 sequence number
// 4 domain ID
// 1 flags2
//
// # bytes field
// 8 sequence number
// 4 domain ID
// 1 flags2
func (ev mariadbBinlogEvent) GTID(f BinlogFormat) (GTID, bool, error) {
const FLStandalone = 1

Expand Down
9 changes: 5 additions & 4 deletions go/mysql/binlog_event_mysql56.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ func (ev mysql56BinlogEvent) IsGTID() bool {
// GTID implements BinlogEvent.GTID().
//
// Expected format:
// # bytes field
// 1 flags
// 16 SID (server UUID)
// 8 GNO (sequence number, signed int)
//
// # bytes field
// 1 flags
// 16 SID (server UUID)
// 8 GNO (sequence number, signed int)
func (ev mysql56BinlogEvent) GTID(f BinlogFormat) (GTID, bool, error) {
data := ev.Bytes()[f.HeaderLength:]
var sid SID
Expand Down
43 changes: 23 additions & 20 deletions go/mysql/binlog_event_rbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ var ZeroTimestamp = []byte("0000-00-00 00:00:00")
// TableMap implements BinlogEvent.TableMap().
//
// Expected format (L = total length of event data):
// # bytes field
// 4/6 table id
// 2 flags
// 1 schema name length sl
// sl schema name
// 1 [00]
// 1 table name length tl
// tl table name
// 1 [00]
// <var> column count cc (var-len encoded)
// cc column-def, one byte per column
// <var> column-meta-def (var-len encoded string)
// n NULL-bitmask, length: (cc + 7) / 8
//
// # bytes field
// 4/6 table id
// 2 flags
// 1 schema name length sl
// sl schema name
// 1 [00]
// 1 table name length tl
// tl table name
// 1 [00]
// <var> column count cc (var-len encoded)
// cc column-def, one byte per column
// <var> column-meta-def (var-len encoded string)
// n NULL-bitmask, length: (cc + 7) / 8
func (ev binlogEvent) TableMap(f BinlogFormat) (*TableMap, error) {
data := ev.Bytes()[f.HeaderLength:]

Expand Down Expand Up @@ -955,13 +956,15 @@ func CellValue(data []byte, pos int, typ byte, metadata uint16, field *querypb.F
// Rows implements BinlogEvent.TableMap().
//
// Expected format (L = total length of event data):
// # bytes field
// 4/6 table id
// 2 flags
// -- if version == 2
// 2 extra data length edl
// edl extra data
// -- endif
//
// # bytes field
// 4/6 table id
// 2 flags
// -- if version == 2
// 2 extra data length edl
// edl extra data
// -- endif
//
// <var> number of columns (var-len encoded)
// <var> identify bitmap
// <var> data bitmap
Expand Down
Loading

0 comments on commit be0bb24

Please sign in to comment.