Skip to content

Commit

Permalink
Update the worker protocol proto (bazelbuild#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins authored May 27, 2021
1 parent ed54a36 commit baa0f0c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
5 changes: 3 additions & 2 deletions third_party/bazel_protos/README.md
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 31 additions & 2 deletions third_party/bazel_protos/worker_protocol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
1 change: 1 addition & 0 deletions tools/worker/work_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit baa0f0c

Please sign in to comment.