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/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/cloud/pubsublite/v1/common.proto"; 24import "google/protobuf/timestamp.proto"; 25 26option csharp_namespace = "Google.Cloud.PubSubLite.V1"; 27option go_package = "cloud.google.com/go/pubsublite/apiv1/pubsublitepb;pubsublitepb"; 28option java_multiple_files = true; 29option java_outer_classname = "TopicStatsProto"; 30option java_package = "com.google.cloud.pubsublite.proto"; 31option php_namespace = "Google\\Cloud\\PubSubLite\\V1"; 32option ruby_package = "Google::Cloud::PubSubLite::V1"; 33 34// This service allows users to get stats about messages in their topic. 35service TopicStatsService { 36 option (google.api.default_host) = "pubsublite.googleapis.com"; 37 option (google.api.oauth_scopes) = 38 "https://www.googleapis.com/auth/cloud-platform"; 39 40 // Compute statistics about a range of messages in a given topic and 41 // partition. 42 rpc ComputeMessageStats(ComputeMessageStatsRequest) 43 returns (ComputeMessageStatsResponse) { 44 option (google.api.http) = { 45 post: "/v1/topicStats/{topic=projects/*/locations/*/topics/*}:computeMessageStats" 46 body: "*" 47 }; 48 } 49 50 // Compute the head cursor for the partition. 51 // The head cursor's offset is guaranteed to be less than or equal to all 52 // messages which have not yet been acknowledged as published, and 53 // greater than the offset of any message whose publish has already 54 // been acknowledged. It is zero if there have never been messages in the 55 // partition. 56 rpc ComputeHeadCursor(ComputeHeadCursorRequest) 57 returns (ComputeHeadCursorResponse) { 58 option (google.api.http) = { 59 post: "/v1/topicStats/{topic=projects/*/locations/*/topics/*}:computeHeadCursor" 60 body: "*" 61 }; 62 } 63 64 // Compute the corresponding cursor for a publish or event time in a topic 65 // partition. 66 rpc ComputeTimeCursor(ComputeTimeCursorRequest) 67 returns (ComputeTimeCursorResponse) { 68 option (google.api.http) = { 69 post: "/v1/topicStats/{topic=projects/*/locations/*/topics/*}:computeTimeCursor" 70 body: "*" 71 }; 72 } 73} 74 75// Compute statistics about a range of messages in a given topic and partition. 76message ComputeMessageStatsRequest { 77 // Required. The topic for which we should compute message stats. 78 string topic = 1 [ 79 (google.api.field_behavior) = REQUIRED, 80 (google.api.resource_reference) = { 81 type: "pubsublite.googleapis.com/Topic" 82 } 83 ]; 84 85 // Required. The partition for which we should compute message stats. 86 int64 partition = 2 [(google.api.field_behavior) = REQUIRED]; 87 88 // The inclusive start of the range. 89 Cursor start_cursor = 3; 90 91 // The exclusive end of the range. The range is empty if end_cursor <= 92 // start_cursor. Specifying a start_cursor before the first message and an 93 // end_cursor after the last message will retrieve all messages. 94 Cursor end_cursor = 4; 95} 96 97// Response containing stats for messages in the requested topic and partition. 98message ComputeMessageStatsResponse { 99 // The count of messages. 100 int64 message_count = 1; 101 102 // The number of quota bytes accounted to these messages. 103 int64 message_bytes = 2; 104 105 // The minimum publish timestamp across these messages. Note that publish 106 // timestamps within a partition are not guaranteed to be non-decreasing. The 107 // timestamp will be unset if there are no messages. 108 google.protobuf.Timestamp minimum_publish_time = 3; 109 110 // The minimum event timestamp across these messages. For the purposes of this 111 // computation, if a message does not have an event time, we use the publish 112 // time. The timestamp will be unset if there are no messages. 113 google.protobuf.Timestamp minimum_event_time = 4; 114} 115 116// Compute the current head cursor for a partition. 117message ComputeHeadCursorRequest { 118 // Required. The topic for which we should compute the head cursor. 119 string topic = 1 [ 120 (google.api.field_behavior) = REQUIRED, 121 (google.api.resource_reference) = { 122 type: "pubsublite.googleapis.com/Topic" 123 } 124 ]; 125 126 // Required. The partition for which we should compute the head cursor. 127 int64 partition = 2 [(google.api.field_behavior) = REQUIRED]; 128} 129 130// Response containing the head cursor for the requested topic and partition. 131message ComputeHeadCursorResponse { 132 // The head cursor. 133 Cursor head_cursor = 1; 134} 135 136// Compute the corresponding cursor for a publish or event time in a topic 137// partition. 138message ComputeTimeCursorRequest { 139 // Required. The topic for which we should compute the cursor. 140 string topic = 1 [ 141 (google.api.field_behavior) = REQUIRED, 142 (google.api.resource_reference) = { 143 type: "pubsublite.googleapis.com/Topic" 144 } 145 ]; 146 147 // Required. The partition for which we should compute the cursor. 148 int64 partition = 2 [(google.api.field_behavior) = REQUIRED]; 149 150 // Required. The target publish or event time. Specifying a future time will 151 // return an unset cursor. 152 TimeTarget target = 3 [(google.api.field_behavior) = REQUIRED]; 153} 154 155// Response containing the cursor corresponding to a publish or event time in a 156// topic partition. 157message ComputeTimeCursorResponse { 158 // If present, the cursor references the first message with time greater than 159 // or equal to the specified target time. If such a message cannot be found, 160 // the cursor will be unset (i.e. `cursor` is not present). 161 Cursor cursor = 1; 162} 163