vitess.io/vitess@v0.16.2/go/cmd/vtgateclienttest/main.go (about)

     1  /*
     2  Copyright 2019 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Package main is the implementation of vtgateclienttest.
    18  // This program has a chain of vtgateservice.VTGateService implementations,
    19  // each one being responsible for one test scenario.
    20  package main
    21  
    22  import (
    23  	"github.com/spf13/pflag"
    24  
    25  	"vitess.io/vitess/go/acl"
    26  	"vitess.io/vitess/go/cmd/vtgateclienttest/services"
    27  	"vitess.io/vitess/go/exit"
    28  	"vitess.io/vitess/go/vt/servenv"
    29  	"vitess.io/vitess/go/vt/vtgate"
    30  )
    31  
    32  func init() {
    33  	servenv.RegisterDefaultFlags()
    34  	servenv.RegisterFlags()
    35  	servenv.RegisterGRPCServerFlags()
    36  	servenv.RegisterGRPCServerAuthFlags()
    37  	servenv.RegisterServiceMapFlag()
    38  
    39  	servenv.OnParse(func(fs *pflag.FlagSet) {
    40  		acl.RegisterFlags(fs)
    41  	})
    42  }
    43  
    44  func main() {
    45  	defer exit.Recover()
    46  
    47  	servenv.ParseFlags("vtgateclienttest")
    48  	servenv.Init()
    49  
    50  	// The implementation chain.
    51  	servenv.OnRun(func() {
    52  		s := services.CreateServices()
    53  		for _, f := range vtgate.RegisterVTGates {
    54  			f(s)
    55  		}
    56  	})
    57  
    58  	servenv.RunDefault()
    59  }