Skip to content

Commit 2befea7

Browse files
vttestserver and binlog player flags
Signed-off-by: Rohit Nayak <[email protected]>
1 parent 47586ad commit 2befea7

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

go/cmd/vttestserver/cli/main.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,21 @@ func New() (cmd *cobra.Command) {
128128
" If the directory contains a vschema.json file, it"+
129129
" will be used as the vschema for the V3 API.")
130130

131-
cmd.Flags().StringVar(&config.DefaultSchemaDir, "default_schema_dir", "",
131+
utils.SetFlagStringVar(cmd.Flags(), &config.DefaultSchemaDir, "default-schema-dir", "",
132132
"Default directory for initial schema files. If no schema is found"+
133133
" in schema-dir, default to this location.")
134134

135-
cmd.Flags().StringVar(&config.DataDir, "data_dir", "",
135+
utils.SetFlagStringVar(cmd.Flags(), &config.DataDir, "data-dir", "",
136136
"Directory where the data files will be placed, defaults to a random "+
137137
"directory under /vt/vtdataroot")
138138

139-
cmd.Flags().BoolVar(&config.OnlyMySQL, "mysql_only", false,
139+
utils.SetFlagBoolVar(cmd.Flags(), &config.OnlyMySQL, "mysql-only", false,
140140
"If this flag is set only mysql is initialized."+
141141
" The rest of the vitess components are not started."+
142142
" Also, the output specifies the mysql unix socket"+
143143
" instead of the vtgate port.")
144144

145-
cmd.Flags().BoolVar(&config.PersistentMode, "persistent_mode", false,
145+
utils.SetFlagBoolVar(cmd.Flags(), &config.PersistentMode, "persistent-mode", false,
146146
"If this flag is set, the MySQL data directory is not cleaned up"+
147147
" when LocalCluster.TearDown() is called. This is useful for running"+
148148
" vttestserver as a database container in local developer environments. Note"+
@@ -157,56 +157,56 @@ func New() (cmd *cobra.Command) {
157157
" with random data. See also the 'rng_seed' and 'min_shard_size'"+
158158
" and 'max_shard_size' flags.")
159159

160-
cmd.Flags().IntVar(&seed.RngSeed, "rng_seed", 123,
160+
utils.SetFlagIntVar(cmd.Flags(), &seed.RngSeed, "rng-seed", 123,
161161
"The random number generator seed to use when initializing"+
162162
" with random data (see also --initialize-with-random-data)."+
163163
" Multiple runs with the same seed will result with the same"+
164164
" initial data.")
165165

166-
cmd.Flags().IntVar(&seed.MinSize, "min_table_shard_size", 1000,
166+
utils.SetFlagIntVar(cmd.Flags(), &seed.MinSize, "min-table-shard-size", 1000,
167167
"The minimum number of initial rows in a table shard. Ignored if"+
168168
"--initialize-with-random-data is false. The actual number is chosen"+
169169
" randomly.")
170170

171-
cmd.Flags().IntVar(&seed.MaxSize, "max_table_shard_size", 10000,
171+
utils.SetFlagIntVar(cmd.Flags(), &seed.MaxSize, "max-table-shard-size", 10000,
172172
"The maximum number of initial rows in a table shard. Ignored if"+
173173
"--initialize-with-random-data is false. The actual number is chosen"+
174174
" randomly")
175175

176-
cmd.Flags().Float64Var(&seed.NullProbability, "null_probability", 0.1,
176+
utils.SetFlagFloat64Var(cmd.Flags(), &seed.NullProbability, "null-probability", 0.1,
177177
"The probability to initialize a field with 'NULL' "+
178178
" if --initialize-with-random-data is true. Only applies to fields"+
179179
" that can contain NULL values.")
180180

181-
cmd.Flags().StringVar(&config.MySQLBindHost, "mysql_bind_host", "localhost",
181+
utils.SetFlagStringVar(cmd.Flags(), &config.MySQLBindHost, "mysql-bind-host", "localhost",
182182
"which host to bind vtgate mysql listener to")
183183

184184
cmd.Flags().StringVar(&config.VtComboBindAddress, "vtcombo-bind-host", "localhost",
185185
"which host to bind vtcombo servenv listener to")
186186

187-
cmd.Flags().StringVar(&mycnf, "extra_my_cnf", "",
187+
utils.SetFlagStringVar(cmd.Flags(), &mycnf, "extra-my-cnf", "",
188188
"extra files to add to the config, separated by ':'")
189189

190190
cmd.Flags().StringSliceVar(&topo.cells, "cells", []string{"test"}, "Comma separated list of cells")
191191
cmd.Flags().StringSliceVar(&topo.keyspaces, "keyspaces", []string{"test_keyspace"},
192192
"Comma separated list of keyspaces")
193-
cmd.Flags().StringSliceVar(&topo.shards, "num_shards", []string{"2"},
193+
utils.SetFlagStringSliceVar(cmd.Flags(), &topo.shards, "num-shards", []string{"2"},
194194
"Comma separated shard count (one per keyspace)")
195-
cmd.Flags().IntVar(&topo.replicas, "replica_count", 2,
195+
utils.SetFlagIntVar(cmd.Flags(), &topo.replicas, "replica-count", 2,
196196
"Replica tablets per shard (includes primary)")
197-
cmd.Flags().IntVar(&topo.rdonly, "rdonly_count", 1,
197+
utils.SetFlagIntVar(cmd.Flags(), &topo.rdonly, "rdonly-count", 1,
198198
"Rdonly tablets per shard")
199199

200200
cmd.Flags().StringVar(&config.Charset, "charset", "utf8mb4", "MySQL charset")
201201

202202
cmd.Flags().StringVar(&config.PlannerVersion, "planner-version", "", "Sets the default planner to use when the session has not changed it. Valid values are: Gen4, Gen4Greedy, Gen4Left2Right")
203203

204-
cmd.Flags().StringVar(&config.SnapshotFile, "snapshot_file", "",
204+
utils.SetFlagStringVar(cmd.Flags(), &config.SnapshotFile, "snapshot-file", "",
205205
"A MySQL DB snapshot file")
206206

207-
cmd.Flags().BoolVar(&config.EnableSystemSettings, "enable_system_settings", true, "This will enable the system settings to be changed per session at the database connection level")
207+
utils.SetFlagBoolVar(cmd.Flags(), &config.EnableSystemSettings, "enable-system-settings", true, "This will enable the system settings to be changed per session at the database connection level")
208208

209-
cmd.Flags().StringVar(&config.TransactionMode, "transaction_mode", "MULTI", "Transaction mode MULTI (default), SINGLE or TWOPC ")
209+
utils.SetFlagStringVar(cmd.Flags(), &config.TransactionMode, "transaction-mode", "MULTI", "Transaction mode MULTI (default), SINGLE or TWOPC ")
210210
cmd.Flags().DurationVar(&config.TransactionTimeout, "queryserver-config-transaction-timeout", 30*time.Second, "query server transaction timeout, a transaction will be killed if it takes longer than this value")
211211

212212
utils.SetFlagStringVar(cmd.Flags(), &config.TabletHostName, "tablet-hostname", "localhost", "The hostname to use for the tablet otherwise it will be derived from OS' hostname")

go/vt/binlog/grpcbinlogplayer/player.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
binlogservicepb "vitess.io/vitess/go/vt/proto/binlogservice"
3030
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
3131
"vitess.io/vitess/go/vt/servenv"
32+
"vitess.io/vitess/go/vt/utils"
3233
)
3334

3435
var cert, key, ca, crl, name string
@@ -39,11 +40,11 @@ func init() {
3940
}
4041

4142
func registerFlags(fs *pflag.FlagSet) {
42-
fs.StringVar(&cert, "binlog_player_grpc_cert", cert, "the cert to use to connect")
43-
fs.StringVar(&key, "binlog_player_grpc_key", key, "the key to use to connect")
44-
fs.StringVar(&ca, "binlog_player_grpc_ca", ca, "the server ca to use to validate servers when connecting")
45-
fs.StringVar(&crl, "binlog_player_grpc_crl", crl, "the server crl to use to validate server certificates when connecting")
46-
fs.StringVar(&name, "binlog_player_grpc_server_name", name, "the server name to use to validate server certificate")
43+
utils.SetFlagStringVar(fs, &cert, "binlog-player-grpc-cert", cert, "the cert to use to connect")
44+
utils.SetFlagStringVar(fs, &key, "binlog-player-grpc-key", key, "the key to use to connect")
45+
utils.SetFlagStringVar(fs, &ca, "binlog-player-grpc-ca", ca, "the server ca to use to validate servers when connecting")
46+
utils.SetFlagStringVar(fs, &crl, "binlog-player-grpc-crl", crl, "the server crl to use to validate server certificates when connecting")
47+
utils.SetFlagStringVar(fs, &name, "binlog-player-grpc-server-name", name, "the server name to use to validate server certificate")
4748
}
4849

4950
// client implements a Client over go rpc

0 commit comments

Comments
 (0)