cursor.proto 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. option cc_enable_arenas = true;
  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 = "CursorProto";
  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. // The service that a subscriber client application uses to manage committed
  30. // cursors while receiving messsages. A cursor represents a subscriber's
  31. // progress within a topic partition for a given subscription.
  32. service CursorService {
  33. option (google.api.default_host) = "pubsublite.googleapis.com";
  34. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  35. // Establishes a stream with the server for managing committed cursors.
  36. rpc StreamingCommitCursor(stream StreamingCommitCursorRequest) returns (stream StreamingCommitCursorResponse) {
  37. }
  38. // Updates the committed cursor.
  39. rpc CommitCursor(CommitCursorRequest) returns (CommitCursorResponse) {
  40. option (google.api.http) = {
  41. post: "/v1/cursor/{subscription=projects/*/locations/*/subscriptions/*}:commitCursor"
  42. body: "*"
  43. };
  44. }
  45. // Returns all committed cursor information for a subscription.
  46. rpc ListPartitionCursors(ListPartitionCursorsRequest) returns (ListPartitionCursorsResponse) {
  47. option (google.api.http) = {
  48. get: "/v1/cursor/{parent=projects/*/locations/*/subscriptions/*}/cursors"
  49. };
  50. option (google.api.method_signature) = "parent";
  51. }
  52. }
  53. // The first streaming request that must be sent on a newly-opened stream. The
  54. // client must wait for the response before sending subsequent requests on the
  55. // stream.
  56. message InitialCommitCursorRequest {
  57. // The subscription for which to manage committed cursors.
  58. string subscription = 1;
  59. // The partition for which to manage committed cursors. Partitions are zero
  60. // indexed, so `partition` must be in the range [0, topic.num_partitions).
  61. int64 partition = 2;
  62. }
  63. // Response to an InitialCommitCursorRequest.
  64. message InitialCommitCursorResponse {
  65. }
  66. // Streaming request to update the committed cursor. Subsequent
  67. // SequencedCommitCursorRequests override outstanding ones.
  68. message SequencedCommitCursorRequest {
  69. // The new value for the committed cursor.
  70. Cursor cursor = 1;
  71. }
  72. // Response to a SequencedCommitCursorRequest.
  73. message SequencedCommitCursorResponse {
  74. // The number of outstanding SequencedCommitCursorRequests acknowledged by
  75. // this response. Note that SequencedCommitCursorRequests are acknowledged in
  76. // the order that they are received.
  77. int64 acknowledged_commits = 1;
  78. }
  79. // A request sent from the client to the server on a stream.
  80. message StreamingCommitCursorRequest {
  81. // The type of request this is.
  82. oneof request {
  83. // Initial request on the stream.
  84. InitialCommitCursorRequest initial = 1;
  85. // Request to commit a new cursor value.
  86. SequencedCommitCursorRequest commit = 2;
  87. }
  88. }
  89. // Response to a StreamingCommitCursorRequest.
  90. message StreamingCommitCursorResponse {
  91. // The type of request this is.
  92. oneof request {
  93. // Initial response on the stream.
  94. InitialCommitCursorResponse initial = 1;
  95. // Response to committing a new cursor value.
  96. SequencedCommitCursorResponse commit = 2;
  97. }
  98. }
  99. // Request for CommitCursor.
  100. message CommitCursorRequest {
  101. // The subscription for which to update the cursor.
  102. string subscription = 1;
  103. // The partition for which to update the cursor. Partitions are zero indexed,
  104. // so `partition` must be in the range [0, topic.num_partitions).
  105. int64 partition = 2;
  106. // The new value for the committed cursor.
  107. Cursor cursor = 3;
  108. }
  109. // Response for CommitCursor.
  110. message CommitCursorResponse {
  111. }
  112. // Request for ListPartitionCursors.
  113. message ListPartitionCursorsRequest {
  114. // Required. The subscription for which to retrieve cursors.
  115. // Structured like
  116. // `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.
  117. string parent = 1 [
  118. (google.api.field_behavior) = REQUIRED,
  119. (google.api.resource_reference) = {
  120. type: "pubsublite.googleapis.com/Subscription"
  121. }
  122. ];
  123. // The maximum number of cursors to return. The service may return fewer than
  124. // this value.
  125. // If unset or zero, all cursors for the parent will be returned.
  126. int32 page_size = 2;
  127. // A page token, received from a previous `ListPartitionCursors` call.
  128. // Provide this to retrieve the subsequent page.
  129. //
  130. // When paginating, all other parameters provided to `ListPartitionCursors`
  131. // must match the call that provided the page token.
  132. string page_token = 3;
  133. }
  134. // A pair of a Cursor and the partition it is for.
  135. message PartitionCursor {
  136. // The partition this is for.
  137. int64 partition = 1;
  138. // The value of the cursor.
  139. Cursor cursor = 2;
  140. }
  141. // Response for ListPartitionCursors
  142. message ListPartitionCursorsResponse {
  143. // The partition cursors from this request.
  144. repeated PartitionCursor partition_cursors = 1;
  145. // A token, which can be sent as `page_token` to retrieve the next page.
  146. // If this field is omitted, there are no subsequent pages.
  147. string next_page_token = 2;
  148. }