You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
5.6 KiB

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