github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/cdc/processor/tablepb/table.proto (about)

     1  // Copyright 2022 PingCAP, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  syntax = "proto3";
    15  package pingcap.tiflow.cdc.processor.tablepb;
    16  option go_package = "github.com/pingcap/tiflow/cdc/processor/tablepb";
    17  
    18  import "gogoproto/gogo.proto";
    19  
    20  option(gogoproto.goproto_enum_prefix_all) = false;
    21  
    22  // Span is a full extent of key space from an inclusive start_key to
    23  // an exclusive end_key.
    24  message Span {
    25      option(gogoproto.stringer) = false;
    26      option(gogoproto.goproto_stringer) = false;
    27      option(gogoproto.goproto_getters) = false;
    28  
    29      int64 table_id = 1 [
    30          (gogoproto.casttype) = "TableID",
    31          (gogoproto.customname) = "TableID"
    32      ];
    33      bytes start_key = 2 [(gogoproto.casttype) = "Key"];
    34      bytes end_key = 3 [(gogoproto.casttype) = "Key"];
    35  }
    36  
    37  // TableState is the state of table replication in processor.
    38  //
    39  //  ┌────────┐   ┌───────────┐   ┌──────────┐
    40  //  │ Absent ├─> │ Preparing ├─> │ Prepared │
    41  //  └────────┘   └───────────┘   └─────┬────┘
    42  //                                     v
    43  //  ┌─────────┐   ┌──────────┐   ┌─────────────┐
    44  //  │ Stopped │ <─┤ Stopping │ <─┤ Replicating │
    45  //  └─────────┘   └──────────┘   └─────────────┘
    46  // TODO rename to TableSpanState.
    47  enum TableState {
    48      Unknown = 0 [(gogoproto.enumvalue_customname) = "TableStateUnknown"];
    49      Absent = 1 [(gogoproto.enumvalue_customname) = "TableStateAbsent"];
    50      Preparing = 2 [(gogoproto.enumvalue_customname) = "TableStatePreparing"];
    51      Prepared = 3 [(gogoproto.enumvalue_customname) = "TableStatePrepared"];
    52      Replicating = 4 [(gogoproto.enumvalue_customname) = "TableStateReplicating"];
    53      Stopping = 5 [(gogoproto.enumvalue_customname) = "TableStateStopping"];
    54      Stopped = 6 [(gogoproto.enumvalue_customname) = "TableStateStopped"];
    55  }
    56  
    57  message Checkpoint {
    58      uint64 checkpoint_ts = 1 [(gogoproto.casttype) = "Ts"];
    59      uint64 resolved_ts = 2 [(gogoproto.casttype) = "Ts"];
    60      uint64 last_synced_ts = 3 [(gogoproto.casttype) = "Ts"];
    61  }
    62  
    63  // Stats holds a statistic for a table.
    64  message Stats {
    65      // Number of captured regions.
    66      uint64 region_count = 1;
    67      // The current timestamp from the table's point of view.
    68      uint64 current_ts = 2 [(gogoproto.casttype) = "Ts"];
    69      // Checkponits at each stage.
    70      map<string, Checkpoint> stage_checkpoints = 3 [(gogoproto.nullable) = false];
    71      // The barrier timestamp of the table.
    72      uint64 barrier_ts = 4 [(gogoproto.casttype) = "Ts"];
    73  }
    74  
    75  // TableStatus is the running status of a table.
    76  // TODO rename to TableStatus.
    77  message TableStatus {
    78      int64 table_id = 1 [
    79          (gogoproto.casttype) = "TableID",
    80          (gogoproto.customname) = "TableID"
    81      ];
    82      Span span = 5 [(gogoproto.nullable) = false];
    83  
    84      TableState state = 2;
    85      Checkpoint checkpoint = 3 [(gogoproto.nullable) = false];
    86      Stats stats = 4 [(gogoproto.nullable) = false];
    87  }