github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/proto/CanalProtocol.proto (about)

     1  /*
     2   * Copyright (C) 2010-2101 Alibaba Group Holding Limited.
     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  syntax = "proto3";
    18  package com.alibaba.otter.canal.protocol;
    19  
    20  option java_package = "com.alibaba.otter.canal.protocol";
    21  option java_outer_classname = "CanalPacket";
    22  option optimize_for = SPEED;
    23  
    24  enum Compression {
    25      COMPRESSIONCOMPATIBLEPROTO2 = 0;
    26      NONE = 1;
    27      ZLIB = 2;
    28      GZIP = 3;
    29      LZF = 4;
    30  }
    31  
    32  enum PacketType {
    33      //compatible
    34      PACKAGETYPECOMPATIBLEPROTO2 = 0;
    35      HANDSHAKE = 1;
    36      CLIENTAUTHENTICATION = 2;
    37      ACK = 3;
    38      SUBSCRIPTION = 4;
    39      UNSUBSCRIPTION = 5;
    40      GET = 6;
    41      MESSAGES = 7;
    42      CLIENTACK = 8;
    43      // management part
    44      SHUTDOWN = 9;
    45      // integration
    46      DUMP = 10;
    47      HEARTBEAT = 11;
    48      CLIENTROLLBACK = 12;
    49  }
    50  
    51  message Packet {
    52       //[default = 17];
    53       oneof magic_number_present {
    54           int32 magic_number = 1;
    55       }
    56       //[default = 1];
    57       oneof version_present {
    58            int32 version = 2;
    59       };
    60       PacketType type = 3;
    61       //[default = NONE];
    62       oneof compression_present {
    63            Compression compression = 4;
    64       }
    65  
    66       bytes body = 5;
    67  }
    68  
    69  message HeartBeat {
    70       int64 send_timestamp = 1;
    71       int64 start_timestamp = 2;
    72  }
    73  
    74  message Handshake {
    75      //  [default = "utf8"];
    76      oneof communication_encoding_present {
    77          string communication_encoding = 1;
    78      }
    79       bytes seeds = 2;
    80       Compression supported_compressions = 3;
    81  }
    82  
    83  // client authentication
    84  message ClientAuth {
    85      string username = 1;
    86      bytes password = 2; // hashed password with seeds from Handshake message
    87      // [default = 0]
    88      oneof net_read_timeout_present {
    89           int32 net_read_timeout = 3; // in seconds
    90      }
    91      // [default = 0];
    92      oneof net_write_timeout_present {
    93          int32 net_write_timeout = 4; // in seconds
    94      }
    95      string destination = 5;
    96      string client_id = 6;
    97      string filter = 7;
    98      int64 start_timestamp = 8;
    99  }
   100  
   101  message Ack {
   102      //[default = 0]
   103      oneof error_code_present {
   104          int32 error_code = 1;
   105      }
   106      string error_message = 2; // if something like compression is not supported, erorr_message will tell about it.
   107  }
   108  
   109  message ClientAck {
   110      string destination = 1;
   111      string client_id = 2;
   112      int64 batch_id = 3;
   113  }
   114  
   115  // subscription
   116  message Sub {
   117      string destination = 1;
   118      string client_id = 2;
   119      string filter = 7;
   120  }
   121  
   122  // Unsubscription
   123  message Unsub {
   124      string destination = 1;
   125      string client_id = 2;
   126      string filter = 7;
   127  }
   128  
   129  //  PullRequest
   130  message Get {
   131      string destination = 1;
   132      string client_id = 2;
   133      int32 fetch_size = 3;
   134      //[default = -1]
   135      oneof timeout_present {
   136          int64 timeout = 4; // 默认-1时代表不控制
   137      }
   138      //[default = 2]
   139      oneof unit_present {
   140          int32 unit = 5;// 数字类型,0:纳秒,1:毫秒,2:微秒,3:秒,4:分钟,5:小时,6:天
   141      }
   142      //[default = false]
   143      oneof auto_ack_present {
   144          bool auto_ack = 6; // 是否自动ack
   145      }
   146  
   147  }
   148  
   149  //
   150  message Messages {
   151  	int64 batch_id = 1;
   152      repeated bytes messages = 2;
   153  }
   154  
   155  // TBD when new packets are required
   156  message Dump{
   157      string journal = 1;
   158      int64  position = 2;
   159      // [default = 0]
   160      oneof timestamp_present {
   161          int64 timestamp = 3;
   162      }
   163  
   164  }
   165  
   166  message ClientRollback{
   167      string destination = 1;
   168      string client_id = 2;
   169      int64 batch_id = 3;
   170  }