1// Copyright 2023 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.visionai.v1; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/cloud/visionai/v1/streaming_resources.proto"; 22import "google/protobuf/duration.proto"; 23import "google/protobuf/timestamp.proto"; 24 25option csharp_namespace = "Google.Cloud.VisionAI.V1"; 26option go_package = "cloud.google.com/go/visionai/apiv1/visionaipb;visionaipb"; 27option java_multiple_files = true; 28option java_outer_classname = "StreamingServiceProto"; 29option java_package = "com.google.cloud.visionai.v1"; 30option php_namespace = "Google\\Cloud\\VisionAI\\V1"; 31option ruby_package = "Google::Cloud::VisionAI::V1"; 32 33// Streaming service for receiving and sending packets. 34service StreamingService { 35 option (google.api.default_host) = "visionai.googleapis.com"; 36 option (google.api.oauth_scopes) = 37 "https://www.googleapis.com/auth/cloud-platform"; 38 39 // Send packets to the series. 40 rpc SendPackets(stream SendPacketsRequest) 41 returns (stream SendPacketsResponse) {} 42 43 // Receive packets from the series. 44 rpc ReceivePackets(stream ReceivePacketsRequest) 45 returns (stream ReceivePacketsResponse) {} 46 47 // Receive events given the stream name. 48 rpc ReceiveEvents(stream ReceiveEventsRequest) 49 returns (stream ReceiveEventsResponse) {} 50 51 // AcquireLease acquires a lease. 52 rpc AcquireLease(AcquireLeaseRequest) returns (Lease) { 53 option (google.api.http) = { 54 post: "/v1/{series=projects/*/locations/*/clusters/*/series/*}:acquireLease" 55 body: "*" 56 }; 57 } 58 59 // RenewLease renews a lease. 60 rpc RenewLease(RenewLeaseRequest) returns (Lease) { 61 option (google.api.http) = { 62 post: "/v1/{series=projects/*/locations/*/clusters/*/series/*}:renewLease" 63 body: "*" 64 }; 65 } 66 67 // RleaseLease releases a lease. 68 rpc ReleaseLease(ReleaseLeaseRequest) returns (ReleaseLeaseResponse) { 69 option (google.api.http) = { 70 post: "/v1/{series=projects/*/locations/*/clusters/*/series/*}:releaseLease" 71 body: "*" 72 }; 73 } 74} 75 76// The lease type. 77enum LeaseType { 78 // Lease type unspecified. 79 LEASE_TYPE_UNSPECIFIED = 0; 80 81 // Lease for stream reader. 82 LEASE_TYPE_READER = 1; 83 84 // Lease for stream writer. 85 LEASE_TYPE_WRITER = 2; 86} 87 88// Request message for ReceiveEvents. 89message ReceiveEventsRequest { 90 // SetupRequest is the first message sent to the service to setup the RPC 91 // connection. 92 message SetupRequest { 93 // The cluster name. 94 string cluster = 1; 95 96 // The stream name. The service will return the events for the given stream. 97 string stream = 2; 98 99 // A name for the receiver to self-identify. 100 // 101 // This is used to keep track of a receiver's read progress. 102 string receiver = 3; 103 104 // Controller mode configuration for receiving events from the server. 105 ControlledMode controlled_mode = 4; 106 107 // The maximum duration of server silence before the client determines the 108 // server unreachable. 109 // 110 // The client must either receive an `Event` update or a heart beat message 111 // before this duration expires; otherwise, the client will automatically 112 // cancel the current connection and retry. 113 google.protobuf.Duration heartbeat_interval = 5; 114 115 // The grace period after which a `writes_done_request` is issued, that a 116 // `WritesDone` is expected from the client. 117 // 118 // The server is free to cancel the RPC should this expire. 119 // 120 // A system default will be chosen if unset. 121 google.protobuf.Duration writes_done_grace_period = 6; 122 } 123 124 oneof request { 125 // The setup request to setup the RPC connection. 126 SetupRequest setup_request = 1; 127 128 // This request checkpoints the consumer's read progress. 129 CommitRequest commit_request = 2; 130 } 131} 132 133// The event update message. 134message EventUpdate { 135 // The name of the stream that the event is attached to. 136 string stream = 1; 137 138 // The name of the event. 139 string event = 2; 140 141 // The name of the series. 142 string series = 3; 143 144 // The timestamp when the Event update happens. 145 google.protobuf.Timestamp update_time = 4; 146 147 // The offset of the message that will be used to acknowledge of the message 148 // receiving. 149 int64 offset = 5; 150} 151 152// Control message for a ReceiveEventsResponse. 153message ReceiveEventsControlResponse { 154 // Possible control messages. 155 oneof control { 156 // A server heartbeat. 157 bool heartbeat = 1; 158 159 // A request to the receiver to complete any final writes followed by a 160 // `WritesDone`; e.g. issue any final `CommitRequest`s. 161 // 162 // May be ignored if `WritesDone` has already been issued at any point 163 // prior to receiving this message. 164 // 165 // If `WritesDone` does not get issued, then the server will forcefully 166 // cancel the connection, and the receiver will likely receive an 167 // uninformative after `Read` returns `false` and `Finish` is called. 168 bool writes_done_request = 2; 169 } 170} 171 172// Response message for the ReceiveEvents. 173message ReceiveEventsResponse { 174 // Possible response types. 175 oneof response { 176 // The event update message. 177 EventUpdate event_update = 1; 178 179 // A control message from the server. 180 ReceiveEventsControlResponse control = 2; 181 } 182} 183 184// The lease message. 185message Lease { 186 // The lease id. 187 string id = 1; 188 189 // The series name. 190 string series = 2; 191 192 // The owner name. 193 string owner = 3; 194 195 // The lease expire time. 196 google.protobuf.Timestamp expire_time = 4; 197 198 // The lease type. 199 LeaseType lease_type = 5; 200} 201 202// Request message for acquiring a lease. 203message AcquireLeaseRequest { 204 // The series name. 205 string series = 1; 206 207 // The owner name. 208 string owner = 2; 209 210 // The lease term. 211 google.protobuf.Duration term = 3; 212 213 // The lease type. 214 LeaseType lease_type = 4; 215} 216 217// Request message for renewing a lease. 218message RenewLeaseRequest { 219 // Lease id. 220 string id = 1; 221 222 // Series name. 223 string series = 2; 224 225 // Lease owner. 226 string owner = 3; 227 228 // Lease term. 229 google.protobuf.Duration term = 4; 230} 231 232// Request message for releasing lease. 233message ReleaseLeaseRequest { 234 // Lease id. 235 string id = 1; 236 237 // Series name. 238 string series = 2; 239 240 // Lease owner. 241 string owner = 3; 242} 243 244// Response message for release lease. 245message ReleaseLeaseResponse {} 246 247// RequestMetadata is the metadata message for the request. 248message RequestMetadata { 249 // Stream name. 250 string stream = 1; 251 252 // Evevt name. 253 string event = 2; 254 255 // Series name. 256 string series = 3; 257 258 // Lease id. 259 string lease_id = 4; 260 261 // Owner name. 262 string owner = 5; 263 264 // Lease term specifies how long the client wants the session to be maintained 265 // by the server after the client leaves. If the lease term is not set, the 266 // server will release the session immediately and the client cannot reconnect 267 // to the same session later. 268 google.protobuf.Duration lease_term = 6; 269} 270 271// Request message for sending packets. 272message SendPacketsRequest { 273 oneof request { 274 // Packets sent over the streaming rpc. 275 Packet packet = 1; 276 277 // The first message of the streaming rpc including the request metadata. 278 RequestMetadata metadata = 2; 279 } 280} 281 282// Response message for sending packets. 283message SendPacketsResponse {} 284 285// Request message for receiving packets. 286message ReceivePacketsRequest { 287 // The message specifying the initial settings for the ReceivePackets session. 288 message SetupRequest { 289 // The mode in which the consumer reads messages. 290 oneof consumer_mode { 291 // Options for configuring eager mode. 292 EagerMode eager_receive_mode = 3; 293 294 // Options for configuring controlled mode. 295 ControlledMode controlled_receive_mode = 4; 296 } 297 298 // The configurations that specify where packets are retrieved. 299 RequestMetadata metadata = 1; 300 301 // A name for the receiver to self-identify. 302 // 303 // This is used to keep track of a receiver's read progress. 304 string receiver = 2; 305 306 // The maximum duration of server silence before the client determines the 307 // server unreachable. 308 // 309 // The client must either receive a `Packet` or a heart beat message before 310 // this duration expires; otherwise, the client will automatically cancel 311 // the current connection and retry. 312 google.protobuf.Duration heartbeat_interval = 5; 313 314 // The grace period after which a `writes_done_request` is issued, that a 315 // `WritesDone` is expected from the client. 316 // 317 // The server is free to cancel the RPC should this expire. 318 // 319 // A system default will be chosen if unset. 320 google.protobuf.Duration writes_done_grace_period = 6; 321 } 322 323 // Possible request types from the client. 324 oneof request { 325 // The request to setup the initial state of session. 326 // 327 // The client must send and only send this as the first message. 328 SetupRequest setup_request = 6; 329 330 // This request checkpoints the consumer's read progress. 331 CommitRequest commit_request = 7; 332 } 333} 334 335// Control message for a ReceivePacketsResponse. 336message ReceivePacketsControlResponse { 337 // Possible control messages. 338 oneof control { 339 // A server heartbeat. 340 bool heartbeat = 1; 341 342 // A request to the receiver to complete any final writes followed by a 343 // `WritesDone`; e.g. issue any final `CommitRequest`s. 344 // 345 // May be ignored if `WritesDone` has already been issued at any point 346 // prior to receiving this message. 347 // 348 // If `WritesDone` does not get issued, then the server will forcefully 349 // cancel the connection, and the receiver will likely receive an 350 // uninformative after `Read` returns `false` and `Finish` is called. 351 bool writes_done_request = 2; 352 } 353} 354 355// Response message from ReceivePackets. 356message ReceivePacketsResponse { 357 // Possible response types. 358 oneof response { 359 // A genuine data payload originating from the sender. 360 Packet packet = 1; 361 362 // A control message from the server. 363 ReceivePacketsControlResponse control = 3; 364 } 365} 366 367// The options for receiver under the eager mode. 368message EagerMode {} 369 370// The options for receiver under the controlled mode. 371message ControlledMode { 372 // This is the offset from which to start receiveing. 373 oneof starting_offset { 374 // This can be set to the following logical starting points: 375 // 376 // "begin": This will read from the earliest available message. 377 // 378 // "most-recent": This will read from the latest available message. 379 // 380 // "end": This will read only future messages. 381 // 382 // "stored": This will resume reads one past the last committed offset. 383 // It is the only option that resumes progress; all others 384 // jump unilaterally. 385 string starting_logical_offset = 1; 386 } 387 388 // This is the logical starting point to fallback upon should the 389 // specified starting offset be unavailable. 390 // 391 // This can be one of the following values: 392 // 393 // "begin": This will read from the earliest available message. 394 // 395 // "end": This will read only future messages. 396 string fallback_starting_offset = 2; 397} 398 399// The message for explicitly committing the read progress. 400// 401// This may only be used when `ReceivePacketsControlledMode` is set in the 402// initial setup request. 403message CommitRequest { 404 // The offset to commit. 405 int64 offset = 1; 406} 407