mq.proto 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. syntax = "proto3";
  2. package messaging_pb;
  3. option go_package = "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb";
  4. option java_package = "seaweedfs.mq";
  5. option java_outer_classname = "MessagQueueProto";
  6. //////////////////////////////////////////////////
  7. service SeaweedMessaging {
  8. // control plane
  9. rpc FindBrokerLeader (FindBrokerLeaderRequest) returns (FindBrokerLeaderResponse) {
  10. }
  11. rpc AssignSegmentBrokers (AssignSegmentBrokersRequest) returns (AssignSegmentBrokersResponse) {
  12. }
  13. rpc CheckSegmentStatus (CheckSegmentStatusRequest) returns (CheckSegmentStatusResponse) {
  14. }
  15. rpc CheckBrokerLoad (CheckBrokerLoadRequest) returns (CheckBrokerLoadResponse) {
  16. }
  17. // control plane for balancer
  18. rpc ConnectToBalancer (stream ConnectToBalancerRequest) returns (stream ConnectToBalancerResponse) {
  19. }
  20. // control plane for topic partitions
  21. rpc LookupTopicBrokers (LookupTopicBrokersRequest) returns (LookupTopicBrokersResponse) {
  22. }
  23. // a pub client will call this to get the topic partitions assignment
  24. rpc RequestTopicPartitions (RequestTopicPartitionsRequest) returns (RequestTopicPartitionsResponse) {
  25. }
  26. rpc AssignTopicPartitions (AssignTopicPartitionsRequest) returns (AssignTopicPartitionsResponse) {
  27. }
  28. rpc CheckTopicPartitionsStatus (CheckTopicPartitionsStatusRequest) returns (CheckTopicPartitionsStatusResponse) {
  29. }
  30. // data plane
  31. rpc Publish (stream PublishRequest) returns (stream PublishResponse) {
  32. }
  33. rpc Subscribe (SubscribeRequest) returns (stream SubscribeResponse) {
  34. }
  35. }
  36. //////////////////////////////////////////////////
  37. message SegmentInfo {
  38. Segment segment = 1;
  39. int64 start_ts_ns = 2;
  40. repeated string brokers = 3;
  41. int64 stop_ts_ns = 4;
  42. repeated int32 previous_segments = 5;
  43. repeated int32 next_segments = 6;
  44. }
  45. //////////////////////////////////////////////////
  46. message FindBrokerLeaderRequest {
  47. string filer_group = 1;
  48. }
  49. message FindBrokerLeaderResponse {
  50. string broker = 1;
  51. }
  52. message Topic {
  53. string namespace = 1;
  54. string name = 2;
  55. }
  56. message Partition {
  57. int32 ring_size = 1;
  58. int32 range_start = 2;
  59. int32 range_stop = 3;
  60. }
  61. message Segment {
  62. string namespace = 1;
  63. string topic = 2;
  64. int32 id = 3;
  65. Partition partition = 4;
  66. }
  67. message AssignSegmentBrokersRequest {
  68. Segment segment = 1;
  69. }
  70. message AssignSegmentBrokersResponse {
  71. repeated string brokers = 1;
  72. }
  73. message CheckSegmentStatusRequest {
  74. Segment segment = 1;
  75. }
  76. message CheckSegmentStatusResponse {
  77. bool is_active = 1;
  78. }
  79. message CheckBrokerLoadRequest {
  80. }
  81. message CheckBrokerLoadResponse {
  82. int64 message_count = 1;
  83. int64 bytes_count = 2;
  84. }
  85. //////////////////////////////////////////////////
  86. message BrokerStats {
  87. int32 cpu_usage_percent = 1;
  88. map<string, TopicPartitionStats> stats = 2;
  89. }
  90. message TopicPartitionStats {
  91. Topic topic = 1;
  92. Partition partition = 2;
  93. int32 consumer_count = 3;
  94. bool is_leader = 4;
  95. }
  96. message ConnectToBalancerRequest {
  97. message InitMessage {
  98. string broker = 1;
  99. }
  100. oneof message {
  101. InitMessage init = 1;
  102. BrokerStats stats = 2;
  103. }
  104. }
  105. message ConnectToBalancerResponse {
  106. }
  107. //////////////////////////////////////////////////
  108. message LookupTopicBrokersRequest {
  109. Topic topic = 1;
  110. bool is_for_publish = 2;
  111. }
  112. message LookupTopicBrokersResponse {
  113. Topic topic = 1;
  114. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  115. }
  116. message BrokerPartitionAssignment {
  117. Partition partition = 1;
  118. string leader_broker = 2;
  119. repeated string follower_brokers = 3;
  120. }
  121. message RequestTopicPartitionsRequest {
  122. Topic topic = 1;
  123. int32 partition_count = 2;
  124. }
  125. message RequestTopicPartitionsResponse {
  126. repeated BrokerPartitionAssignment broker_partition_assignments = 1;
  127. }
  128. message AssignTopicPartitionsRequest {
  129. Topic topic = 1;
  130. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  131. bool is_leader = 3;
  132. }
  133. message AssignTopicPartitionsResponse {
  134. }
  135. message CheckTopicPartitionsStatusRequest {
  136. string namespace = 1;
  137. string topic = 2;
  138. BrokerPartitionAssignment broker_partition_assignment = 3;
  139. bool should_cancel_if_not_match = 4;
  140. }
  141. message CheckTopicPartitionsStatusResponse {
  142. repeated BrokerPartitionAssignment broker_partition_assignments = 1;
  143. }
  144. //////////////////////////////////////////////////
  145. message DataMessage {
  146. bytes key = 1;
  147. bytes value = 2;
  148. }
  149. message PublishRequest {
  150. message InitMessage {
  151. Topic topic = 1;
  152. Partition partition = 2;
  153. int32 ack_interval = 3;
  154. }
  155. oneof message {
  156. InitMessage init = 1;
  157. DataMessage data = 2;
  158. }
  159. int64 sequence = 3;
  160. }
  161. message PublishResponse {
  162. int64 ack_sequence = 1;
  163. string error = 2;
  164. string redirect_to_broker = 3;
  165. }
  166. message SubscribeRequest {
  167. message Consumer {
  168. string consumer_group = 1;
  169. string consumer_id = 2;
  170. string client_id = 3;
  171. }
  172. message Cursor {
  173. Topic topic = 1;
  174. Partition partition = 2;
  175. oneof offset {
  176. int64 start_offset = 3;
  177. int64 start_timestamp_ns = 4;
  178. }
  179. string filter = 5;
  180. }
  181. Consumer consumer = 1;
  182. Cursor cursor = 2;
  183. }
  184. message SubscribeResponse {
  185. message CtrlMessage {
  186. string error = 1;
  187. string redirect_to_broker = 2;
  188. }
  189. oneof message {
  190. CtrlMessage ctrl = 1;
  191. DataMessage data = 2;
  192. }
  193. }