common.proto 11 KB

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