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/cloud/pubsublite/v1/common.proto"; 22*d5c09012SAndroid Build Coastguard Worker 23*d5c09012SAndroid Build Coastguard Workeroption cc_enable_arenas = true; 24*d5c09012SAndroid Build Coastguard Workeroption csharp_namespace = "Google.Cloud.PubSubLite.V1"; 25*d5c09012SAndroid Build Coastguard Workeroption go_package = "cloud.google.com/go/pubsublite/apiv1/pubsublitepb;pubsublitepb"; 26*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true; 27*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "PublisherProto"; 28*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.cloud.pubsublite.proto"; 29*d5c09012SAndroid Build Coastguard Workeroption php_namespace = "Google\\Cloud\\PubSubLite\\V1"; 30*d5c09012SAndroid Build Coastguard Workeroption ruby_package = "Google::Cloud::PubSubLite::V1"; 31*d5c09012SAndroid Build Coastguard Worker 32*d5c09012SAndroid Build Coastguard Worker// The service that a publisher client application uses to publish messages to 33*d5c09012SAndroid Build Coastguard Worker// topics. Published messages are retained by the service for the duration of 34*d5c09012SAndroid Build Coastguard Worker// the retention period configured for the respective topic, and are delivered 35*d5c09012SAndroid Build Coastguard Worker// to subscriber clients upon request (via the `SubscriberService`). 36*d5c09012SAndroid Build Coastguard Workerservice PublisherService { 37*d5c09012SAndroid Build Coastguard Worker option (google.api.default_host) = "pubsublite.googleapis.com"; 38*d5c09012SAndroid Build Coastguard Worker option (google.api.oauth_scopes) = 39*d5c09012SAndroid Build Coastguard Worker "https://www.googleapis.com/auth/cloud-platform"; 40*d5c09012SAndroid Build Coastguard Worker 41*d5c09012SAndroid Build Coastguard Worker // Establishes a stream with the server for publishing messages. Once the 42*d5c09012SAndroid Build Coastguard Worker // stream is initialized, the client publishes messages by sending publish 43*d5c09012SAndroid Build Coastguard Worker // requests on the stream. The server responds with a PublishResponse for each 44*d5c09012SAndroid Build Coastguard Worker // PublishRequest sent by the client, in the same order that the requests 45*d5c09012SAndroid Build Coastguard Worker // were sent. Note that multiple PublishRequests can be in flight 46*d5c09012SAndroid Build Coastguard Worker // simultaneously, but they will be processed by the server in the order that 47*d5c09012SAndroid Build Coastguard Worker // they are sent by the client on a given stream. 48*d5c09012SAndroid Build Coastguard Worker rpc Publish(stream PublishRequest) returns (stream PublishResponse) {} 49*d5c09012SAndroid Build Coastguard Worker} 50*d5c09012SAndroid Build Coastguard Worker 51*d5c09012SAndroid Build Coastguard Worker// The first request that must be sent on a newly-opened stream. 52*d5c09012SAndroid Build Coastguard Workermessage InitialPublishRequest { 53*d5c09012SAndroid Build Coastguard Worker // The topic to which messages will be written. 54*d5c09012SAndroid Build Coastguard Worker string topic = 1; 55*d5c09012SAndroid Build Coastguard Worker 56*d5c09012SAndroid Build Coastguard Worker // The partition within the topic to which messages will be written. 57*d5c09012SAndroid Build Coastguard Worker // Partitions are zero indexed, so `partition` must be in the range [0, 58*d5c09012SAndroid Build Coastguard Worker // topic.num_partitions). 59*d5c09012SAndroid Build Coastguard Worker int64 partition = 2; 60*d5c09012SAndroid Build Coastguard Worker 61*d5c09012SAndroid Build Coastguard Worker // Unique identifier for a publisher client. If set, enables publish 62*d5c09012SAndroid Build Coastguard Worker // idempotency within a publisher client session. 63*d5c09012SAndroid Build Coastguard Worker // 64*d5c09012SAndroid Build Coastguard Worker // The length of this field must be exactly 16 bytes long and should be 65*d5c09012SAndroid Build Coastguard Worker // populated with a 128 bit uuid, generated by standard uuid algorithms like 66*d5c09012SAndroid Build Coastguard Worker // uuid1 or uuid4. The same identifier should be reused following 67*d5c09012SAndroid Build Coastguard Worker // disconnections with retryable stream errors. 68*d5c09012SAndroid Build Coastguard Worker bytes client_id = 3; 69*d5c09012SAndroid Build Coastguard Worker} 70*d5c09012SAndroid Build Coastguard Worker 71*d5c09012SAndroid Build Coastguard Worker// Response to an InitialPublishRequest. 72*d5c09012SAndroid Build Coastguard Workermessage InitialPublishResponse {} 73*d5c09012SAndroid Build Coastguard Worker 74*d5c09012SAndroid Build Coastguard Worker// Request to publish messages to the topic. 75*d5c09012SAndroid Build Coastguard Workermessage MessagePublishRequest { 76*d5c09012SAndroid Build Coastguard Worker // The messages to publish. 77*d5c09012SAndroid Build Coastguard Worker repeated PubSubMessage messages = 1; 78*d5c09012SAndroid Build Coastguard Worker 79*d5c09012SAndroid Build Coastguard Worker // The sequence number corresponding to the first message in `messages`. 80*d5c09012SAndroid Build Coastguard Worker // Messages within a batch are ordered and the sequence numbers of all 81*d5c09012SAndroid Build Coastguard Worker // subsequent messages in the batch are assumed to be incremental. 82*d5c09012SAndroid Build Coastguard Worker // 83*d5c09012SAndroid Build Coastguard Worker // Sequence numbers are assigned at the message level and the first message 84*d5c09012SAndroid Build Coastguard Worker // published in a publisher client session must have a sequence number of 0. 85*d5c09012SAndroid Build Coastguard Worker // All messages must have contiguous sequence numbers, which uniquely identify 86*d5c09012SAndroid Build Coastguard Worker // the messages accepted by the publisher client. Since messages are ordered, 87*d5c09012SAndroid Build Coastguard Worker // the client only needs to specify the sequence number of the first message 88*d5c09012SAndroid Build Coastguard Worker // in a published batch. The server deduplicates messages with the same 89*d5c09012SAndroid Build Coastguard Worker // sequence number from the same publisher `client_id`. 90*d5c09012SAndroid Build Coastguard Worker int64 first_sequence_number = 2; 91*d5c09012SAndroid Build Coastguard Worker} 92*d5c09012SAndroid Build Coastguard Worker 93*d5c09012SAndroid Build Coastguard Worker// Response to a MessagePublishRequest. 94*d5c09012SAndroid Build Coastguard Workermessage MessagePublishResponse { 95*d5c09012SAndroid Build Coastguard Worker // Cursors for a subrange of published messages. 96*d5c09012SAndroid Build Coastguard Worker message CursorRange { 97*d5c09012SAndroid Build Coastguard Worker // The cursor of the message at the start index. The cursors for remaining 98*d5c09012SAndroid Build Coastguard Worker // messages up to the end index (exclusive) are sequential. 99*d5c09012SAndroid Build Coastguard Worker Cursor start_cursor = 1; 100*d5c09012SAndroid Build Coastguard Worker 101*d5c09012SAndroid Build Coastguard Worker // Index of the message in the published batch that corresponds to the 102*d5c09012SAndroid Build Coastguard Worker // start cursor. Inclusive. 103*d5c09012SAndroid Build Coastguard Worker int32 start_index = 2; 104*d5c09012SAndroid Build Coastguard Worker 105*d5c09012SAndroid Build Coastguard Worker // Index of the last message in this range. Exclusive. 106*d5c09012SAndroid Build Coastguard Worker int32 end_index = 3; 107*d5c09012SAndroid Build Coastguard Worker } 108*d5c09012SAndroid Build Coastguard Worker 109*d5c09012SAndroid Build Coastguard Worker // The cursor of the first published message in the batch. The cursors for any 110*d5c09012SAndroid Build Coastguard Worker // remaining messages in the batch are guaranteed to be sequential. 111*d5c09012SAndroid Build Coastguard Worker Cursor start_cursor = 1; 112*d5c09012SAndroid Build Coastguard Worker 113*d5c09012SAndroid Build Coastguard Worker // Cursors for messages published in the batch. There will exist multiple 114*d5c09012SAndroid Build Coastguard Worker // ranges when cursors are not contiguous within the batch. 115*d5c09012SAndroid Build Coastguard Worker // 116*d5c09012SAndroid Build Coastguard Worker // The cursor ranges may not account for all messages in the batch when 117*d5c09012SAndroid Build Coastguard Worker // publish idempotency is enabled. A missing range indicates that cursors 118*d5c09012SAndroid Build Coastguard Worker // could not be determined for messages within the range, as they were 119*d5c09012SAndroid Build Coastguard Worker // deduplicated and the necessary data was not available at publish time. 120*d5c09012SAndroid Build Coastguard Worker // These messages will have offsets when received by a subscriber. 121*d5c09012SAndroid Build Coastguard Worker repeated CursorRange cursor_ranges = 2; 122*d5c09012SAndroid Build Coastguard Worker} 123*d5c09012SAndroid Build Coastguard Worker 124*d5c09012SAndroid Build Coastguard Worker// Request sent from the client to the server on a stream. 125*d5c09012SAndroid Build Coastguard Workermessage PublishRequest { 126*d5c09012SAndroid Build Coastguard Worker // The type of request this is. 127*d5c09012SAndroid Build Coastguard Worker oneof request_type { 128*d5c09012SAndroid Build Coastguard Worker // Initial request on the stream. 129*d5c09012SAndroid Build Coastguard Worker InitialPublishRequest initial_request = 1; 130*d5c09012SAndroid Build Coastguard Worker 131*d5c09012SAndroid Build Coastguard Worker // Request to publish messages. 132*d5c09012SAndroid Build Coastguard Worker MessagePublishRequest message_publish_request = 2; 133*d5c09012SAndroid Build Coastguard Worker } 134*d5c09012SAndroid Build Coastguard Worker} 135*d5c09012SAndroid Build Coastguard Worker 136*d5c09012SAndroid Build Coastguard Worker// Response to a PublishRequest. 137*d5c09012SAndroid Build Coastguard Workermessage PublishResponse { 138*d5c09012SAndroid Build Coastguard Worker // The type of response this is. 139*d5c09012SAndroid Build Coastguard Worker oneof response_type { 140*d5c09012SAndroid Build Coastguard Worker // Initial response on the stream. 141*d5c09012SAndroid Build Coastguard Worker InitialPublishResponse initial_response = 1; 142*d5c09012SAndroid Build Coastguard Worker 143*d5c09012SAndroid Build Coastguard Worker // Response to publishing messages. 144*d5c09012SAndroid Build Coastguard Worker MessagePublishResponse message_response = 2; 145*d5c09012SAndroid Build Coastguard Worker } 146*d5c09012SAndroid Build Coastguard Worker} 147