vitess.io/vitess@v0.16.2/proto/vschema.proto (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  // This file contains the types needed to define a vschema.
    18  
    19  syntax = "proto3";
    20  option go_package = "vitess.io/vitess/go/vt/proto/vschema";
    21  
    22  package vschema;
    23  
    24  import "query.proto";
    25  
    26  // RoutingRules specify the high level routing rules for the VSchema.
    27  message RoutingRules {
    28    // rules should ideally be a map. However protos dont't allow
    29    // repeated fields as elements of a map. So, we use a list
    30    // instead.
    31    repeated RoutingRule rules = 1;
    32  }
    33  
    34  // RoutingRule specifies a routing rule.
    35  message RoutingRule {
    36    string from_table = 1;
    37    repeated string to_tables = 2;
    38  }
    39  
    40  // Keyspace is the vschema for a keyspace.
    41  message Keyspace {
    42    // If sharded is false, vindexes and tables are ignored.
    43    bool sharded = 1;
    44    map<string, Vindex> vindexes = 2;
    45    map<string, Table> tables = 3;
    46    // If require_explicit_routing is true, vindexes and tables are not added to global routing
    47    bool require_explicit_routing = 4;
    48  }
    49  
    50  // Vindex is the vindex info for a Keyspace.
    51  message Vindex {
    52    // The type must match one of the predefined
    53    // (or plugged in) vindex names.
    54    string type = 1;
    55    // params is a map of attribute value pairs
    56    // that must be defined as required by the
    57    // vindex constructors. The values can only
    58    // be strings.
    59    map<string, string> params = 2;
    60    // A lookup vindex can have an owner table defined.
    61    // If so, rows in the lookup table are created or
    62    // deleted in sync with corresponding rows in the
    63    // owner table.
    64    string owner = 3;
    65  }
    66  
    67  // Table is the table info for a Keyspace.
    68  message Table {
    69    // If the table is a sequence, type must be
    70    // "sequence".
    71    //
    72    // If the table is a reference, type must be
    73    // "reference".
    74    // See https://vitess.io/docs/reference/features/vschema/#reference-tables.
    75    //
    76    // Otherwise, it should be empty.
    77    string type = 1;
    78    // column_vindexes associates columns to vindexes.
    79    repeated ColumnVindex column_vindexes = 2;
    80    // auto_increment is specified if a column needs
    81    // to be associated with a sequence.
    82    AutoIncrement auto_increment = 3;
    83    // columns lists the columns for the table.
    84    repeated Column columns = 4;
    85    // pinned pins an unsharded table to a specific
    86    // shard, as dictated by the keyspace id.
    87    // The keyspace id is represented in hex form
    88    // like in keyranges.
    89    string pinned = 5;
    90    // column_list_authoritative is set to true if columns is
    91    // an authoritative list for the table. This allows
    92    // us to expand 'select *' expressions.
    93    bool column_list_authoritative = 6;
    94  
    95    // reference tables may optionally indicate their source table.
    96    string source = 7;
    97  }
    98  
    99  // ColumnVindex is used to associate a column to a vindex.
   100  message ColumnVindex {
   101    // Legacy implementation, moving forward all vindexes should define a list of columns.
   102    string column = 1;
   103    // The name must match a vindex defined in Keyspace.
   104    string name = 2;
   105    // List of columns that define this Vindex
   106    repeated string columns = 3;
   107  }
   108  
   109  // Autoincrement is used to designate a column as auto-inc.
   110  message AutoIncrement {
   111    string column = 1;
   112    // The sequence must match a table of type SEQUENCE.
   113    string sequence = 2;
   114  }
   115  
   116  // Column describes a column.
   117  message Column {
   118    string name = 1;
   119    query.Type type = 2;
   120  }
   121  
   122  // SrvVSchema is the roll-up of all the Keyspace schema for a cell.
   123  message SrvVSchema {
   124    // keyspaces is a map of keyspace name -> Keyspace object.
   125    map<string, Keyspace> keyspaces = 1;
   126    RoutingRules routing_rules = 2; // table routing rules
   127    ShardRoutingRules shard_routing_rules = 3;
   128  }
   129  
   130  // ShardRoutingRules specify the shard routing rules for the VSchema.
   131  message ShardRoutingRules {
   132    repeated ShardRoutingRule rules = 1;
   133  }
   134  
   135  // RoutingRule specifies a routing rule.
   136  message ShardRoutingRule {
   137    string from_keyspace = 1;
   138    string to_keyspace = 2;
   139    string shard = 3;
   140  }