vitess-gh/proto/vschema.proto

138 строки
4.2 KiB
Protocol Buffer

/*
Copyright 2019 The Vitess Authors.
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.
*/
// This file contains the types needed to define a vschema.
syntax = "proto3";
option go_package = "vitess.io/vitess/go/vt/proto/vschema";
package vschema;
import "query.proto";
// RoutingRules specify the high level routing rules for the VSchema.
message RoutingRules {
// rules should ideally be a map. However protos dont't allow
// repeated fields as elements of a map. So, we use a list
// instead.
repeated RoutingRule rules = 1;
}
// RoutingRule specifies a routing rule.
message RoutingRule {
string from_table = 1;
repeated string to_tables = 2;
}
// Keyspace is the vschema for a keyspace.
message Keyspace {
// If sharded is false, vindexes and tables are ignored.
bool sharded = 1;
map<string, Vindex> vindexes = 2;
map<string, Table> tables = 3;
// If require_explicit_routing is true, vindexes and tables are not added to global routing
bool require_explicit_routing = 4;
}
// Vindex is the vindex info for a Keyspace.
message Vindex {
// The type must match one of the predefined
// (or plugged in) vindex names.
string type = 1;
// params is a map of attribute value pairs
// that must be defined as required by the
// vindex constructors. The values can only
// be strings.
map<string, string> params = 2;
// A lookup vindex can have an owner table defined.
// If so, rows in the lookup table are created or
// deleted in sync with corresponding rows in the
// owner table.
string owner = 3;
}
// Table is the table info for a Keyspace.
message Table {
// If the table is a sequence, type must be
// "sequence".
//
// If the table is a reference, type must be
// "reference".
// See https://vitess.io/docs/reference/features/vschema/#reference-tables.
//
// Otherwise, it should be empty.
string type = 1;
// column_vindexes associates columns to vindexes.
repeated ColumnVindex column_vindexes = 2;
// auto_increment is specified if a column needs
// to be associated with a sequence.
AutoIncrement auto_increment = 3;
// columns lists the columns for the table.
repeated Column columns = 4;
// pinned pins an unsharded table to a specific
// shard, as dictated by the keyspace id.
// The keyspace id is represented in hex form
// like in keyranges.
string pinned = 5;
// column_list_authoritative is set to true if columns is
// an authoritative list for the table. This allows
// us to expand 'select *' expressions.
bool column_list_authoritative = 6;
}
// ColumnVindex is used to associate a column to a vindex.
message ColumnVindex {
// Legacy implementation, moving forward all vindexes should define a list of columns.
string column = 1;
// The name must match a vindex defined in Keyspace.
string name = 2;
// List of columns that define this Vindex
repeated string columns = 3;
}
// Autoincrement is used to designate a column as auto-inc.
message AutoIncrement {
string column = 1;
// The sequence must match a table of type SEQUENCE.
string sequence = 2;
}
// Column describes a column.
message Column {
string name = 1;
query.Type type = 2;
}
// SrvVSchema is the roll-up of all the Keyspace schema for a cell.
message SrvVSchema {
// keyspaces is a map of keyspace name -> Keyspace object.
map<string, Keyspace> keyspaces = 1;
RoutingRules routing_rules = 2; // table routing rules
ShardRoutingRules shard_routing_rules = 3;
}
// ShardRoutingRules specify the shard routing rules for the VSchema.
message ShardRoutingRules {
repeated ShardRoutingRule rules = 1;
}
// RoutingRule specifies a routing rule.
message ShardRoutingRule {
string from_keyspace = 1;
string to_keyspace = 2;
string shard = 3;
}