vitess.io/vitess@v0.16.2/go/vt/srvtopo/server.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 /* 18 Package srvtopo contains a set of helper methods and classes to 19 use the topology service in a serving environment. 20 */ 21 package srvtopo 22 23 import ( 24 "context" 25 26 topodatapb "vitess.io/vitess/go/vt/proto/topodata" 27 vschemapb "vitess.io/vitess/go/vt/proto/vschema" 28 "vitess.io/vitess/go/vt/topo" 29 ) 30 31 // Server is a subset of the topo.Server API that only contains 32 // the serving graph read-only calls used by clients to resolve 33 // serving addresses, and to get VSchema. 34 type Server interface { 35 // GetTopoServer returns the full topo.Server instance. 36 GetTopoServer() (*topo.Server, error) 37 38 // GetSrvKeyspaceNames returns the list of keyspaces served in 39 // the provided cell. 40 GetSrvKeyspaceNames(ctx context.Context, cell string, staleOK bool) ([]string, error) 41 42 // GetSrvKeyspace returns the SrvKeyspace for a cell/keyspace. 43 GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) 44 45 WatchSrvKeyspace(ctx context.Context, cell, keyspace string, callback func(*topodatapb.SrvKeyspace, error) bool) 46 47 // WatchSrvVSchema starts watching the SrvVSchema object for 48 // the provided cell. It will call the callback when 49 // a new value or an error occurs. 50 WatchSrvVSchema(ctx context.Context, cell string, callback func(*vschemapb.SrvVSchema, error) bool) 51 }