vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletserver/controller.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 tabletserver 18 19 import ( 20 "context" 21 22 "vitess.io/vitess/go/vt/dbconfigs" 23 "vitess.io/vitess/go/vt/mysqlctl" 24 "vitess.io/vitess/go/vt/topo" 25 "vitess.io/vitess/go/vt/vttablet/queryservice" 26 "vitess.io/vitess/go/vt/vttablet/tabletserver/rules" 27 "vitess.io/vitess/go/vt/vttablet/tabletserver/schema" 28 "vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv" 29 "vitess.io/vitess/go/vt/vttablet/vexec" 30 31 "time" 32 33 querypb "vitess.io/vitess/go/vt/proto/query" 34 topodatapb "vitess.io/vitess/go/vt/proto/topodata" 35 ) 36 37 // Controller defines the control interface for TabletServer. 38 type Controller interface { 39 // Register registers this query service with the RPC layer. 40 Register() 41 42 // AddStatusHeader adds the header part to the status page. 43 AddStatusHeader() 44 45 // AddStatusHeader adds the status part to the status page 46 AddStatusPart() 47 48 // Stats returns stats vars. 49 Stats() *tabletenv.Stats 50 51 // InitDBConfig sets up the db config vars. 52 InitDBConfig(target *querypb.Target, dbConfigs *dbconfigs.DBConfigs, mysqlDaemon mysqlctl.MysqlDaemon) error 53 54 // SetServingType transitions the query service to the required serving type. 55 // Returns true if the state of QueryService or the tablet type changed. 56 SetServingType(tabletType topodatapb.TabletType, terTimestamp time.Time, serving bool, reason string) error 57 58 // EnterLameduck causes tabletserver to enter the lameduck state. 59 EnterLameduck() 60 61 // IsServing returns true if the query service is running 62 IsServing() bool 63 64 // IsHealthy returns the health status of the QueryService 65 IsHealthy() error 66 67 // ClearQueryPlanCache clears internal query plan cache 68 ClearQueryPlanCache() 69 70 // ReloadSchema makes the quey service reload its schema cache 71 ReloadSchema(ctx context.Context) error 72 73 // RegisterQueryRuleSource adds a query rule source 74 RegisterQueryRuleSource(ruleSource string) 75 76 // RegisterQueryRuleSource removes a query rule source 77 UnRegisterQueryRuleSource(ruleSource string) 78 79 // SetQueryRules sets the query rules for this QueryService 80 SetQueryRules(ruleSource string, qrs *rules.Rules) error 81 82 // QueryService returns the QueryService object used by this Controller 83 QueryService() queryservice.QueryService 84 85 // OnlineDDLExecutor the online DDL executor used by this Controller 86 OnlineDDLExecutor() vexec.Executor 87 88 // SchemaEngine returns the SchemaEngine object used by this Controller 89 SchemaEngine() *schema.Engine 90 91 // BroadcastHealth sends the current health to all listeners 92 BroadcastHealth() 93 94 // TopoServer returns the topo server. 95 TopoServer() *topo.Server 96 } 97 98 // Ensure TabletServer satisfies Controller interface. 99 var _ Controller = (*TabletServer)(nil)