mq.proto 6.9 KB

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