mq.proto 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. syntax = "proto3";
  2. package messaging_pb;
  3. import "schema.proto";
  4. option go_package = "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb";
  5. option java_package = "seaweedfs.mq";
  6. option java_outer_classname = "MessageQueueProto";
  7. //////////////////////////////////////////////////
  8. service SeaweedMessaging {
  9. // control plane
  10. rpc FindBrokerLeader (FindBrokerLeaderRequest) returns (FindBrokerLeaderResponse) {
  11. }
  12. // control plane for balancer
  13. rpc PublisherToPubBalancer (stream PublisherToPubBalancerRequest) returns (stream PublisherToPubBalancerResponse) {
  14. }
  15. rpc BalanceTopics (BalanceTopicsRequest) returns (BalanceTopicsResponse) {
  16. }
  17. // control plane for topic partitions
  18. rpc ListTopics (ListTopicsRequest) returns (ListTopicsResponse) {
  19. }
  20. rpc ConfigureTopic (ConfigureTopicRequest) returns (ConfigureTopicResponse) {
  21. }
  22. rpc LookupTopicBrokers (LookupTopicBrokersRequest) returns (LookupTopicBrokersResponse) {
  23. }
  24. // invoked by the balancer, running on each broker
  25. rpc AssignTopicPartitions (AssignTopicPartitionsRequest) returns (AssignTopicPartitionsResponse) {
  26. }
  27. rpc ClosePublishers(ClosePublishersRequest) returns (ClosePublishersResponse) {
  28. }
  29. rpc CloseSubscribers(CloseSubscribersRequest) returns (CloseSubscribersResponse) {
  30. }
  31. // subscriber connects to broker balancer, which coordinates with the subscribers
  32. rpc SubscriberToSubCoordinator (stream SubscriberToSubCoordinatorRequest) returns (stream SubscriberToSubCoordinatorResponse) {
  33. }
  34. // data plane for each topic partition
  35. rpc PublishMessage (stream PublishMessageRequest) returns (stream PublishMessageResponse) {
  36. }
  37. rpc SubscribeMessage (stream SubscribeMessageRequest) returns (stream SubscribeMessageResponse) {
  38. }
  39. // The lead broker asks a follower broker to follow itself
  40. rpc PublishFollowMe (stream PublishFollowMeRequest) returns (stream PublishFollowMeResponse) {
  41. }
  42. rpc SubscribeFollowMe (stream SubscribeFollowMeRequest) returns (SubscribeFollowMeResponse) {
  43. }
  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. int64 unix_time_ns = 4;
  61. }
  62. message Offset {
  63. Topic topic = 1;
  64. repeated PartitionOffset partition_offsets = 2;
  65. }
  66. enum PartitionOffsetStartType {
  67. EARLIEST = 0;
  68. EARLIEST_IN_MEMORY = 1;
  69. LATEST = 2;
  70. }
  71. message PartitionOffset {
  72. Partition partition = 1;
  73. int64 start_ts_ns = 2;
  74. int64 stop_ts_ns = 3;
  75. PartitionOffsetStartType start_type = 4;
  76. }
  77. //////////////////////////////////////////////////
  78. message BrokerStats {
  79. int32 cpu_usage_percent = 1;
  80. map<string, TopicPartitionStats> stats = 2;
  81. }
  82. message TopicPartitionStats {
  83. Topic topic = 1;
  84. Partition partition = 2;
  85. int32 publisher_count = 3;
  86. int32 subscriber_count = 4;
  87. string follower = 5;
  88. }
  89. message PublisherToPubBalancerRequest {
  90. message InitMessage {
  91. string broker = 1;
  92. }
  93. oneof message {
  94. InitMessage init = 1;
  95. BrokerStats stats = 2;
  96. }
  97. }
  98. message PublisherToPubBalancerResponse {
  99. }
  100. message BalanceTopicsRequest {
  101. }
  102. message BalanceTopicsResponse {
  103. }
  104. //////////////////////////////////////////////////
  105. message ConfigureTopicRequest {
  106. Topic topic = 1;
  107. int32 partition_count = 2;
  108. schema_pb.RecordType record_type = 3;
  109. }
  110. message ConfigureTopicResponse {
  111. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  112. schema_pb.RecordType record_type = 3;
  113. }
  114. message ListTopicsRequest {
  115. }
  116. message ListTopicsResponse {
  117. repeated Topic topics = 1;
  118. }
  119. message LookupTopicBrokersRequest {
  120. Topic topic = 1;
  121. }
  122. message LookupTopicBrokersResponse {
  123. Topic topic = 1;
  124. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  125. }
  126. message BrokerPartitionAssignment {
  127. Partition partition = 1;
  128. string leader_broker = 2;
  129. string follower_broker = 3;
  130. }
  131. message AssignTopicPartitionsRequest {
  132. Topic topic = 1;
  133. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  134. bool is_leader = 3;
  135. bool is_draining = 4;
  136. }
  137. message AssignTopicPartitionsResponse {
  138. }
  139. message SubscriberToSubCoordinatorRequest {
  140. message InitMessage {
  141. string consumer_group = 1;
  142. string consumer_group_instance_id = 2;
  143. Topic topic = 3;
  144. // The consumer group instance will be assigned at most max_partition_count partitions.
  145. // If the number of partitions is less than the sum of max_partition_count,
  146. // the consumer group instance may be assigned partitions less than max_partition_count.
  147. // Default is 1.
  148. int32 max_partition_count = 4;
  149. // If consumer group instance changes, wait for rebalance_seconds before reassigning partitions
  150. // Exception: if adding a new consumer group instance and sum of max_partition_count equals the number of partitions,
  151. // the rebalance will happen immediately.
  152. // Default is 10 seconds.
  153. int32 rebalance_seconds = 5;
  154. }
  155. message AckUnAssignmentMessage {
  156. Partition partition = 1;
  157. }
  158. message AckAssignmentMessage {
  159. Partition partition = 1;
  160. }
  161. oneof message {
  162. InitMessage init = 1;
  163. AckAssignmentMessage ack_assignment = 2;
  164. AckUnAssignmentMessage ack_un_assignment = 3;
  165. }
  166. }
  167. message SubscriberToSubCoordinatorResponse {
  168. message Assignment {
  169. BrokerPartitionAssignment partition_assignment = 1;
  170. }
  171. message UnAssignment {
  172. Partition partition = 1;
  173. }
  174. oneof message {
  175. Assignment assignment = 1;
  176. UnAssignment un_assignment = 2;
  177. }
  178. }
  179. //////////////////////////////////////////////////
  180. message ControlMessage {
  181. bool is_close = 1;
  182. string publisher_name = 2;
  183. }
  184. message DataMessage {
  185. bytes key = 1;
  186. bytes value = 2;
  187. int64 ts_ns = 3;
  188. ControlMessage ctrl = 4;
  189. }
  190. message PublishMessageRequest {
  191. message InitMessage {
  192. Topic topic = 1;
  193. Partition partition = 2;
  194. int32 ack_interval = 3;
  195. string follower_broker = 4;
  196. string publisher_name = 5; // for debugging
  197. }
  198. oneof message {
  199. InitMessage init = 1;
  200. DataMessage data = 2;
  201. }
  202. }
  203. message PublishMessageResponse {
  204. int64 ack_sequence = 1;
  205. string error = 2;
  206. bool should_close = 3;
  207. }
  208. message PublishFollowMeRequest {
  209. message InitMessage {
  210. Topic topic = 1;
  211. Partition partition = 2;
  212. }
  213. message FlushMessage {
  214. int64 ts_ns = 1;
  215. }
  216. message CloseMessage {
  217. }
  218. oneof message {
  219. InitMessage init = 1;
  220. DataMessage data = 2;
  221. FlushMessage flush = 3;
  222. CloseMessage close = 4;
  223. }
  224. }
  225. message PublishFollowMeResponse {
  226. int64 ack_ts_ns = 1;
  227. }
  228. message SubscribeMessageRequest {
  229. message InitMessage {
  230. string consumer_group = 1;
  231. string consumer_id = 2;
  232. string client_id = 3;
  233. Topic topic = 4;
  234. PartitionOffset partition_offset = 5;
  235. string filter = 6;
  236. string follower_broker = 7;
  237. int32 concurrency = 8;
  238. }
  239. message AckMessage {
  240. int64 sequence = 1;
  241. bytes key = 2;
  242. }
  243. oneof message {
  244. InitMessage init = 1;
  245. AckMessage ack = 2;
  246. }
  247. }
  248. message SubscribeMessageResponse {
  249. message SubscribeCtrlMessage {
  250. string error = 1;
  251. bool is_end_of_stream = 2;
  252. bool is_end_of_topic = 3;
  253. }
  254. oneof message {
  255. SubscribeCtrlMessage ctrl = 1;
  256. DataMessage data = 2;
  257. }
  258. }
  259. message SubscribeFollowMeRequest {
  260. message InitMessage {
  261. Topic topic = 1;
  262. Partition partition = 2;
  263. string consumer_group = 3;
  264. }
  265. message AckMessage {
  266. int64 ts_ns = 1;
  267. }
  268. message CloseMessage {
  269. }
  270. oneof message {
  271. InitMessage init = 1;
  272. AckMessage ack = 2;
  273. CloseMessage close = 3;
  274. }
  275. }
  276. message SubscribeFollowMeResponse {
  277. int64 ack_ts_ns = 1;
  278. }
  279. message ClosePublishersRequest {
  280. Topic topic = 1;
  281. int64 unix_time_ns = 2;
  282. }
  283. message ClosePublishersResponse {
  284. }
  285. message CloseSubscribersRequest {
  286. Topic topic = 1;
  287. int64 unix_time_ns = 2;
  288. }
  289. message CloseSubscribersResponse {
  290. }