github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/proto/CDCPeerToPeer.proto (about) 1 // Copyright 2021 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 16 package p2p; 17 18 import "gogoproto/gogo.proto"; 19 20 option(gogoproto.sizer_all) = true; 21 // Use generated code to lower performance overhead. 22 option(gogoproto.marshaler_all) = true; 23 option(gogoproto.unmarshaler_all) = true; 24 25 service CDCPeerToPeer { 26 // A bidirectional stream from the sender (client) to the receiver (server) 27 // The send direction is used to carry the serialized payload, and the 28 // reply direction is used to receive ACKs (progress information) from the server. 29 rpc SendMessage(stream MessagePacket) returns (stream SendMessageResponse); 30 } 31 32 // MessageEntry represents a single message. 33 message MessageEntry { 34 // topic is used to separate messages into order-guaranteed logical streams. 35 string topic = 1; 36 37 // serialized payload. The format and schema is defined by the business logic 38 // using the peer-to-peer mechanism. 39 bytes content = 2; 40 41 // monotonically increase. 42 int64 sequence = 3; 43 } 44 45 // Metadata associated with one client-server bidirectional stream. 46 message StreamMeta { 47 // fields required for correctness 48 string sender_id = 1; 49 string receiver_id = 2; 50 int64 epoch = 3; // monotonically increasing between two given node processes. 51 52 // fields required for compatibility check 53 string client_version = 50; 54 55 // fields for metrics, logging, debugging, etc. 56 string sender_advertised_addr = 100; 57 } 58 59 message MessagePacket { 60 StreamMeta meta = 1; 61 62 // multiple messages can be batched. 63 repeated MessageEntry entries = 2; 64 } 65 66 message Ack { 67 string topic = 1; 68 69 // the sequence of an already processed message. 70 // Must be monotonically increasing for a given topic and two given node processes. 71 int64 last_seq = 2; 72 } 73 74 enum ExitReason { 75 UNKNOWN = 0; 76 OK = 1; 77 CONGESTED = 2; 78 CAPTURE_SUICIDE = 3; 79 STALE_CONNECTION = 4; 80 DUPLICATE_CONNECTION = 5; 81 CAPTURE_ID_MISMATCH = 6; 82 } 83 84 message SendMessageResponse { 85 repeated Ack ack = 1; 86 ExitReason exit_reason = 2; 87 string error_message = 3; 88 }