streaming_service.proto 14 KB

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