Skip to content

Commit b601f02

Browse files
Google APIscopybara-github
authored andcommitted
feat: Add SeekSubscription and Operations to API
PiperOrigin-RevId: 380660182
1 parent 9250dff commit b601f02

7 files changed

Lines changed: 127 additions & 0 deletions

File tree

google/cloud/pubsublite/v1/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ proto_library(
3333
"//google/api:client_proto",
3434
"//google/api:field_behavior_proto",
3535
"//google/api:resource_proto",
36+
"//google/longrunning:operations_proto",
3637
"@com_google_protobuf//:duration_proto",
3738
"@com_google_protobuf//:empty_proto",
3839
"@com_google_protobuf//:field_mask_proto",
@@ -126,6 +127,7 @@ go_proto_library(
126127
protos = [":pubsublite_proto"],
127128
deps = [
128129
"//google/api:annotations_go_proto",
130+
"//google/longrunning:longrunning_go_proto",
129131
],
130132
)
131133

@@ -137,6 +139,9 @@ go_gapic_library(
137139
service_yaml = "pubsublite_v1.yaml",
138140
deps = [
139141
":pubsublite_go_proto",
142+
"//google/longrunning:longrunning_go_proto",
143+
"@com_google_cloud_go//longrunning:go_default_library",
144+
"@com_google_cloud_go//longrunning/autogen:go_default_library",
140145
"@io_bazel_rules_go//proto/wkt:duration_go_proto",
141146
],
142147
)

google/cloud/pubsublite/v1/admin.proto

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import "google/api/client.proto";
2121
import "google/api/field_behavior.proto";
2222
import "google/api/resource.proto";
2323
import "google/cloud/pubsublite/v1/common.proto";
24+
import "google/longrunning/operations.proto";
2425
import "google/protobuf/empty.proto";
2526
import "google/protobuf/field_mask.proto";
2627
import "google/protobuf/timestamp.proto";
@@ -139,6 +140,38 @@ service AdminService {
139140
option (google.api.method_signature) = "name";
140141
}
141142

143+
// Performs an out-of-band seek for a subscription to a specified target,
144+
// which may be timestamps or named positions within the message backlog.
145+
// Seek translates these targets to cursors for each partition and
146+
// orchestrates subscribers to start consuming messages from these seek
147+
// cursors.
148+
//
149+
// If an operation is returned, the seek has been registered and subscribers
150+
// will eventually receive messages from the seek cursors (i.e. eventual
151+
// consistency), as long as they are using a minimum supported client library
152+
// version and not a system that tracks cursors independently of Pub/Sub Lite
153+
// (e.g. Apache Beam, Dataflow, Spark). The seek operation will fail for
154+
// unsupported clients.
155+
//
156+
// If clients would like to know when subscribers react to the seek (or not),
157+
// they can poll the operation. The seek operation will succeed and complete
158+
// once subscribers are ready to receive messages from the seek cursors for
159+
// all partitions of the topic. This means that the seek operation will not
160+
// complete until all subscribers come online.
161+
//
162+
// If the previous seek operation has not yet completed, it will be aborted
163+
// and the new invocation of seek will supersede it.
164+
rpc SeekSubscription(SeekSubscriptionRequest) returns (google.longrunning.Operation) {
165+
option (google.api.http) = {
166+
post: "/v1/admin/{name=projects/*/locations/*/subscriptions/*}:seek"
167+
body: "*"
168+
};
169+
option (google.longrunning.operation_info) = {
170+
response_type: "SeekSubscriptionResponse"
171+
metadata_type: "OperationMetadata"
172+
};
173+
}
174+
142175
// Creates a new reservation.
143176
rpc CreateReservation(CreateReservationRequest) returns (Reservation) {
144177
option (google.api.http) = {
@@ -421,6 +454,64 @@ message DeleteSubscriptionRequest {
421454
];
422455
}
423456

457+
// Request for SeekSubscription.
458+
message SeekSubscriptionRequest {
459+
// A named position with respect to the message backlog.
460+
enum NamedTarget {
461+
// Unspecified named target. Do not use.
462+
NAMED_TARGET_UNSPECIFIED = 0;
463+
464+
// Seek to the oldest retained message.
465+
TAIL = 1;
466+
467+
// Seek past all recently published messages, skipping the entire message
468+
// backlog.
469+
HEAD = 2;
470+
}
471+
472+
// Required. The name of the subscription to seek.
473+
string name = 1 [
474+
(google.api.field_behavior) = REQUIRED,
475+
(google.api.resource_reference) = {
476+
type: "pubsublite.googleapis.com/Subscription"
477+
}
478+
];
479+
480+
// The target to seek to. Must be set.
481+
oneof target {
482+
// Seek to a named position with respect to the message backlog.
483+
NamedTarget named_target = 2;
484+
485+
// Seek to the first message whose publish or event time is greater than or
486+
// equal to the specified query time. If no such message can be located,
487+
// will seek to the end of the message backlog.
488+
TimeTarget time_target = 3;
489+
}
490+
}
491+
492+
// Response for SeekSubscription long running operation.
493+
message SeekSubscriptionResponse {
494+
495+
}
496+
497+
// Metadata for long running operations.
498+
message OperationMetadata {
499+
// The time the operation was created.
500+
google.protobuf.Timestamp create_time = 1;
501+
502+
// The time the operation finished running. Not set if the operation has not
503+
// completed.
504+
google.protobuf.Timestamp end_time = 2;
505+
506+
// Resource path for the target of the operation. For example, targets of
507+
// seeks are subscription resources, structured like:
508+
// projects/{project_number}/locations/{location}/subscriptions/{subscription_id}
509+
string target = 3;
510+
511+
// Name of the verb executed by the operation.
512+
string verb = 4;
513+
}
514+
424515
// Request for CreateReservation.
425516
message CreateReservationRequest {
426517
// Required. The parent location in which to create the reservation.

google/cloud/pubsublite/v1/common.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package google.cloud.pubsublite.v1;
1919
import "google/api/resource.proto";
2020
import "google/protobuf/duration.proto";
2121
import "google/protobuf/timestamp.proto";
22+
import "google/api/annotations.proto";
2223

2324
option cc_enable_arenas = true;
2425
option csharp_namespace = "Google.Cloud.PubSubLite.V1";

google/cloud/pubsublite/v1/publisher.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ syntax = "proto3";
1717
package google.cloud.pubsublite.v1;
1818

1919
import "google/cloud/pubsublite/v1/common.proto";
20+
import "google/api/annotations.proto";
2021
import "google/api/client.proto";
2122

2223
option cc_enable_arenas = true;

google/cloud/pubsublite/v1/pubsublite_grpc_service_config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
},
1616
{
1717
"service": "google.cloud.pubsublite.v1.TopicStatsService"
18+
},
19+
{
20+
"service": "google.longrunning.Operations",
21+
"method": "GetOperation"
22+
},
23+
{
24+
"service": "google.longrunning.Operations",
25+
"method": "ListOperations"
1826
}
1927
],
2028
"timeout": "600s",

google/cloud/pubsublite/v1/pubsublite_v1.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ apis:
1111
- name: google.cloud.pubsublite.v1.SubscriberService
1212
- name: google.cloud.pubsublite.v1.TopicStatsService
1313

14+
types:
15+
- name: google.cloud.pubsublite.v1.OperationMetadata
16+
- name: google.cloud.pubsublite.v1.SeekSubscriptionResponse
17+
18+
http:
19+
rules:
20+
- selector: google.longrunning.Operations.CancelOperation
21+
post: '/v1/admin/{name=projects/*/locations/*/operations/*}:cancel'
22+
body: '*'
23+
- selector: google.longrunning.Operations.DeleteOperation
24+
delete: '/v1/admin/{name=projects/*/locations/*/operations/*}'
25+
- selector: google.longrunning.Operations.GetOperation
26+
get: '/v1/admin/{name=projects/*/locations/*/operations/*}'
27+
- selector: google.longrunning.Operations.ListOperations
28+
get: '/v1/admin/{name=projects/*/locations/*}/operations'
29+
1430
authentication:
1531
rules:
1632
- selector: 'google.cloud.pubsublite.v1.AdminService.*'
@@ -37,3 +53,7 @@ authentication:
3753
oauth:
3854
canonical_scopes: |-
3955
https://www.googleapis.com/auth/cloud-platform
56+
- selector: 'google.longrunning.Operations.*'
57+
oauth:
58+
canonical_scopes: |-
59+
https://www.googleapis.com/auth/cloud-platform

google/cloud/pubsublite/v1/subscriber.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package google.cloud.pubsublite.v1;
1818

1919
import "google/api/field_behavior.proto";
2020
import "google/cloud/pubsublite/v1/common.proto";
21+
import "google/api/annotations.proto";
2122
import "google/api/client.proto";
2223

2324
option cc_enable_arenas = true;

0 commit comments

Comments
 (0)