vitess.io/vitess@v0.16.2/go/cmd/vtgr/main.go (about) 1 /* 2 Copyright 2021 The Vitess Authors. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 http://www.apache.org/licenses/LICENSE-2.0 7 Unless required by applicable law or agreed to in writing, software 8 distributed under the License is distributed on an "AS IS" BASIS, 9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 See the License for the specific language governing permissions and 11 limitations under the License. 12 */ 13 14 package main 15 16 import ( 17 "context" 18 19 "github.com/spf13/pflag" 20 21 "vitess.io/vitess/go/acl" 22 "vitess.io/vitess/go/vt/servenv" 23 "vitess.io/vitess/go/vt/vtgr" 24 ) 25 26 func main() { 27 var clustersToWatch []string 28 servenv.OnParseFor("vtgr", func(fs *pflag.FlagSet) { 29 fs.StringSliceVar(&clustersToWatch, "clusters_to_watch", nil, `Comma-separated list of keyspaces or keyspace/shards that this instance will monitor and repair. Defaults to all clusters in the topology. Example: "ks1,ks2/-80"`) 30 31 acl.RegisterFlags(fs) 32 }) 33 servenv.ParseFlags("vtgr") 34 35 // openTabletDiscovery will open up a connection to topo server 36 // and populate the tablets in memory 37 vtgr := vtgr.OpenTabletDiscovery(context.Background(), nil, clustersToWatch) 38 vtgr.RefreshCluster() 39 vtgr.ScanAndRepair() 40 41 // block here so that we don't exit directly 42 select {} 43 }