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.

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