topic_stats.proto 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.pubsublite.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/cloud/pubsublite/v1/common.proto";
  21. import "google/protobuf/timestamp.proto";
  22. option csharp_namespace = "Google.Cloud.PubSubLite.V1";
  23. option go_package = "google.golang.org/genproto/googleapis/cloud/pubsublite/v1;pubsublite";
  24. option java_multiple_files = true;
  25. option java_outer_classname = "TopicStatsProto";
  26. option java_package = "com.google.cloud.pubsublite.proto";
  27. option php_namespace = "Google\\Cloud\\PubSubLite\\V1";
  28. option ruby_package = "Google::Cloud::PubSubLite::V1";
  29. // This service allows users to get stats about messages in their topic.
  30. service TopicStatsService {
  31. option (google.api.default_host) = "pubsublite.googleapis.com";
  32. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  33. // Compute statistics about a range of messages in a given topic and
  34. // partition.
  35. rpc ComputeMessageStats(ComputeMessageStatsRequest) returns (ComputeMessageStatsResponse) {
  36. option (google.api.http) = {
  37. post: "/v1/topicStats/{topic=projects/*/locations/*/topics/*}:computeMessageStats"
  38. body: "*"
  39. };
  40. }
  41. // Compute the head cursor for the partition.
  42. // The head cursor's offset is guaranteed to be less than or equal to all
  43. // messages which have not yet been acknowledged as published, and
  44. // greater than the offset of any message whose publish has already
  45. // been acknowledged. It is zero if there have never been messages in the
  46. // partition.
  47. rpc ComputeHeadCursor(ComputeHeadCursorRequest) returns (ComputeHeadCursorResponse) {
  48. option (google.api.http) = {
  49. post: "/v1/topicStats/{topic=projects/*/locations/*/topics/*}:computeHeadCursor"
  50. body: "*"
  51. };
  52. }
  53. // Compute the corresponding cursor for a publish or event time in a topic
  54. // partition.
  55. rpc ComputeTimeCursor(ComputeTimeCursorRequest) returns (ComputeTimeCursorResponse) {
  56. option (google.api.http) = {
  57. post: "/v1/topicStats/{topic=projects/*/locations/*/topics/*}:computeTimeCursor"
  58. body: "*"
  59. };
  60. }
  61. }
  62. // Compute statistics about a range of messages in a given topic and partition.
  63. message ComputeMessageStatsRequest {
  64. // Required. The topic for which we should compute message stats.
  65. string topic = 1 [
  66. (google.api.field_behavior) = REQUIRED,
  67. (google.api.resource_reference) = {
  68. type: "pubsublite.googleapis.com/Topic"
  69. }
  70. ];
  71. // Required. The partition for which we should compute message stats.
  72. int64 partition = 2 [(google.api.field_behavior) = REQUIRED];
  73. // The inclusive start of the range.
  74. Cursor start_cursor = 3;
  75. // The exclusive end of the range. The range is empty if end_cursor <=
  76. // start_cursor. Specifying a start_cursor before the first message and an
  77. // end_cursor after the last message will retrieve all messages.
  78. Cursor end_cursor = 4;
  79. }
  80. // Response containing stats for messages in the requested topic and partition.
  81. message ComputeMessageStatsResponse {
  82. // The count of messages.
  83. int64 message_count = 1;
  84. // The number of quota bytes accounted to these messages.
  85. int64 message_bytes = 2;
  86. // The minimum publish timestamp across these messages. Note that publish
  87. // timestamps within a partition are not guaranteed to be non-decreasing. The
  88. // timestamp will be unset if there are no messages.
  89. google.protobuf.Timestamp minimum_publish_time = 3;
  90. // The minimum event timestamp across these messages. For the purposes of this
  91. // computation, if a message does not have an event time, we use the publish
  92. // time. The timestamp will be unset if there are no messages.
  93. google.protobuf.Timestamp minimum_event_time = 4;
  94. }
  95. // Compute the current head cursor for a partition.
  96. message ComputeHeadCursorRequest {
  97. // Required. The topic for which we should compute the head cursor.
  98. string topic = 1 [
  99. (google.api.field_behavior) = REQUIRED,
  100. (google.api.resource_reference) = {
  101. type: "pubsublite.googleapis.com/Topic"
  102. }
  103. ];
  104. // Required. The partition for which we should compute the head cursor.
  105. int64 partition = 2 [(google.api.field_behavior) = REQUIRED];
  106. }
  107. // Response containing the head cursor for the requested topic and partition.
  108. message ComputeHeadCursorResponse {
  109. // The head cursor.
  110. Cursor head_cursor = 1;
  111. }
  112. // Compute the corresponding cursor for a publish or event time in a topic
  113. // partition.
  114. message ComputeTimeCursorRequest {
  115. // Required. The topic for which we should compute the cursor.
  116. string topic = 1 [
  117. (google.api.field_behavior) = REQUIRED,
  118. (google.api.resource_reference) = {
  119. type: "pubsublite.googleapis.com/Topic"
  120. }
  121. ];
  122. // Required. The partition for which we should compute the cursor.
  123. int64 partition = 2 [(google.api.field_behavior) = REQUIRED];
  124. // Required. The target publish or event time. Specifying a future time will return an
  125. // unset cursor.
  126. TimeTarget target = 3 [(google.api.field_behavior) = REQUIRED];
  127. }
  128. // Response containing the cursor corresponding to a publish or event time in a
  129. // topic partition.
  130. message ComputeTimeCursorResponse {
  131. // If present, the cursor references the first message with time greater than
  132. // or equal to the specified target time. If such a message cannot be found,
  133. // the cursor will be unset (i.e. `cursor` is not present).
  134. Cursor cursor = 1;
  135. }