1*d5c09012SAndroid Build Coastguard Worker// Copyright 2022 Google LLC 2*d5c09012SAndroid Build Coastguard Worker// 3*d5c09012SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*d5c09012SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*d5c09012SAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*d5c09012SAndroid Build Coastguard Worker// 7*d5c09012SAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*d5c09012SAndroid Build Coastguard Worker// 9*d5c09012SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*d5c09012SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*d5c09012SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*d5c09012SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*d5c09012SAndroid Build Coastguard Worker// limitations under the License. 14*d5c09012SAndroid Build Coastguard Worker 15*d5c09012SAndroid Build Coastguard Workersyntax = "proto3"; 16*d5c09012SAndroid Build Coastguard Worker 17*d5c09012SAndroid Build Coastguard Workerpackage google.cloud.pubsublite.v1; 18*d5c09012SAndroid Build Coastguard Worker 19*d5c09012SAndroid Build Coastguard Workerimport "google/api/annotations.proto"; 20*d5c09012SAndroid Build Coastguard Workerimport "google/api/client.proto"; 21*d5c09012SAndroid Build Coastguard Workerimport "google/api/field_behavior.proto"; 22*d5c09012SAndroid Build Coastguard Workerimport "google/cloud/pubsublite/v1/common.proto"; 23*d5c09012SAndroid Build Coastguard Worker 24*d5c09012SAndroid Build Coastguard Workeroption cc_enable_arenas = true; 25*d5c09012SAndroid Build Coastguard Workeroption csharp_namespace = "Google.Cloud.PubSubLite.V1"; 26*d5c09012SAndroid Build Coastguard Workeroption go_package = "cloud.google.com/go/pubsublite/apiv1/pubsublitepb;pubsublitepb"; 27*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true; 28*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "SubscriberProto"; 29*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.cloud.pubsublite.proto"; 30*d5c09012SAndroid Build Coastguard Workeroption php_namespace = "Google\\Cloud\\PubSubLite\\V1"; 31*d5c09012SAndroid Build Coastguard Workeroption ruby_package = "Google::Cloud::PubSubLite::V1"; 32*d5c09012SAndroid Build Coastguard Worker 33*d5c09012SAndroid Build Coastguard Worker// The service that a subscriber client application uses to receive messages 34*d5c09012SAndroid Build Coastguard Worker// from subscriptions. 35*d5c09012SAndroid Build Coastguard Workerservice SubscriberService { 36*d5c09012SAndroid Build Coastguard Worker option (google.api.default_host) = "pubsublite.googleapis.com"; 37*d5c09012SAndroid Build Coastguard Worker option (google.api.oauth_scopes) = 38*d5c09012SAndroid Build Coastguard Worker "https://www.googleapis.com/auth/cloud-platform"; 39*d5c09012SAndroid Build Coastguard Worker 40*d5c09012SAndroid Build Coastguard Worker // Establishes a stream with the server for receiving messages. 41*d5c09012SAndroid Build Coastguard Worker rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeResponse) {} 42*d5c09012SAndroid Build Coastguard Worker} 43*d5c09012SAndroid Build Coastguard Worker 44*d5c09012SAndroid Build Coastguard Worker// The service that a subscriber client application uses to determine which 45*d5c09012SAndroid Build Coastguard Worker// partitions it should connect to. 46*d5c09012SAndroid Build Coastguard Workerservice PartitionAssignmentService { 47*d5c09012SAndroid Build Coastguard Worker option (google.api.default_host) = "pubsublite.googleapis.com"; 48*d5c09012SAndroid Build Coastguard Worker option (google.api.oauth_scopes) = 49*d5c09012SAndroid Build Coastguard Worker "https://www.googleapis.com/auth/cloud-platform"; 50*d5c09012SAndroid Build Coastguard Worker 51*d5c09012SAndroid Build Coastguard Worker // Assign partitions for this client to handle for the specified subscription. 52*d5c09012SAndroid Build Coastguard Worker // 53*d5c09012SAndroid Build Coastguard Worker // The client must send an InitialPartitionAssignmentRequest first. 54*d5c09012SAndroid Build Coastguard Worker // The server will then send at most one unacknowledged PartitionAssignment 55*d5c09012SAndroid Build Coastguard Worker // outstanding on the stream at a time. 56*d5c09012SAndroid Build Coastguard Worker // The client should send a PartitionAssignmentAck after updating the 57*d5c09012SAndroid Build Coastguard Worker // partitions it is connected to to reflect the new assignment. 58*d5c09012SAndroid Build Coastguard Worker rpc AssignPartitions(stream PartitionAssignmentRequest) 59*d5c09012SAndroid Build Coastguard Worker returns (stream PartitionAssignment) {} 60*d5c09012SAndroid Build Coastguard Worker} 61*d5c09012SAndroid Build Coastguard Worker 62*d5c09012SAndroid Build Coastguard Worker// The first request that must be sent on a newly-opened stream. The client must 63*d5c09012SAndroid Build Coastguard Worker// wait for the response before sending subsequent requests on the stream. 64*d5c09012SAndroid Build Coastguard Workermessage InitialSubscribeRequest { 65*d5c09012SAndroid Build Coastguard Worker // The subscription from which to receive messages. 66*d5c09012SAndroid Build Coastguard Worker string subscription = 1; 67*d5c09012SAndroid Build Coastguard Worker 68*d5c09012SAndroid Build Coastguard Worker // The partition from which to receive messages. Partitions are zero indexed, 69*d5c09012SAndroid Build Coastguard Worker // so `partition` must be in the range [0, topic.num_partitions). 70*d5c09012SAndroid Build Coastguard Worker int64 partition = 2; 71*d5c09012SAndroid Build Coastguard Worker 72*d5c09012SAndroid Build Coastguard Worker // Optional. Initial target location within the message backlog. If not set, 73*d5c09012SAndroid Build Coastguard Worker // messages will be delivered from the commit cursor for the given 74*d5c09012SAndroid Build Coastguard Worker // subscription and partition. 75*d5c09012SAndroid Build Coastguard Worker SeekRequest initial_location = 4 [(google.api.field_behavior) = OPTIONAL]; 76*d5c09012SAndroid Build Coastguard Worker} 77*d5c09012SAndroid Build Coastguard Worker 78*d5c09012SAndroid Build Coastguard Worker// Response to an InitialSubscribeRequest. 79*d5c09012SAndroid Build Coastguard Workermessage InitialSubscribeResponse { 80*d5c09012SAndroid Build Coastguard Worker // The cursor from which the subscriber will start receiving messages once 81*d5c09012SAndroid Build Coastguard Worker // flow control tokens become available. 82*d5c09012SAndroid Build Coastguard Worker Cursor cursor = 1; 83*d5c09012SAndroid Build Coastguard Worker} 84*d5c09012SAndroid Build Coastguard Worker 85*d5c09012SAndroid Build Coastguard Worker// Request to update the stream's delivery cursor based on the given target. 86*d5c09012SAndroid Build Coastguard Worker// Resets the server available tokens to 0. SeekRequests past head result in 87*d5c09012SAndroid Build Coastguard Worker// stream breakage. 88*d5c09012SAndroid Build Coastguard Worker// 89*d5c09012SAndroid Build Coastguard Worker// SeekRequests may not be sent while another SeekRequest is outstanding (i.e., 90*d5c09012SAndroid Build Coastguard Worker// has not received a SeekResponse) on the same stream. 91*d5c09012SAndroid Build Coastguard Workermessage SeekRequest { 92*d5c09012SAndroid Build Coastguard Worker // A special target in the partition that takes no other parameters. 93*d5c09012SAndroid Build Coastguard Worker enum NamedTarget { 94*d5c09012SAndroid Build Coastguard Worker // Default value. This value is unused. 95*d5c09012SAndroid Build Coastguard Worker NAMED_TARGET_UNSPECIFIED = 0; 96*d5c09012SAndroid Build Coastguard Worker 97*d5c09012SAndroid Build Coastguard Worker // A target corresponding to the most recently published message in the 98*d5c09012SAndroid Build Coastguard Worker // partition. 99*d5c09012SAndroid Build Coastguard Worker HEAD = 1; 100*d5c09012SAndroid Build Coastguard Worker 101*d5c09012SAndroid Build Coastguard Worker // A target corresponding to the committed cursor for the given subscription 102*d5c09012SAndroid Build Coastguard Worker // and topic partition. 103*d5c09012SAndroid Build Coastguard Worker COMMITTED_CURSOR = 2; 104*d5c09012SAndroid Build Coastguard Worker } 105*d5c09012SAndroid Build Coastguard Worker 106*d5c09012SAndroid Build Coastguard Worker // The target to seek to. Must be set. 107*d5c09012SAndroid Build Coastguard Worker oneof target { 108*d5c09012SAndroid Build Coastguard Worker // A named target. 109*d5c09012SAndroid Build Coastguard Worker NamedTarget named_target = 1; 110*d5c09012SAndroid Build Coastguard Worker 111*d5c09012SAndroid Build Coastguard Worker // A target corresponding to the cursor, pointing to anywhere in the 112*d5c09012SAndroid Build Coastguard Worker // topic partition. 113*d5c09012SAndroid Build Coastguard Worker Cursor cursor = 2; 114*d5c09012SAndroid Build Coastguard Worker } 115*d5c09012SAndroid Build Coastguard Worker} 116*d5c09012SAndroid Build Coastguard Worker 117*d5c09012SAndroid Build Coastguard Worker// Response to a SeekRequest. 118*d5c09012SAndroid Build Coastguard Workermessage SeekResponse { 119*d5c09012SAndroid Build Coastguard Worker // The new delivery cursor for the current stream. 120*d5c09012SAndroid Build Coastguard Worker Cursor cursor = 1; 121*d5c09012SAndroid Build Coastguard Worker} 122*d5c09012SAndroid Build Coastguard Worker 123*d5c09012SAndroid Build Coastguard Worker// Request to grant tokens to the server, requesting delivery of messages when 124*d5c09012SAndroid Build Coastguard Worker// they become available. 125*d5c09012SAndroid Build Coastguard Workermessage FlowControlRequest { 126*d5c09012SAndroid Build Coastguard Worker // The number of message tokens to grant. Must be greater than or equal to 0. 127*d5c09012SAndroid Build Coastguard Worker int64 allowed_messages = 1; 128*d5c09012SAndroid Build Coastguard Worker 129*d5c09012SAndroid Build Coastguard Worker // The number of byte tokens to grant. Must be greater than or equal to 0. 130*d5c09012SAndroid Build Coastguard Worker int64 allowed_bytes = 2; 131*d5c09012SAndroid Build Coastguard Worker} 132*d5c09012SAndroid Build Coastguard Worker 133*d5c09012SAndroid Build Coastguard Worker// A request sent from the client to the server on a stream. 134*d5c09012SAndroid Build Coastguard Workermessage SubscribeRequest { 135*d5c09012SAndroid Build Coastguard Worker // The type of request this is. 136*d5c09012SAndroid Build Coastguard Worker oneof request { 137*d5c09012SAndroid Build Coastguard Worker // Initial request on the stream. 138*d5c09012SAndroid Build Coastguard Worker InitialSubscribeRequest initial = 1; 139*d5c09012SAndroid Build Coastguard Worker 140*d5c09012SAndroid Build Coastguard Worker // Request to update the stream's delivery cursor. 141*d5c09012SAndroid Build Coastguard Worker SeekRequest seek = 2; 142*d5c09012SAndroid Build Coastguard Worker 143*d5c09012SAndroid Build Coastguard Worker // Request to grant tokens to the server, 144*d5c09012SAndroid Build Coastguard Worker FlowControlRequest flow_control = 3; 145*d5c09012SAndroid Build Coastguard Worker } 146*d5c09012SAndroid Build Coastguard Worker} 147*d5c09012SAndroid Build Coastguard Worker 148*d5c09012SAndroid Build Coastguard Worker// Response containing a list of messages. Upon delivering a MessageResponse to 149*d5c09012SAndroid Build Coastguard Worker// the client, the server: 150*d5c09012SAndroid Build Coastguard Worker// * Updates the stream's delivery cursor to one greater than the cursor of the 151*d5c09012SAndroid Build Coastguard Worker// last message in the list. 152*d5c09012SAndroid Build Coastguard Worker// * Subtracts the total number of bytes and messages from the tokens available 153*d5c09012SAndroid Build Coastguard Worker// to the server. 154*d5c09012SAndroid Build Coastguard Workermessage MessageResponse { 155*d5c09012SAndroid Build Coastguard Worker // Messages from the topic partition. 156*d5c09012SAndroid Build Coastguard Worker repeated SequencedMessage messages = 1; 157*d5c09012SAndroid Build Coastguard Worker} 158*d5c09012SAndroid Build Coastguard Worker 159*d5c09012SAndroid Build Coastguard Worker// Response to SubscribeRequest. 160*d5c09012SAndroid Build Coastguard Workermessage SubscribeResponse { 161*d5c09012SAndroid Build Coastguard Worker // The type of response this is. 162*d5c09012SAndroid Build Coastguard Worker oneof response { 163*d5c09012SAndroid Build Coastguard Worker // Initial response on the stream. 164*d5c09012SAndroid Build Coastguard Worker InitialSubscribeResponse initial = 1; 165*d5c09012SAndroid Build Coastguard Worker 166*d5c09012SAndroid Build Coastguard Worker // Response to a Seek operation. 167*d5c09012SAndroid Build Coastguard Worker SeekResponse seek = 2; 168*d5c09012SAndroid Build Coastguard Worker 169*d5c09012SAndroid Build Coastguard Worker // Response containing messages from the topic partition. 170*d5c09012SAndroid Build Coastguard Worker MessageResponse messages = 3; 171*d5c09012SAndroid Build Coastguard Worker } 172*d5c09012SAndroid Build Coastguard Worker} 173*d5c09012SAndroid Build Coastguard Worker 174*d5c09012SAndroid Build Coastguard Worker// The first request that must be sent on a newly-opened stream. The client must 175*d5c09012SAndroid Build Coastguard Worker// wait for the response before sending subsequent requests on the stream. 176*d5c09012SAndroid Build Coastguard Workermessage InitialPartitionAssignmentRequest { 177*d5c09012SAndroid Build Coastguard Worker // The subscription name. Structured like: 178*d5c09012SAndroid Build Coastguard Worker // projects/<project number>/locations/<zone name>/subscriptions/<subscription 179*d5c09012SAndroid Build Coastguard Worker // id> 180*d5c09012SAndroid Build Coastguard Worker string subscription = 1; 181*d5c09012SAndroid Build Coastguard Worker 182*d5c09012SAndroid Build Coastguard Worker // An opaque, unique client identifier. This field must be exactly 16 bytes 183*d5c09012SAndroid Build Coastguard Worker // long and is interpreted as an unsigned 128 bit integer. Other size values 184*d5c09012SAndroid Build Coastguard Worker // will be rejected and the stream will be failed with a non-retryable error. 185*d5c09012SAndroid Build Coastguard Worker // 186*d5c09012SAndroid Build Coastguard Worker // This field is large enough to fit a uuid from standard uuid algorithms like 187*d5c09012SAndroid Build Coastguard Worker // uuid1 or uuid4, which should be used to generate this number. The same 188*d5c09012SAndroid Build Coastguard Worker // identifier should be reused following disconnections with retryable stream 189*d5c09012SAndroid Build Coastguard Worker // errors. 190*d5c09012SAndroid Build Coastguard Worker bytes client_id = 2; 191*d5c09012SAndroid Build Coastguard Worker} 192*d5c09012SAndroid Build Coastguard Worker 193*d5c09012SAndroid Build Coastguard Worker// PartitionAssignments should not race with acknowledgements. There 194*d5c09012SAndroid Build Coastguard Worker// should be exactly one unacknowledged PartitionAssignment at a time. If not, 195*d5c09012SAndroid Build Coastguard Worker// the client must break the stream. 196*d5c09012SAndroid Build Coastguard Workermessage PartitionAssignment { 197*d5c09012SAndroid Build Coastguard Worker // The list of partition numbers this subscriber is assigned to. 198*d5c09012SAndroid Build Coastguard Worker repeated int64 partitions = 1; 199*d5c09012SAndroid Build Coastguard Worker} 200*d5c09012SAndroid Build Coastguard Worker 201*d5c09012SAndroid Build Coastguard Worker// Acknowledge receipt and handling of the previous assignment. 202*d5c09012SAndroid Build Coastguard Worker// If not sent within a short period after receiving the assignment, 203*d5c09012SAndroid Build Coastguard Worker// partitions may remain unassigned for a period of time until the 204*d5c09012SAndroid Build Coastguard Worker// client is known to be inactive, after which time the server will break the 205*d5c09012SAndroid Build Coastguard Worker// stream. 206*d5c09012SAndroid Build Coastguard Workermessage PartitionAssignmentAck {} 207*d5c09012SAndroid Build Coastguard Worker 208*d5c09012SAndroid Build Coastguard Worker// A request on the PartitionAssignment stream. 209*d5c09012SAndroid Build Coastguard Workermessage PartitionAssignmentRequest { 210*d5c09012SAndroid Build Coastguard Worker // The type of request this is. 211*d5c09012SAndroid Build Coastguard Worker oneof request { 212*d5c09012SAndroid Build Coastguard Worker // Initial request on the stream. 213*d5c09012SAndroid Build Coastguard Worker InitialPartitionAssignmentRequest initial = 1; 214*d5c09012SAndroid Build Coastguard Worker 215*d5c09012SAndroid Build Coastguard Worker // Acknowledgement of a partition assignment. 216*d5c09012SAndroid Build Coastguard Worker PartitionAssignmentAck ack = 2; 217*d5c09012SAndroid Build Coastguard Worker } 218*d5c09012SAndroid Build Coastguard Worker} 219