From cffb6e309107d2f75158e0f30cbd308e67c7d675 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Thu, 27 May 2021 16:21:08 -0700 Subject: [PATCH] Update the worker protocol proto --- third_party/bazel_protos/README.md | 5 +-- .../bazel_protos/worker_protocol.proto | 33 +++++++++++++++++-- tools/worker/work_processor.cc | 1 + 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/third_party/bazel_protos/README.md b/third_party/bazel_protos/README.md index 442e981f4..8eaca51dd 100644 --- a/third_party/bazel_protos/README.md +++ b/third_party/bazel_protos/README.md @@ -1,3 +1,4 @@ -This directory contains protocol buffers vendored from the main Bazel -repository, so that rules_swift does not need to depend on the entire +This directory contains protocol buffers vendored from the +[main Bazel repository](https://raw.githubusercontent.com/bazelbuild/bazel/master/src/main/protobuf/worker_protocol.proto), +so that rules_swift does not need to depend on the entire `@io_bazel` workspace, which is approximately 100MB. diff --git a/third_party/bazel_protos/worker_protocol.proto b/third_party/bazel_protos/worker_protocol.proto index 0a777a96b..2381df106 100644 --- a/third_party/bazel_protos/worker_protocol.proto +++ b/third_party/bazel_protos/worker_protocol.proto @@ -31,16 +31,31 @@ message Input { bytes digest = 2; } -// This represents a single work unit that Bazel sends to the worker. +// This represents a single work unit that Blaze sends to the worker. message WorkRequest { repeated string arguments = 1; // The inputs that the worker is allowed to read during execution of this // request. repeated Input inputs = 2; + + // Each WorkRequest must have either a unique + // request_id or request_id = 0. If request_id is 0, this WorkRequest must be + // processed alone (singleplex), otherwise the worker may process multiple + // WorkRequests in parallel (multiplexing). As an exception to the above, if + // the cancel field is true, the request_id must be the same as a previously + // sent WorkRequest. The request_id must be attached unchanged to the + // corresponding WorkResponse. Only one singleplex request may be sent to a + // worker at a time. + int32 request_id = 3; + + // EXPERIMENTAL: When true, this is a cancel request, indicating that a + // previously sent WorkRequest with the same request_id should be cancelled. + // The arguments and inputs fields must be empty and should be ignored. + bool cancel = 4; } -// The worker sends this message to Bazel when it finished its work on the +// The worker sends this message to Blaze when it finished its work on the // WorkRequest message. message WorkResponse { int32 exit_code = 1; @@ -49,4 +64,18 @@ message WorkResponse { // supposed to contain compiler warnings / errors etc. - thus we'll use a // string type here, which gives us UTF-8 encoding. string output = 2; + + // This field must be set to the same request_id as the WorkRequest it is a + // response to. Since worker processes which support multiplex worker will + // handle multiple WorkRequests in parallel, this ID will be used to + // determined which WorkerProxy does this WorkResponse belong to. + int32 request_id = 3; + + // EXPERIMENTAL When true, indicates that this response was sent due to + // receiving a cancel request. The exit_code and output fields should be empty + // and will be ignored. Exactly one WorkResponse must be sent for each + // non-cancelling WorkRequest received by the worker, but if the worker + // received a cancel request, it doesn't matter if it replies with a regular + // WorkResponse or with one where was_cancelled = true. + bool was_cancelled = 4; } diff --git a/tools/worker/work_processor.cc b/tools/worker/work_processor.cc index 1e48bebc5..8e824ade0 100644 --- a/tools/worker/work_processor.cc +++ b/tools/worker/work_processor.cc @@ -145,4 +145,5 @@ void WorkProcessor::ProcessWorkRequest( response->set_exit_code(exit_code); response->set_output(stderr_stream.str()); + response->set_request_id(request.request_id()); }