xref: /aosp_15_r20/external/bazelbuild-remote-apis/build/bazel/remote/logstream/v1/remote_logstream.proto (revision ae21b2b400d1606a797985382019aea74177085c)
1// Copyright 2020 The Bazel Authors.
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
15// Log Stream API
16
17syntax = "proto3";
18
19package build.bazel.remote.logstream.v1;
20
21option csharp_namespace = "Build.Bazel.Remote.LogStream.v1";
22option go_package = "github.com/bazelbuild/remote-apis/build/bazel/remote/logstream/v1;remotelogstream";
23option java_multiple_files = true;
24option java_outer_classname = "RemoteLogStreamProto";
25option java_package = "build.bazel.remote.logstream.v1";
26option objc_class_prefix = "RL";
27
28
29// #### Introduction
30//
31// The Log Stream API manages LogStream resources which are used to stream
32// writes and reads of an ordered sequence of bytes of unknown eventual length.
33//
34// Note that this is an API Interface and not an API Service, per the definitions
35// at: https://cloud.google.com/apis/design/glossary
36//
37// Log Stream API supports the reading of unfinalized LogStreams either by
38// seeking or in "tail" mode, for example by end-users browsing to a build
39// result UI interested in seeing logs from a build action as soon as they are
40// (or as they become) available.
41//
42// Reads and Writes of LogStreams are done via the Byte Stream API:
43// https://cloud.google.com/dataproc/docs/reference/rpc/google.bytestream
44// https://github.com/googleapis/googleapis/blob/master/google/bytestream/bytestream.proto
45//
46// #### Writing LogStreams
47//
48// LogStreams are written to via the Byte Stream API's `Write` RPC. Bytes
49// written to LogStreams are expected to be committed and available for reading
50// within a reasonable period of time (implementation-defined). Committed bytes
51// to a LogStream cannot be overwritten, and finalized LogStreams - indicated by
52// setting `finish_write` field in the final WriteRequest - also cannot be
53// appended to.
54//
55// When calling the Byte Stream API's `Write` RPC to write LogStreams, writers
56// must pass the `write_resource_name` of a LogStream as
57// `ByteStream.WriteRequest.resource_name` rather than the LogStream's `name`.
58// Separate resource names for reading and writing allows for broadcasting the
59// read resource name widely while simultaneously ensuring that only writer(s)
60// with knowledge of the write resource name may have written bytes to the
61// LogStream.
62//
63// #### Reading LogStreams
64//
65// Use the Byte Stream API's `Read` RPC to read LogStreams. When reading
66// finalized LogStreams the server will stream all contents of the LogStream
67// starting at `ByteStream.ReadRequest.read_offset`.
68//
69// When reading unfinalized LogStreams the server must keep the streaming
70// `ByteStream.Read` RPC open and send `ByteStream.ReadResponse` messages as
71// more bytes become available or the LogStream is finalized.
72//
73// #### Example Multi-Party Read/Write Flow
74//
75// 1. LogStream Writer calls `CreateLogStream`
76// 2. LogStream Writer publishes `LogStream.name`
77// 3. LogStream Writer calls `ByteStream.Write` with
78//    `LogStream.write_resource_name` as
79//    `ByteStream.WriteRequest.resource_name`,
80//    `ByteStream.WriteRequest.finish_write`=false.
81// 4. LogStream Reader(s) call `ByteStream.Read` with the published
82//    `LogStream.name` as `ByteStream.ReadRequest.resource_name`.
83// 5. LogStream Service streams all committed bytes to LogStream Reader(s),
84//    leave the stream open.
85// 6. LogStream Writer calls `ByteStream.Write` with
86//    `LogStream.write_resource_name` as
87//    `ByteStream.WriteRequest.resource_name`,
88//    `ByteStream.WriteRequest.finish_write`=true.
89// 7. LogStream Service streams all remaining bytes to LogStream Reader(s),
90//    terminates the stream.
91service LogStreamService {
92  // Create a LogStream which may be written to.
93  //
94  // The returned LogStream resource name will include a `write_resource_name`
95  // which is the resource to use when writing to the LogStream.
96  // Callers of CreateLogStream are expected to NOT publish the
97  // `write_resource_name`.
98  rpc CreateLogStream(CreateLogStreamRequest) returns (LogStream) {}
99}
100
101// Contains all information necessary to create a new LogStream resource.
102message CreateLogStreamRequest {
103  // Required. The parent resource of the created LogStream.
104  // The list of valid types of parent resources of LogStreams is up to the
105  // implementing server.
106  // Example: projects/123
107  string parent = 1;
108}
109
110// A handle to a log (an ordered sequence of bytes).
111message LogStream {
112  // Structured name of the resource in the format:
113  //   {parent=**}/logstreams/{logstream_id}
114  //   Example: projects/123/logstreams/456-def
115  // Attempting to call the Byte Stream API's `Write` RPC with a LogStream's
116  //   `name` as the value for `ByteStream.Write.resource_name` is an error.
117  string name = 1;
118
119  // Resource name to pass to `ByteStream.Write` in the format:
120  //   {parent=**}/logstreams/{logstream_id}/{write_token}
121  //   Example: projects/123/logstreams/456-def/789-ghi
122  // Attempting to call the Byte Stream API's `Read` RPC with a LogStream's
123  //   `write_resource_name` as the value for `ByteStream.Write.resource_name`
124  //   is an error.
125  //
126  // `write_resource_name` is separate from `name` to ensure that only the
127  // intended writers can write to a given LogStream. Writers must address write
128  // operations to the `write_resource_name`, not the `name`, and must have
129  // permission to write LogStreams. `write_resource_name` embeds a secret token
130  // and should be protected accordingly; a mishandled `write_resource_name` can
131  // result in unintended writers corrupting the LogStream. Therefore, the field
132  // should be excluded from calls to any calls which retrieve LogStream
133  // metadata (i.e.: `GetLogStream`).
134  //
135  // Bytes written to this resource must to be readable when `ByteStream.Read`
136  // is called with the `name` resource.
137  // Reading a write_resource_name must return an INVALID_ARGUMENT error.
138  string write_resource_name = 2;
139}
140