mq.proto 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 (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. }
  43. //////////////////////////////////////////////////
  44. message FindBrokerLeaderRequest {
  45. string filer_group = 1;
  46. }
  47. message FindBrokerLeaderResponse {
  48. string broker = 1;
  49. }
  50. message Topic {
  51. string namespace = 1;
  52. string name = 2;
  53. }
  54. message Partition {
  55. int32 ring_size = 1;
  56. int32 range_start = 2;
  57. int32 range_stop = 3;
  58. int64 unix_time_ns = 4;
  59. }
  60. message Offset {
  61. Topic topic = 1;
  62. repeated PartitionOffset partition_offsets = 2;
  63. }
  64. enum PartitionOffsetStartType {
  65. EARLIEST = 0;
  66. EARLIEST_IN_MEMORY = 1;
  67. LATEST = 2;
  68. }
  69. message PartitionOffset {
  70. Partition partition = 1;
  71. int64 start_ts_ns = 2;
  72. int64 stop_ts_ns = 3;
  73. PartitionOffsetStartType start_type = 4;
  74. }
  75. //////////////////////////////////////////////////
  76. message BrokerStats {
  77. int32 cpu_usage_percent = 1;
  78. map<string, TopicPartitionStats> stats = 2;
  79. }
  80. message TopicPartitionStats {
  81. Topic topic = 1;
  82. Partition partition = 2;
  83. int32 publisher_count = 3;
  84. int32 subscriber_count = 4;
  85. }
  86. message PublisherToPubBalancerRequest {
  87. message InitMessage {
  88. string broker = 1;
  89. }
  90. oneof message {
  91. InitMessage init = 1;
  92. BrokerStats stats = 2;
  93. }
  94. }
  95. message PublisherToPubBalancerResponse {
  96. }
  97. message BalanceTopicsRequest {
  98. }
  99. message BalanceTopicsResponse {
  100. }
  101. //////////////////////////////////////////////////
  102. message ConfigureTopicRequest {
  103. Topic topic = 1;
  104. int32 partition_count = 2;
  105. schema_pb.RecordType record_type = 3;
  106. }
  107. message ConfigureTopicResponse {
  108. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  109. schema_pb.RecordType record_type = 3;
  110. }
  111. message ListTopicsRequest {
  112. }
  113. message ListTopicsResponse {
  114. repeated Topic topics = 1;
  115. }
  116. message LookupTopicBrokersRequest {
  117. Topic topic = 1;
  118. }
  119. message LookupTopicBrokersResponse {
  120. Topic topic = 1;
  121. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  122. }
  123. message BrokerPartitionAssignment {
  124. Partition partition = 1;
  125. string leader_broker = 2;
  126. repeated string follower_brokers = 3;
  127. }
  128. message AssignTopicPartitionsRequest {
  129. Topic topic = 1;
  130. repeated BrokerPartitionAssignment broker_partition_assignments = 2;
  131. bool is_leader = 3;
  132. bool is_draining = 4;
  133. }
  134. message AssignTopicPartitionsResponse {
  135. }
  136. message SubscriberToSubCoordinatorRequest {
  137. message InitMessage {
  138. string consumer_group = 1;
  139. string consumer_group_instance_id = 2;
  140. Topic topic = 3;
  141. }
  142. message AckMessage {
  143. Partition partition = 1;
  144. int64 ts_ns = 2;
  145. }
  146. oneof message {
  147. InitMessage init = 1;
  148. AckMessage ack = 2;
  149. }
  150. }
  151. message SubscriberToSubCoordinatorResponse {
  152. message Assignment {
  153. int64 generation = 1;
  154. repeated BrokerPartitionAssignment partition_assignments = 2;
  155. }
  156. oneof message {
  157. Assignment assignment = 1;
  158. }
  159. }
  160. //////////////////////////////////////////////////
  161. message ControlMessage {
  162. bool is_close = 1;
  163. }
  164. message DataMessage {
  165. bytes key = 1;
  166. bytes value = 2;
  167. int64 ts_ns = 3;
  168. ControlMessage ctrl = 4;
  169. }
  170. message PublishMessageRequest {
  171. message InitMessage {
  172. Topic topic = 1;
  173. Partition partition = 2;
  174. int32 ack_interval = 3;
  175. repeated string follower_brokers = 4;
  176. string publisher_name = 5; // for debugging
  177. }
  178. oneof message {
  179. InitMessage init = 1;
  180. DataMessage data = 2;
  181. }
  182. int64 sequence = 3;
  183. }
  184. message PublishMessageResponse {
  185. int64 ack_sequence = 1;
  186. string error = 2;
  187. bool should_close = 3;
  188. }
  189. message PublishFollowMeRequest {
  190. message InitMessage {
  191. Topic topic = 1;
  192. Partition partition = 2;
  193. }
  194. message FlushMessage {
  195. int64 ts_ns = 1;
  196. }
  197. message CloseMessage {
  198. }
  199. oneof message {
  200. InitMessage init = 1;
  201. DataMessage data = 2;
  202. FlushMessage flush = 3;
  203. CloseMessage close = 4;
  204. }
  205. }
  206. message PublishFollowMeResponse {
  207. int64 ack_ts_ns = 1;
  208. }
  209. message SubscribeMessageRequest {
  210. message InitMessage {
  211. string consumer_group = 1;
  212. string consumer_id = 2;
  213. string client_id = 3;
  214. Topic topic = 4;
  215. PartitionOffset partition_offset = 5;
  216. string filter = 6;
  217. repeated string follower_brokers = 7;
  218. }
  219. message AckMessage {
  220. int64 sequence = 1;
  221. }
  222. oneof message {
  223. InitMessage init = 1;
  224. AckMessage ack = 2;
  225. }
  226. }
  227. message SubscribeMessageResponse {
  228. message SubscribeCtrlMessage {
  229. string error = 1;
  230. bool is_end_of_stream = 2;
  231. bool is_end_of_topic = 3;
  232. }
  233. oneof message {
  234. SubscribeCtrlMessage ctrl = 1;
  235. DataMessage data = 2;
  236. }
  237. }
  238. message ClosePublishersRequest {
  239. Topic topic = 1;
  240. int64 unix_time_ns = 2;
  241. }
  242. message ClosePublishersResponse {
  243. }
  244. message CloseSubscribersRequest {
  245. Topic topic = 1;
  246. int64 unix_time_ns = 2;
  247. }
  248. message CloseSubscribersResponse {
  249. }