From faf691048ef6a31e332384425f418754628de0ea Mon Sep 17 00:00:00 2001 From: Alain Jobart Date: Tue, 9 Jan 2018 10:38:44 -0800 Subject: [PATCH 1/7] A few small vtgate fixes / cleanups. * Remove unused 'method string' from Executor.execute(). * Remove srv_topo_timeout flag from resilient_srv_topo_server. We can just used the provided context, no need to slap on a random timeout. * Update MessageStream comment, we do support multiple shards. * In vtgate SplitQuery, use closures directly, inside of wrapping them in a method. --- go/vt/vtgate/executor.go | 4 +- go/vt/vtgate/resilient_srv_topo_server.go | 15 ++--- go/vt/vtgate/resolver.go | 4 +- go/vt/vtgate/vtgate.go | 76 ++++++++--------------- 4 files changed, 38 insertions(+), 61 deletions(-) diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index 0e399db1e10..b0d551d4798 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -111,7 +111,7 @@ func NewExecutor(ctx context.Context, serv topo.SrvTopoServer, cell, statsName s // Execute executes a non-streaming query. func (e *Executor) Execute(ctx context.Context, method string, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable) (result *sqltypes.Result, err error) { logStats := NewLogStats(ctx, method, sql, bindVars) - result, err = e.execute(ctx, method, session, sql, bindVars, logStats) + result, err = e.execute(ctx, session, sql, bindVars, logStats) logStats.Error = err // The mysql plugin runs an implicit rollback whenever a connection closes. @@ -123,7 +123,7 @@ func (e *Executor) Execute(ctx context.Context, method string, session *vtgatepb return result, err } -func (e *Executor) execute(ctx context.Context, method string, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable, logStats *LogStats) (*sqltypes.Result, error) { +func (e *Executor) execute(ctx context.Context, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable, logStats *LogStats) (*sqltypes.Result, error) { // Start an implicit transaction if necessary. // TODO(sougou): deprecate legacyMode after all users are migrated out. if !e.legacyAutocommit && !session.Autocommit && !session.InTransaction { diff --git a/go/vt/vtgate/resilient_srv_topo_server.go b/go/vt/vtgate/resilient_srv_topo_server.go index fbf4daa6574..941ee50273b 100644 --- a/go/vt/vtgate/resilient_srv_topo_server.go +++ b/go/vt/vtgate/resilient_srv_topo_server.go @@ -35,7 +35,6 @@ import ( var ( srvTopoCacheTTL = flag.Duration("srv_topo_cache_ttl", 1*time.Second, "how long to use cached entries for topology") - srvTopoTimeout = flag.Duration("srv_topo_timeout", 2*time.Second, "topo server timeout") ) const ( @@ -189,18 +188,16 @@ func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(ctx context.Context, c return entry.value, entry.lastError } - // not in cache or too old, get the real value - newCtx, cancel := context.WithTimeout(context.Background(), *srvTopoTimeout) - defer cancel() - - result, err := server.topoServer.GetSrvKeyspaceNames(newCtx, cell) + // Not in cache or too old, get the real value. We use the context that issued + // the query here. + result, err := server.topoServer.GetSrvKeyspaceNames(ctx, cell) if err != nil { if entry.insertionTime.IsZero() { server.counts.Add(errorCategory, 1) - log.Errorf("GetSrvKeyspaceNames(%v, %v) failed: %v (no cached value, caching and returning error)", newCtx, cell, err) + log.Errorf("GetSrvKeyspaceNames(%v, %v) failed: %v (no cached value, caching and returning error)", ctx, cell, err) } else { server.counts.Add(cachedCategory, 1) - log.Warningf("GetSrvKeyspaceNames(%v, %v) failed: %v (returning cached value: %v %v)", newCtx, cell, err, entry.value, entry.lastError) + log.Warningf("GetSrvKeyspaceNames(%v, %v) failed: %v (returning cached value: %v %v)", ctx, cell, err, entry.value, entry.lastError) return entry.value, entry.lastError } } @@ -209,7 +206,7 @@ func (server *ResilientSrvTopoServer) GetSrvKeyspaceNames(ctx context.Context, c entry.insertionTime = time.Now() entry.value = result entry.lastError = err - entry.lastErrorCtx = newCtx + entry.lastErrorCtx = ctx return result, err } diff --git a/go/vt/vtgate/resolver.go b/go/vt/vtgate/resolver.go index 9e3d30efd0b..f5f01879059 100644 --- a/go/vt/vtgate/resolver.go +++ b/go/vt/vtgate/resolver.go @@ -370,7 +370,9 @@ func (res *Resolver) MessageStream(ctx context.Context, keyspace string, shard s keyspace, _, _, err = getKeyspaceShards(ctx, res.toposerv, res.cell, keyspace, topodatapb.TabletType_MASTER) shards = []string{shard} } else { - // If we pass in a KeyRange, resolve it to one shard only for now. + // If we pass in a KeyRange, resolve it to the proper shards. + // Note we support multiple shards here, we will just aggregate + // the message streams. keyspace, shards, err = mapExactShards(ctx, res.toposerv, res.cell, keyspace, topodatapb.TabletType_MASTER, keyRange) } if err != nil { diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index 094204d5772..de9b8f10e3b 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -833,10 +833,35 @@ func (vtg *VTGate) SplitQuery( for _, shardRef := range shardRefs { shardRefByName[shardRef.Name] = shardRef } - querySplitToQueryPartFunc = getQuerySplitToKeyRangePartFunc(keyspace, shardRefByName) + querySplitToQueryPartFunc = func(querySplit *querypb.QuerySplit, shard string) (*vtgatepb.SplitQueryResponse_Part, error) { + // TODO(erez): Assert that shardRefByName contains an entry for 'shard'. + // Keyrange can be nil for the shard (e.g. for single-sharded keyspaces during resharding). + // In this case we append an empty keyrange that represents the entire keyspace. + keyranges := []*topodatapb.KeyRange{{Start: []byte{}, End: []byte{}}} + if shardRefByName[shard].KeyRange != nil { + keyranges = []*topodatapb.KeyRange{shardRefByName[shard].KeyRange} + } + return &vtgatepb.SplitQueryResponse_Part{ + Query: querySplit.Query, + KeyRangePart: &vtgatepb.SplitQueryResponse_KeyRangePart{ + Keyspace: keyspace, + KeyRanges: keyranges, + }, + Size: querySplit.RowCount, + }, nil + } } else { // Keyspace is either unsharded or custom-sharded. - querySplitToQueryPartFunc = getQuerySplitToShardPartFunc(keyspace) + querySplitToQueryPartFunc = func(querySplit *querypb.QuerySplit, shard string) (*vtgatepb.SplitQueryResponse_Part, error) { + return &vtgatepb.SplitQueryResponse_Part{ + Query: querySplit.Query, + ShardPart: &vtgatepb.SplitQueryResponse_ShardPart{ + Keyspace: keyspace, + Shards: []string{shard}, + }, + Size: querySplit.RowCount, + }, nil + } } // Collect all shard names into a slice. @@ -857,53 +882,6 @@ func (vtg *VTGate) SplitQuery( keyspace) } -// getQuerySplitToKeyRangePartFunc returns a function to use with scatterConn.SplitQuery -// that converts the given QuerySplit to a SplitQueryResponse_Part message whose KeyRangePart field -// is set. -func getQuerySplitToKeyRangePartFunc( - keyspace string, - shardReferenceByName map[string]*topodatapb.ShardReference) func( - querySplit *querypb.QuerySplit, shard string) (*vtgatepb.SplitQueryResponse_Part, error) { - - return func( - querySplit *querypb.QuerySplit, shard string) (*vtgatepb.SplitQueryResponse_Part, error) { - // TODO(erez): Assert that shardReferenceByName contains an entry for 'shard'. - // Keyrange can be nil for the shard (e.g. for single-sharded keyspaces during resharding). - // In this case we append an empty keyrange that represents the entire keyspace. - keyranges := []*topodatapb.KeyRange{{Start: []byte{}, End: []byte{}}} - if shardReferenceByName[shard].KeyRange != nil { - keyranges = []*topodatapb.KeyRange{shardReferenceByName[shard].KeyRange} - } - return &vtgatepb.SplitQueryResponse_Part{ - Query: querySplit.Query, - KeyRangePart: &vtgatepb.SplitQueryResponse_KeyRangePart{ - Keyspace: keyspace, - KeyRanges: keyranges, - }, - Size: querySplit.RowCount, - }, nil - } -} - -// getQuerySplitToShardPartFunc returns a function to use with scatterConn.SplitQuery -// that converts the given QuerySplit to a SplitQueryResponse_Part message whose ShardPart field -// is set. -func getQuerySplitToShardPartFunc(keyspace string) func( - querySplit *querypb.QuerySplit, shard string) (*vtgatepb.SplitQueryResponse_Part, error) { - - return func( - querySplit *querypb.QuerySplit, shard string) (*vtgatepb.SplitQueryResponse_Part, error) { - return &vtgatepb.SplitQueryResponse_Part{ - Query: querySplit.Query, - ShardPart: &vtgatepb.SplitQueryResponse_ShardPart{ - Keyspace: keyspace, - Shards: []string{shard}, - }, - Size: querySplit.RowCount, - }, nil - } -} - // GetSrvKeyspace is part of the vtgate service API. func (vtg *VTGate) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error) { return vtg.resolver.toposerv.GetSrvKeyspace(ctx, vtg.resolver.cell, keyspace) From b13e0cc0fab83a8610ee18bb69b6ac6f3d896577 Mon Sep 17 00:00:00 2001 From: Alain Jobart Date: Tue, 9 Jan 2018 14:59:02 -0800 Subject: [PATCH 2/7] Moving topo.SrvTopoServer into srvtopo.Server. The new package will also eventually contain: * the ResilientSrvTopoServer implementation of that interface. * helper methods to resolve cell/keyspace/shards. --- go/vt/discovery/tablet_stats_cache_wait.go | 6 ++-- go/vt/srvtopo/server.go | 38 ++++++++++++++++++++++ go/vt/topo/server.go | 12 ------- go/vt/vtexplain/vtexplain_topo.go | 8 ++--- go/vt/vtexplain/vtexplain_vtgate.go | 4 +-- go/vt/vtgate/executor.go | 5 +-- go/vt/vtgate/gateway/discoverygateway.go | 5 +-- go/vt/vtgate/gateway/gateway.go | 3 +- go/vt/vtgate/gateway/l2vtgategateway.go | 3 +- go/vt/vtgate/l2vtgate/l2vtgate.go | 3 +- go/vt/vtgate/resilient_srv_topo_server.go | 2 +- go/vt/vtgate/resolver.go | 6 ++-- go/vt/vtgate/resolver_test.go | 4 +-- go/vt/vtgate/sandbox_test.go | 8 ++--- go/vt/vtgate/scatter_conn_test.go | 4 +-- go/vt/vtgate/topo_utils.go | 18 +++++----- go/vt/vtgate/vtgate.go | 3 +- 17 files changed, 82 insertions(+), 50 deletions(-) create mode 100644 go/vt/srvtopo/server.go diff --git a/go/vt/discovery/tablet_stats_cache_wait.go b/go/vt/discovery/tablet_stats_cache_wait.go index 21951da0e4d..8589a89e3be 100644 --- a/go/vt/discovery/tablet_stats_cache_wait.go +++ b/go/vt/discovery/tablet_stats_cache_wait.go @@ -23,7 +23,7 @@ import ( "golang.org/x/net/context" "github.com/youtube/vitess/go/vt/concurrency" - "github.com/youtube/vitess/go/vt/topo" + "github.com/youtube/vitess/go/vt/srvtopo" topodatapb "github.com/youtube/vitess/go/vt/proto/topodata" ) @@ -66,7 +66,7 @@ func (tc *TabletStatsCache) WaitForAnyTablet(ctx context.Context, cell, keyspace // WaitForAllServingTablets waits for at least one healthy serving tablet in // the given cell for all keyspaces / shards before returning. // It will return ctx.Err() if the context is canceled. -func (tc *TabletStatsCache) WaitForAllServingTablets(ctx context.Context, ts topo.SrvTopoServer, cell string, types []topodatapb.TabletType) error { +func (tc *TabletStatsCache) WaitForAllServingTablets(ctx context.Context, ts srvtopo.Server, cell string, types []topodatapb.TabletType) error { keyspaceShards, err := findAllKeyspaceShards(ctx, ts, cell) if err != nil { return err @@ -76,7 +76,7 @@ func (tc *TabletStatsCache) WaitForAllServingTablets(ctx context.Context, ts top } // findAllKeyspaceShards goes through all serving shards in the topology -func findAllKeyspaceShards(ctx context.Context, ts topo.SrvTopoServer, cell string) (map[keyspaceShard]bool, error) { +func findAllKeyspaceShards(ctx context.Context, ts srvtopo.Server, cell string) (map[keyspaceShard]bool, error) { ksNames, err := ts.GetSrvKeyspaceNames(ctx, cell) if err != nil { return nil, err diff --git a/go/vt/srvtopo/server.go b/go/vt/srvtopo/server.go new file mode 100644 index 00000000000..601002ccded --- /dev/null +++ b/go/vt/srvtopo/server.go @@ -0,0 +1,38 @@ +/* +Copyright 2017 Google Inc. + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Package srvtopo contains a set of helper methods and classes to +use the topology service in a serving environment. +*/ +package srvtopo + +import ( + "golang.org/x/net/context" + + "github.com/youtube/vitess/go/vt/topo" + + topodatapb "github.com/youtube/vitess/go/vt/proto/topodata" +) + +// Server is a subset of the topo.Server API that only contains +// the serving graph read-only calls used by clients to resolve +// serving addresses, and to get VSchema. +type Server interface { + GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error) + GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) + WatchSrvVSchema(ctx context.Context, cell string) (*topo.WatchSrvVSchemaData, <-chan *topo.WatchSrvVSchemaData, topo.CancelFunc) +} diff --git a/go/vt/topo/server.go b/go/vt/topo/server.go index 60fa84f8442..c14b5e335aa 100644 --- a/go/vt/topo/server.go +++ b/go/vt/topo/server.go @@ -50,8 +50,6 @@ import ( log "github.com/golang/glog" "golang.org/x/net/context" - - topodatapb "github.com/youtube/vitess/go/vt/proto/topodata" ) const ( @@ -169,16 +167,6 @@ type Server struct { cells map[string]Conn } -// SrvTopoServer is a subset of the topo.Server API that only contains -// the serving graph read-only calls used by clients to resolve -// serving addresses, and how to get VSchema. It is mostly used by our -// discovery modules, and by vtgate. -type SrvTopoServer interface { - GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error) - GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) - WatchSrvVSchema(ctx context.Context, cell string) (*WatchSrvVSchemaData, <-chan *WatchSrvVSchemaData, CancelFunc) -} - type cellsToRegionsMap struct { mu sync.Mutex // cellsToRegions contains all cell->region mappings diff --git a/go/vt/vtexplain/vtexplain_topo.go b/go/vt/vtexplain/vtexplain_topo.go index fb94a2ec7d2..47893b99abd 100644 --- a/go/vt/vtexplain/vtexplain_topo.go +++ b/go/vt/vtexplain/vtexplain_topo.go @@ -29,7 +29,7 @@ import ( vschemapb "github.com/youtube/vitess/go/vt/proto/vschema" ) -// ExplainTopo satisfies the SrvTopoServer interface. +// ExplainTopo satisfies the srvtopo.Server interface. // Modeled after the vtgate test sandboxTopo type ExplainTopo struct { // Map of keyspace name to vschema @@ -54,7 +54,7 @@ func (et *ExplainTopo) getSrvVSchema() *vschemapb.SrvVSchema { } } -// GetSrvKeyspaceNames is part of SrvTopoServer. +// GetSrvKeyspaceNames is part of the srvtopo.Server interface. func (et *ExplainTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error) { et.Lock.Lock() defer et.Lock.Unlock() @@ -66,7 +66,7 @@ func (et *ExplainTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([] return keyspaces, nil } -// GetSrvKeyspace is part of SrvTopoServer. +// GetSrvKeyspace is part of the srvtopo.Server interface. func (et *ExplainTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) { et.Lock.Lock() defer et.Lock.Unlock() @@ -143,7 +143,7 @@ func (et *ExplainTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string return srvKeyspace, nil } -// WatchSrvVSchema is part of SrvTopoServer. +// WatchSrvVSchema is part of the srvtopo.Server interface. func (et *ExplainTopo) WatchSrvVSchema(ctx context.Context, cell string) (*topo.WatchSrvVSchemaData, <-chan *topo.WatchSrvVSchemaData, topo.CancelFunc) { return &topo.WatchSrvVSchemaData{ Value: et.getSrvVSchema(), diff --git a/go/vt/vtexplain/vtexplain_vtgate.go b/go/vt/vtexplain/vtexplain_vtgate.go index fb2f0a308b8..6a83463afb8 100644 --- a/go/vt/vtexplain/vtexplain_vtgate.go +++ b/go/vt/vtexplain/vtexplain_vtgate.go @@ -29,7 +29,7 @@ import ( "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/key" - "github.com/youtube/vitess/go/vt/topo" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/vtgate" "github.com/youtube/vitess/go/vt/vtgate/engine" "github.com/youtube/vitess/go/vt/vtgate/gateway" @@ -70,7 +70,7 @@ func initVtgateExecutor(vSchemaStr string, opts *Options) error { return nil } -func newFakeResolver(hc discovery.HealthCheck, serv topo.SrvTopoServer, cell string) *vtgate.Resolver { +func newFakeResolver(hc discovery.HealthCheck, serv srvtopo.Server, cell string) *vtgate.Resolver { gw := gateway.GetCreator()(hc, nil, serv, cell, 3) gw.WaitForTablets(context.Background(), []topodatapb.TabletType{topodatapb.TabletType_REPLICA}) tc := vtgate.NewTxConn(gw, vtgatepb.TransactionMode_MULTI) diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index b0d551d4798..8fd702b625f 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -36,6 +36,7 @@ import ( "github.com/youtube/vitess/go/stats" "github.com/youtube/vitess/go/vt/sqlannotation" "github.com/youtube/vitess/go/vt/sqlparser" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/topoproto" "github.com/youtube/vitess/go/vt/vterrors" @@ -62,7 +63,7 @@ func init() { // Executor is the engine that executes queries by utilizing // the abilities of the underlying vttablets. type Executor struct { - serv topo.SrvTopoServer + serv srvtopo.Server cell string resolver *Resolver scatterConn *ScatterConn @@ -81,7 +82,7 @@ type Executor struct { var executorOnce sync.Once // NewExecutor creates a new Executor. -func NewExecutor(ctx context.Context, serv topo.SrvTopoServer, cell, statsName string, resolver *Resolver, normalize bool, streamSize int, queryPlanCacheSize int64, legacyAutocommit bool) *Executor { +func NewExecutor(ctx context.Context, serv srvtopo.Server, cell, statsName string, resolver *Resolver, normalize bool, streamSize int, queryPlanCacheSize int64, legacyAutocommit bool) *Executor { e := &Executor{ serv: serv, cell: cell, diff --git a/go/vt/vtgate/gateway/discoverygateway.go b/go/vt/vtgate/gateway/discoverygateway.go index 34f28b32c92..2f40b4dea73 100644 --- a/go/vt/vtgate/gateway/discoverygateway.go +++ b/go/vt/vtgate/gateway/discoverygateway.go @@ -30,6 +30,7 @@ import ( "github.com/youtube/vitess/go/flagutil" "github.com/youtube/vitess/go/vt/discovery" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/vterrors" "github.com/youtube/vitess/go/vt/vtgate/buffer" @@ -65,7 +66,7 @@ type discoveryGateway struct { hc discovery.HealthCheck tsc *discovery.TabletStatsCache topoServer *topo.Server - srvTopoServer topo.SrvTopoServer + srvTopoServer srvtopo.Server localCell string retryCount int @@ -83,7 +84,7 @@ type discoveryGateway struct { buffer *buffer.Buffer } -func createDiscoveryGateway(hc discovery.HealthCheck, topoServer *topo.Server, serv topo.SrvTopoServer, cell string, retryCount int) Gateway { +func createDiscoveryGateway(hc discovery.HealthCheck, topoServer *topo.Server, serv srvtopo.Server, cell string, retryCount int) Gateway { dg := &discoveryGateway{ hc: hc, tsc: discovery.NewTabletStatsCacheDoNotSetListener(topoServer, cell), diff --git a/go/vt/vtgate/gateway/gateway.go b/go/vt/vtgate/gateway/gateway.go index 47085163c01..36e2c61bbd2 100644 --- a/go/vt/vtgate/gateway/gateway.go +++ b/go/vt/vtgate/gateway/gateway.go @@ -26,6 +26,7 @@ import ( "golang.org/x/net/context" "github.com/youtube/vitess/go/vt/discovery" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/vttablet/queryservice" @@ -55,7 +56,7 @@ type Gateway interface { } // Creator is the factory method which can create the actual gateway object. -type Creator func(hc discovery.HealthCheck, topoServer *topo.Server, serv topo.SrvTopoServer, cell string, retryCount int) Gateway +type Creator func(hc discovery.HealthCheck, topoServer *topo.Server, serv srvtopo.Server, cell string, retryCount int) Gateway var creators = make(map[string]Creator) diff --git a/go/vt/vtgate/gateway/l2vtgategateway.go b/go/vt/vtgate/gateway/l2vtgategateway.go index fe63ecf2de5..49c22e2c916 100644 --- a/go/vt/vtgate/gateway/l2vtgategateway.go +++ b/go/vt/vtgate/gateway/l2vtgategateway.go @@ -31,6 +31,7 @@ import ( "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/grpcclient" "github.com/youtube/vitess/go/vt/key" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/topoproto" "github.com/youtube/vitess/go/vt/vttablet/queryservice" @@ -82,7 +83,7 @@ type l2VTGateGateway struct { statusAggregators map[string]*TabletStatusAggregator } -func createL2VTGateGateway(hc discovery.HealthCheck, topoServer *topo.Server, serv topo.SrvTopoServer, cell string, retryCount int) Gateway { +func createL2VTGateGateway(hc discovery.HealthCheck, topoServer *topo.Server, serv srvtopo.Server, cell string, retryCount int) Gateway { lg := &l2VTGateGateway{ retryCount: retryCount, connMap: make(map[string][]*l2VTGateConn), diff --git a/go/vt/vtgate/l2vtgate/l2vtgate.go b/go/vt/vtgate/l2vtgate/l2vtgate.go index 047672c8107..d78e1cd63c9 100644 --- a/go/vt/vtgate/l2vtgate/l2vtgate.go +++ b/go/vt/vtgate/l2vtgate/l2vtgate.go @@ -27,6 +27,7 @@ import ( "github.com/youtube/vitess/go/stats" "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/servenv" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/topoproto" "github.com/youtube/vitess/go/vt/vterrors" @@ -58,7 +59,7 @@ type RegisterL2VTGate func(queryservice.QueryService) var RegisterL2VTGates []RegisterL2VTGate // Init creates the single L2VTGate with the provided parameters. -func Init(hc discovery.HealthCheck, topoServer *topo.Server, serv topo.SrvTopoServer, statsName, cell string, retryCount int, tabletTypesToWait []topodatapb.TabletType) *L2VTGate { +func Init(hc discovery.HealthCheck, topoServer *topo.Server, serv srvtopo.Server, statsName, cell string, retryCount int, tabletTypesToWait []topodatapb.TabletType) *L2VTGate { if l2VTGate != nil { log.Fatalf("L2VTGate already initialized") } diff --git a/go/vt/vtgate/resilient_srv_topo_server.go b/go/vt/vtgate/resilient_srv_topo_server.go index 941ee50273b..44d5afcab8e 100644 --- a/go/vt/vtgate/resilient_srv_topo_server.go +++ b/go/vt/vtgate/resilient_srv_topo_server.go @@ -90,7 +90,7 @@ const ( ` ) -// ResilientSrvTopoServer is an implementation of SrvTopoServer based +// ResilientSrvTopoServer is an implementation of srvtopo.Server based // on a topo.Server that uses a cache for two purposes: // - limit the QPS to the underlying topo.Server // - return the last known value of the data if there is an error diff --git a/go/vt/vtgate/resolver.go b/go/vt/vtgate/resolver.go index f5f01879059..ec7df8626db 100644 --- a/go/vt/vtgate/resolver.go +++ b/go/vt/vtgate/resolver.go @@ -25,7 +25,7 @@ import ( "github.com/youtube/vitess/go/sqltypes" "github.com/youtube/vitess/go/vt/sqlparser" - "github.com/youtube/vitess/go/vt/topo" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/vterrors" "github.com/youtube/vitess/go/vt/vtgate/gateway" "golang.org/x/net/context" @@ -49,12 +49,12 @@ var ( // resharding happened. type Resolver struct { scatterConn *ScatterConn - toposerv topo.SrvTopoServer + toposerv srvtopo.Server cell string } // NewResolver creates a new Resolver. -func NewResolver(serv topo.SrvTopoServer, cell string, sc *ScatterConn) *Resolver { +func NewResolver(serv srvtopo.Server, cell string, sc *ScatterConn) *Resolver { return &Resolver{ scatterConn: sc, toposerv: serv, diff --git a/go/vt/vtgate/resolver_test.go b/go/vt/vtgate/resolver_test.go index 2dd51684a66..f1365192e44 100644 --- a/go/vt/vtgate/resolver_test.go +++ b/go/vt/vtgate/resolver_test.go @@ -27,7 +27,7 @@ import ( "github.com/youtube/vitess/go/sqltypes" "github.com/youtube/vitess/go/vt/discovery" - "github.com/youtube/vitess/go/vt/topo" + "github.com/youtube/vitess/go/vt/srvtopo" "golang.org/x/net/context" querypb "github.com/youtube/vitess/go/vt/proto/query" @@ -662,7 +662,7 @@ func TestResolverExecBatchAsTransaction(t *testing.T) { } } -func newTestResolver(hc discovery.HealthCheck, serv topo.SrvTopoServer, cell string) *Resolver { +func newTestResolver(hc discovery.HealthCheck, serv srvtopo.Server, cell string) *Resolver { sc := newTestScatterConn(hc, serv, cell) return NewResolver(serv, cell, sc) } diff --git a/go/vt/vtgate/sandbox_test.go b/go/vt/vtgate/sandbox_test.go index 83c17cbcc69..183537cea4b 100644 --- a/go/vt/vtgate/sandbox_test.go +++ b/go/vt/vtgate/sandbox_test.go @@ -214,11 +214,11 @@ func createUnshardedKeyspace() (*topodatapb.SrvKeyspace, error) { return unshardedSrvKeyspace, nil } -// sandboxTopo satisfies the SrvTopoServer interface +// sandboxTopo satisfies the srvtopo.Server interface type sandboxTopo struct { } -// GetSrvKeyspaceNames is part of SrvTopoServer. +// GetSrvKeyspaceNames is part of the srvtopo.Server interface. func (sct *sandboxTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error) { sandboxMu.Lock() defer sandboxMu.Unlock() @@ -229,7 +229,7 @@ func (sct *sandboxTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([ return keyspaces, nil } -// GetSrvKeyspace is part of SrvTopoServer. +// GetSrvKeyspace is part of the srvtopo.Server interface. func (sct *sandboxTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) { sand := getSandbox(keyspace) sand.sandmu.Lock() @@ -266,7 +266,7 @@ func (sct *sandboxTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace strin return createShardedSrvKeyspace(sand.ShardSpec, sand.KeyspaceServedFrom) } -// WatchSrvVSchema is part of SrvTopoServer. +// WatchSrvVSchema is part of the srvtopo.Server interface. func (sct *sandboxTopo) WatchSrvVSchema(ctx context.Context, cell string) (*topo.WatchSrvVSchemaData, <-chan *topo.WatchSrvVSchemaData, topo.CancelFunc) { return &topo.WatchSrvVSchemaData{ Value: getSandboxSrvVSchema(), diff --git a/go/vt/vtgate/scatter_conn_test.go b/go/vt/vtgate/scatter_conn_test.go index 8e50d015338..71e891fc61f 100644 --- a/go/vt/vtgate/scatter_conn_test.go +++ b/go/vt/vtgate/scatter_conn_test.go @@ -27,7 +27,7 @@ import ( "github.com/golang/protobuf/proto" "github.com/youtube/vitess/go/sqltypes" "github.com/youtube/vitess/go/vt/discovery" - "github.com/youtube/vitess/go/vt/topo" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/vterrors" "github.com/youtube/vitess/go/vt/vtgate/gateway" @@ -563,7 +563,7 @@ func TestShuffleQueryParts(t *testing.T) { injectShuffleQueryPartsRandomGenerator(oldGen) } -func newTestScatterConn(hc discovery.HealthCheck, serv topo.SrvTopoServer, cell string) *ScatterConn { +func newTestScatterConn(hc discovery.HealthCheck, serv srvtopo.Server, cell string) *ScatterConn { // The topo.Server is used to start watching the cells described // in '-cells_to_watch' command line parameter, which is // empty by default. So it's unused in this test, set to nil. diff --git a/go/vt/vtgate/topo_utils.go b/go/vt/vtgate/topo_utils.go index 19f9d83d83c..e895342aad3 100644 --- a/go/vt/vtgate/topo_utils.go +++ b/go/vt/vtgate/topo_utils.go @@ -21,7 +21,7 @@ import ( "sort" "github.com/youtube/vitess/go/vt/key" - "github.com/youtube/vitess/go/vt/topo" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo/topoproto" "github.com/youtube/vitess/go/vt/vterrors" "golang.org/x/net/context" @@ -32,7 +32,7 @@ import ( vtrpcpb "github.com/youtube/vitess/go/vt/proto/vtrpc" ) -func mapKeyspaceIdsToShards(ctx context.Context, topoServ topo.SrvTopoServer, cell, keyspace string, tabletType topodatapb.TabletType, keyspaceIds [][]byte) (string, []string, error) { +func mapKeyspaceIdsToShards(ctx context.Context, topoServ srvtopo.Server, cell, keyspace string, tabletType topodatapb.TabletType, keyspaceIds [][]byte) (string, []string, error) { keyspace, _, allShards, err := getKeyspaceShards(ctx, topoServ, cell, keyspace, tabletType) if err != nil { return "", nil, err @@ -52,7 +52,7 @@ func mapKeyspaceIdsToShards(ctx context.Context, topoServ topo.SrvTopoServer, ce return keyspace, res, nil } -func getAnyShard(ctx context.Context, topoServ topo.SrvTopoServer, cell, keyspace string, tabletType topodatapb.TabletType) (ks, shard string, err error) { +func getAnyShard(ctx context.Context, topoServ srvtopo.Server, cell, keyspace string, tabletType topodatapb.TabletType) (ks, shard string, err error) { keyspace, _, allShards, err := getKeyspaceShards(ctx, topoServ, cell, keyspace, tabletType) if err != nil { return "", "", err @@ -63,7 +63,7 @@ func getAnyShard(ctx context.Context, topoServ topo.SrvTopoServer, cell, keyspac return keyspace, allShards[0].Name, nil } -func getAllKeyspaces(ctx context.Context, topoServ topo.SrvTopoServer, cell string) ([]string, error) { +func getAllKeyspaces(ctx context.Context, topoServ srvtopo.Server, cell string) ([]string, error) { keyspaces, err := topoServ.GetSrvKeyspaceNames(ctx, cell) if err != nil { return nil, vterrors.Errorf(vtrpcpb.Code_UNKNOWN, "keyspace names fetch error: %v", err) @@ -73,7 +73,7 @@ func getAllKeyspaces(ctx context.Context, topoServ topo.SrvTopoServer, cell stri return keyspaces, nil } -func getKeyspaceShards(ctx context.Context, topoServ topo.SrvTopoServer, cell, keyspace string, tabletType topodatapb.TabletType) (string, *topodatapb.SrvKeyspace, []*topodatapb.ShardReference, error) { +func getKeyspaceShards(ctx context.Context, topoServ srvtopo.Server, cell, keyspace string, tabletType topodatapb.TabletType) (string, *topodatapb.SrvKeyspace, []*topodatapb.ShardReference, error) { srvKeyspace, err := topoServ.GetSrvKeyspace(ctx, cell, keyspace) if err != nil { return "", nil, nil, vterrors.Errorf(vtrpcpb.Code_UNKNOWN, "keyspace %v fetch error: %v", keyspace, err) @@ -110,7 +110,7 @@ func getShardForKeyspaceID(allShards []*topodatapb.ShardReference, keyspaceID [] return "", vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "KeyspaceId %v didn't match any shards %+v", hex.EncodeToString(keyspaceID), allShards) } -func mapEntityIdsToShards(ctx context.Context, topoServ topo.SrvTopoServer, cell, keyspace string, entityIds []*vtgatepb.ExecuteEntityIdsRequest_EntityId, tabletType topodatapb.TabletType) (string, map[string][]*querypb.Value, error) { +func mapEntityIdsToShards(ctx context.Context, topoServ srvtopo.Server, cell, keyspace string, entityIds []*vtgatepb.ExecuteEntityIdsRequest_EntityId, tabletType topodatapb.TabletType) (string, map[string][]*querypb.Value, error) { keyspace, _, allShards, err := getKeyspaceShards(ctx, topoServ, cell, keyspace, tabletType) if err != nil { return "", nil, err @@ -129,7 +129,7 @@ func mapEntityIdsToShards(ctx context.Context, topoServ topo.SrvTopoServer, cell // Given a collection of key-ranges, returns the set of shards that "intersect" // them; that is, a shard is included if and only if its corresponding key-space ids // are in one of the key-ranges. -func mapKeyRangesToShards(ctx context.Context, topoServ topo.SrvTopoServer, cell, keyspace string, tabletType topodatapb.TabletType, krs []*topodatapb.KeyRange) (string, []string, error) { +func mapKeyRangesToShards(ctx context.Context, topoServ srvtopo.Server, cell, keyspace string, tabletType topodatapb.TabletType, krs []*topodatapb.KeyRange) (string, []string, error) { keyspace, _, allShards, err := getKeyspaceShards(ctx, topoServ, cell, keyspace, tabletType) if err != nil { return "", nil, err @@ -162,7 +162,7 @@ func resolveKeyRangeToShards(allShards []*topodatapb.ShardReference, matches map // mapExactShards maps a keyrange to shards only if there's a complete // match. If there's any partial match the function returns no match. -func mapExactShards(ctx context.Context, topoServ topo.SrvTopoServer, cell, keyspace string, tabletType topodatapb.TabletType, kr *topodatapb.KeyRange) (newkeyspace string, shards []string, err error) { +func mapExactShards(ctx context.Context, topoServ srvtopo.Server, cell, keyspace string, tabletType topodatapb.TabletType, kr *topodatapb.KeyRange) (newkeyspace string, shards []string, err error) { keyspace, _, allShards, err := getKeyspaceShards(ctx, topoServ, cell, keyspace, tabletType) if err != nil { return "", nil, err @@ -207,7 +207,7 @@ func boundShardQueriesToScatterBatchRequest(boundQueries []*vtgatepb.BoundShardQ return requests, nil } -func boundKeyspaceIDQueriesToBoundShardQueries(ctx context.Context, topoServ topo.SrvTopoServer, cell string, tabletType topodatapb.TabletType, idQueries []*vtgatepb.BoundKeyspaceIdQuery) ([]*vtgatepb.BoundShardQuery, error) { +func boundKeyspaceIDQueriesToBoundShardQueries(ctx context.Context, topoServ srvtopo.Server, cell string, tabletType topodatapb.TabletType, idQueries []*vtgatepb.BoundKeyspaceIdQuery) ([]*vtgatepb.BoundShardQuery, error) { shardQueries := make([]*vtgatepb.BoundShardQuery, len(idQueries)) for i, idQuery := range idQueries { keyspace, shards, err := mapKeyspaceIdsToShards(ctx, topoServ, cell, idQuery.Keyspace, tabletType, idQuery.KeyspaceIds) diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index de9b8f10e3b..8ab1903ff60 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -38,6 +38,7 @@ import ( "github.com/youtube/vitess/go/vt/servenv" "github.com/youtube/vitess/go/vt/sqlannotation" "github.com/youtube/vitess/go/vt/sqlparser" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/topoproto" "github.com/youtube/vitess/go/vt/vterrors" @@ -143,7 +144,7 @@ var RegisterVTGates []RegisterVTGate var vtgateOnce sync.Once // Init initializes VTGate server. -func Init(ctx context.Context, hc discovery.HealthCheck, topoServer *topo.Server, serv topo.SrvTopoServer, cell string, retryCount int, tabletTypesToWait []topodatapb.TabletType) *VTGate { +func Init(ctx context.Context, hc discovery.HealthCheck, topoServer *topo.Server, serv srvtopo.Server, cell string, retryCount int, tabletTypesToWait []topodatapb.TabletType) *VTGate { if rpcVTGate != nil { log.Fatalf("VTGate already initialized") } From c413521709796b8caf91eb05ce31a0bf5e482982 Mon Sep 17 00:00:00 2001 From: Alain Jobart Date: Tue, 9 Jan 2018 15:12:07 -0800 Subject: [PATCH 3/7] Moving ResilientSrvTopoServer to srvtopo. --- go/cmd/l2vtgate/main.go | 8 ++--- go/cmd/l2vtgate/status.go | 6 ++-- go/cmd/vtcombo/main.go | 5 +-- go/cmd/vtgate/status.go | 5 +-- go/cmd/vtgate/vtgate.go | 7 ++-- .../resilient_server.go} | 32 +++++++++---------- .../resilient_server_test.go} | 8 ++--- 7 files changed, 37 insertions(+), 34 deletions(-) rename go/vt/{vtgate/resilient_srv_topo_server.go => srvtopo/resilient_server.go} (90%) rename go/vt/{vtgate/resilient_srv_topo_server_test.go => srvtopo/resilient_server_test.go} (96%) diff --git a/go/cmd/l2vtgate/main.go b/go/cmd/l2vtgate/main.go index 2404c1256b8..dd082656c8e 100644 --- a/go/cmd/l2vtgate/main.go +++ b/go/cmd/l2vtgate/main.go @@ -28,9 +28,9 @@ import ( "github.com/youtube/vitess/go/exit" "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/servenv" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/topoproto" - "github.com/youtube/vitess/go/vt/vtgate" "github.com/youtube/vitess/go/vt/vtgate/l2vtgate" topodatapb "github.com/youtube/vitess/go/vt/proto/topodata" @@ -44,7 +44,7 @@ var ( tabletTypesToWait = flag.String("tablet_types_to_wait", "", "wait till connected for specified tablet types during Gateway initialization") ) -var resilientSrvTopoServer *vtgate.ResilientSrvTopoServer +var resilientServer *srvtopo.ResilientServer var healthCheck discovery.HealthCheck func init() { @@ -66,7 +66,7 @@ func main() { ts := topo.Open() defer ts.Close() - resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer") + resilientServer = srvtopo.NewResilientServer(ts, "ResilientSrvTopoServer") healthCheck = discovery.NewHealthCheck(*healthCheckRetryDelay, *healthCheckTimeout) healthCheck.RegisterStats() @@ -82,7 +82,7 @@ func main() { tabletTypes = append(tabletTypes, tt) } } - l2vtg := l2vtgate.Init(healthCheck, ts, resilientSrvTopoServer, "VttabletCall", *cell, *retryCount, tabletTypes) + l2vtg := l2vtgate.Init(healthCheck, ts, resilientServer, "VttabletCall", *cell, *retryCount, tabletTypes) servenv.OnRun(func() { addStatusParts(l2vtg) diff --git a/go/cmd/l2vtgate/status.go b/go/cmd/l2vtgate/status.go index cc1325f3151..194e77a42ad 100644 --- a/go/cmd/l2vtgate/status.go +++ b/go/cmd/l2vtgate/status.go @@ -19,8 +19,8 @@ package main import ( "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/servenv" + "github.com/youtube/vitess/go/vt/srvtopo" _ "github.com/youtube/vitess/go/vt/status" - "github.com/youtube/vitess/go/vt/vtgate" "github.com/youtube/vitess/go/vt/vtgate/gateway" "github.com/youtube/vitess/go/vt/vtgate/l2vtgate" ) @@ -29,8 +29,8 @@ import ( var onStatusRegistered func() func addStatusParts(l2vtgate *l2vtgate.L2VTGate) { - servenv.AddStatusPart("Topology Cache", vtgate.TopoTemplate, func() interface{} { - return resilientSrvTopoServer.CacheStatus() + servenv.AddStatusPart("Topology Cache", srvtopo.TopoTemplate, func() interface{} { + return resilientServer.CacheStatus() }) servenv.AddStatusPart("Gateway Status", gateway.StatusTemplate, func() interface{} { return l2vtgate.GetGatewayCacheStatus() diff --git a/go/cmd/vtcombo/main.go b/go/cmd/vtcombo/main.go index e411f773043..43729f70d83 100644 --- a/go/cmd/vtcombo/main.go +++ b/go/cmd/vtcombo/main.go @@ -36,6 +36,7 @@ import ( "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/mysqlctl" "github.com/youtube/vitess/go/vt/servenv" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/memorytopo" "github.com/youtube/vitess/go/vt/vtctld" @@ -126,7 +127,7 @@ func main() { } // vtgate configuration and init - resilientSrvTopoServer := vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer") + resilientServer := srvtopo.NewResilientServer(ts, "ResilientSrvTopoServer") healthCheck := discovery.NewHealthCheck(1*time.Millisecond /*retryDelay*/, 1*time.Hour /*healthCheckTimeout*/) tabletTypesToWait := []topodatapb.TabletType{ topodatapb.TabletType_MASTER, @@ -137,7 +138,7 @@ func main() { vtgate.QueryLogHandler = "/debug/vtgate/querylog" vtgate.QueryLogzHandler = "/debug/vtgate/querylogz" vtgate.QueryzHandler = "/debug/vtgate/queryz" - vtgate.Init(context.Background(), healthCheck, ts, resilientSrvTopoServer, tpb.Cells[0], 2 /*retryCount*/, tabletTypesToWait) + vtgate.Init(context.Background(), healthCheck, ts, resilientServer, tpb.Cells[0], 2 /*retryCount*/, tabletTypesToWait) // vtctld configuration and init vtctld.InitVtctld(ts) diff --git a/go/cmd/vtgate/status.go b/go/cmd/vtgate/status.go index 8c4e52f3b6c..bc7b6ce7fdc 100644 --- a/go/cmd/vtgate/status.go +++ b/go/cmd/vtgate/status.go @@ -19,6 +19,7 @@ package main import ( "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/servenv" + "github.com/youtube/vitess/go/vt/srvtopo" _ "github.com/youtube/vitess/go/vt/status" "github.com/youtube/vitess/go/vt/vtgate" "github.com/youtube/vitess/go/vt/vtgate/gateway" @@ -34,8 +35,8 @@ func addStatusParts(vtg *vtgate.VTGate) { servenv.AddStatusPart("VSchema", vtgate.VSchemaTemplate, func() interface{} { return vtg.VSchemaStats() }) - servenv.AddStatusPart("Topology Cache", vtgate.TopoTemplate, func() interface{} { - return resilientSrvTopoServer.CacheStatus() + servenv.AddStatusPart("Topology Cache", srvtopo.TopoTemplate, func() interface{} { + return resilientServer.CacheStatus() }) servenv.AddStatusPart("Gateway Status", gateway.StatusTemplate, func() interface{} { return vtg.GetGatewayCacheStatus() diff --git a/go/cmd/vtgate/vtgate.go b/go/cmd/vtgate/vtgate.go index bcfd3dd0b41..3c2d9c33260 100644 --- a/go/cmd/vtgate/vtgate.go +++ b/go/cmd/vtgate/vtgate.go @@ -30,6 +30,7 @@ import ( "github.com/youtube/vitess/go/exit" "github.com/youtube/vitess/go/vt/discovery" "github.com/youtube/vitess/go/vt/servenv" + "github.com/youtube/vitess/go/vt/srvtopo" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/topoproto" "github.com/youtube/vitess/go/vt/vtgate" @@ -45,7 +46,7 @@ var ( tabletTypesToWait = flag.String("tablet_types_to_wait", "", "wait till connected for specified tablet types during Gateway initialization") ) -var resilientSrvTopoServer *vtgate.ResilientSrvTopoServer +var resilientServer *srvtopo.ResilientServer var healthCheck discovery.HealthCheck var initFakeZK func() @@ -72,7 +73,7 @@ func main() { ts := topo.Open() defer ts.Close() - resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer") + resilientServer = srvtopo.NewResilientServer(ts, "ResilientSrvTopoServer") healthCheck = discovery.NewHealthCheck(*healthCheckRetryDelay, *healthCheckTimeout) healthCheck.RegisterStats() @@ -89,7 +90,7 @@ func main() { } } - vtg := vtgate.Init(context.Background(), healthCheck, ts, resilientSrvTopoServer, *cell, *retryCount, tabletTypes) + vtg := vtgate.Init(context.Background(), healthCheck, ts, resilientServer, *cell, *retryCount, tabletTypes) servenv.OnRun(func() { addStatusParts(vtg) diff --git a/go/vt/vtgate/resilient_srv_topo_server.go b/go/vt/srvtopo/resilient_server.go similarity index 90% rename from go/vt/vtgate/resilient_srv_topo_server.go rename to go/vt/srvtopo/resilient_server.go index 44d5afcab8e..89526d5ed64 100644 --- a/go/vt/vtgate/resilient_srv_topo_server.go +++ b/go/vt/srvtopo/resilient_server.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package vtgate +package srvtopo import ( "flag" @@ -43,7 +43,7 @@ const ( errorCategory = "error" // TopoTemplate is the HTML to use to display the - // ResilientSrvTopoServerCacheStatus object + // ResilientServerCacheStatus object TopoTemplate = `