Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the worker protocol proto #622

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤨

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied verbatim from Bazel source

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());
}