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