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/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/protobuf/duration.proto"; 22import "google/protobuf/timestamp.proto"; 23 24option cc_enable_arenas = true; 25option csharp_namespace = "Google.Cloud.PubSubLite.V1"; 26option go_package = "cloud.google.com/go/pubsublite/apiv1/pubsublitepb;pubsublitepb"; 27option java_multiple_files = true; 28option java_outer_classname = "CommonProto"; 29option java_package = "com.google.cloud.pubsublite.proto"; 30option php_namespace = "Google\\Cloud\\PubSubLite\\V1"; 31option ruby_package = "Google::Cloud::PubSubLite::V1"; 32 33// The values associated with a key of an attribute. 34message AttributeValues { 35 // The list of values associated with a key. 36 repeated bytes values = 1; 37} 38 39// A message that is published by publishers and delivered to subscribers. 40message PubSubMessage { 41 // The key used for routing messages to partitions or for compaction (e.g., 42 // keep the last N messages per key). If the key is empty, the message is 43 // routed to an arbitrary partition. 44 bytes key = 1; 45 46 // The payload of the message. 47 bytes data = 2; 48 49 // Optional attributes that can be used for message metadata/headers. 50 map<string, AttributeValues> attributes = 3; 51 52 // An optional, user-specified event time. 53 google.protobuf.Timestamp event_time = 4; 54} 55 56// A cursor that describes the position of a message within a topic partition. 57message Cursor { 58 // The offset of a message within a topic partition. Must be greater than or 59 // equal 0. 60 int64 offset = 1; 61} 62 63// A message that has been stored and sequenced by the Pub/Sub Lite system. 64message SequencedMessage { 65 // The position of a message within the partition where it is stored. 66 Cursor cursor = 1; 67 68 // The time when the message was received by the server when it was first 69 // published. 70 google.protobuf.Timestamp publish_time = 2; 71 72 // The user message. 73 PubSubMessage message = 3; 74 75 // The size in bytes of this message for flow control and quota purposes. 76 int64 size_bytes = 4; 77} 78 79// Metadata about a reservation resource. 80message Reservation { 81 option (google.api.resource) = { 82 type: "pubsublite.googleapis.com/Reservation" 83 pattern: "projects/{project}/locations/{location}/reservations/{reservation}" 84 }; 85 86 // The name of the reservation. 87 // Structured like: 88 // projects/{project_number}/locations/{location}/reservations/{reservation_id} 89 string name = 1; 90 91 // The reserved throughput capacity. Every unit of throughput capacity is 92 // equivalent to 1 MiB/s of published messages or 2 MiB/s of subscribed 93 // messages. 94 // 95 // Any topics which are declared as using capacity from a Reservation will 96 // consume resources from this reservation instead of being charged 97 // individually. 98 int64 throughput_capacity = 2; 99} 100 101// Metadata about a topic resource. 102message Topic { 103 option (google.api.resource) = { 104 type: "pubsublite.googleapis.com/Topic" 105 pattern: "projects/{project}/locations/{location}/topics/{topic}" 106 }; 107 108 // The settings for a topic's partitions. 109 message PartitionConfig { 110 // The throughput capacity configuration for each partition. 111 message Capacity { 112 // Publish throughput capacity per partition in MiB/s. 113 // Must be >= 4 and <= 16. 114 int32 publish_mib_per_sec = 1; 115 116 // Subscribe throughput capacity per partition in MiB/s. 117 // Must be >= 4 and <= 32. 118 int32 subscribe_mib_per_sec = 2; 119 } 120 121 // The number of partitions in the topic. Must be at least 1. 122 // 123 // Once a topic has been created the number of partitions can be increased 124 // but not decreased. Message ordering is not guaranteed across a topic 125 // resize. For more information see 126 // https://cloud.google.com/pubsub/lite/docs/topics#scaling_capacity 127 int64 count = 1; 128 129 // The throughput dimension of this topic. 130 oneof dimension { 131 // DEPRECATED: Use capacity instead which can express a superset of 132 // configurations. 133 // 134 // Every partition in the topic is allocated throughput equivalent to 135 // `scale` times the standard partition throughput (4 MiB/s). This is also 136 // reflected in the cost of this topic; a topic with `scale` of 2 and 137 // count of 10 is charged for 20 partitions. This value must be in the 138 // range [1,4]. 139 int32 scale = 2 [deprecated = true]; 140 141 // The capacity configuration. 142 Capacity capacity = 3; 143 } 144 } 145 146 // The settings for a topic's message retention. 147 message RetentionConfig { 148 // The provisioned storage, in bytes, per partition. If the number of bytes 149 // stored in any of the topic's partitions grows beyond this value, older 150 // messages will be dropped to make room for newer ones, regardless of the 151 // value of `period`. 152 int64 per_partition_bytes = 1; 153 154 // How long a published message is retained. If unset, messages will be 155 // retained as long as the bytes retained for each partition is below 156 // `per_partition_bytes`. 157 google.protobuf.Duration period = 2; 158 } 159 160 // The settings for this topic's Reservation usage. 161 message ReservationConfig { 162 // The Reservation to use for this topic's throughput capacity. 163 // Structured like: 164 // projects/{project_number}/locations/{location}/reservations/{reservation_id} 165 string throughput_reservation = 1 [(google.api.resource_reference) = { 166 type: "pubsublite.googleapis.com/Reservation" 167 }]; 168 } 169 170 // The name of the topic. 171 // Structured like: 172 // projects/{project_number}/locations/{location}/topics/{topic_id} 173 string name = 1; 174 175 // The settings for this topic's partitions. 176 PartitionConfig partition_config = 2; 177 178 // The settings for this topic's message retention. 179 RetentionConfig retention_config = 3; 180 181 // The settings for this topic's Reservation usage. 182 ReservationConfig reservation_config = 4; 183} 184 185// Metadata about a subscription resource. 186message Subscription { 187 option (google.api.resource) = { 188 type: "pubsublite.googleapis.com/Subscription" 189 pattern: "projects/{project}/locations/{location}/subscriptions/{subscription}" 190 }; 191 192 // The settings for a subscription's message delivery. 193 message DeliveryConfig { 194 // When this subscription should send messages to subscribers relative to 195 // messages persistence in storage. For details, see [Creating Lite 196 // subscriptions](https://cloud.google.com/pubsub/lite/docs/subscriptions#creating_lite_subscriptions). 197 enum DeliveryRequirement { 198 // Default value. This value is unused. 199 DELIVERY_REQUIREMENT_UNSPECIFIED = 0; 200 201 // The server does not wait for a published message to be successfully 202 // written to storage before delivering it to subscribers. 203 DELIVER_IMMEDIATELY = 1; 204 205 // The server will not deliver a published message to subscribers until 206 // the message has been successfully written to storage. This will result 207 // in higher end-to-end latency, but consistent delivery. 208 DELIVER_AFTER_STORED = 2; 209 } 210 211 // The DeliveryRequirement for this subscription. 212 DeliveryRequirement delivery_requirement = 3; 213 } 214 215 // The name of the subscription. 216 // Structured like: 217 // projects/{project_number}/locations/{location}/subscriptions/{subscription_id} 218 string name = 1; 219 220 // The name of the topic this subscription is attached to. 221 // Structured like: 222 // projects/{project_number}/locations/{location}/topics/{topic_id} 223 string topic = 2 [(google.api.resource_reference) = { 224 type: "pubsublite.googleapis.com/Topic" 225 }]; 226 227 // The settings for this subscription's message delivery. 228 DeliveryConfig delivery_config = 3; 229 230 // If present, messages are automatically written from the Pub/Sub Lite topic 231 // associated with this subscription to a destination. 232 ExportConfig export_config = 4; 233} 234 235// Configuration for a Pub/Sub Lite subscription that writes messages to a 236// destination. User subscriber clients must not connect to this subscription. 237message ExportConfig { 238 // The desired export state. 239 enum State { 240 // Default value. This value is unused. 241 STATE_UNSPECIFIED = 0; 242 243 // Messages are being exported. 244 ACTIVE = 1; 245 246 // Exporting messages is suspended. 247 PAUSED = 2; 248 249 // Messages cannot be exported due to permission denied errors. Output only. 250 PERMISSION_DENIED = 3; 251 252 // Messages cannot be exported due to missing resources. Output only. 253 NOT_FOUND = 4; 254 } 255 256 // Configuration for exporting to a Pub/Sub topic. 257 message PubSubConfig { 258 // The name of the Pub/Sub topic. 259 // Structured like: projects/{project_number}/topics/{topic_id}. 260 // The topic may be changed. 261 string topic = 1; 262 } 263 264 // The desired state of this export. Setting this to values other than 265 // `ACTIVE` and `PAUSED` will result in an error. 266 State desired_state = 1; 267 268 // Output only. The current state of the export, which may be different to the 269 // desired state due to errors. This field is output only. 270 State current_state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; 271 272 // Optional. The name of an optional Pub/Sub Lite topic to publish messages 273 // that can not be exported to the destination. For example, the message can 274 // not be published to the Pub/Sub service because it does not satisfy the 275 // constraints documented at https://cloud.google.com/pubsub/docs/publisher. 276 // 277 // Structured like: 278 // projects/{project_number}/locations/{location}/topics/{topic_id}. 279 // Must be within the same project and location as the subscription. The topic 280 // may be changed or removed. 281 string dead_letter_topic = 5 [ 282 (google.api.field_behavior) = OPTIONAL, 283 (google.api.resource_reference) = { 284 type: "pubsublite.googleapis.com/Topic" 285 } 286 ]; 287 288 // The destination to export to. Required. 289 oneof destination { 290 // Messages are automatically written from the Pub/Sub Lite topic associated 291 // with this subscription to a Pub/Sub topic. 292 PubSubConfig pubsub_config = 3; 293 } 294} 295 296// A target publish or event time. Can be used for seeking to or retrieving the 297// corresponding cursor. 298message TimeTarget { 299 // The type of message time to query. 300 oneof time { 301 // Request the cursor of the first message with publish time greater than or 302 // equal to `publish_time`. All messages thereafter are guaranteed to have 303 // publish times >= `publish_time`. 304 google.protobuf.Timestamp publish_time = 1; 305 306 // Request the cursor of the first message with event time greater than or 307 // equal to `event_time`. If messages are missing an event time, the publish 308 // time is used as a fallback. As event times are user supplied, subsequent 309 // messages may have event times less than `event_time` and should be 310 // filtered by the client, if necessary. 311 google.protobuf.Timestamp event_time = 2; 312 } 313} 314