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