Skip to content

Commit

Permalink
Switch operation getting to tower (pantsbuild#7108)
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion authored Jan 18, 2019
1 parent 32dc915 commit 0375b30
Show file tree
Hide file tree
Showing 11 changed files with 568 additions and 562 deletions.
4 changes: 3 additions & 1 deletion src/rust/engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/rust/engine/process_execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ fs = { path = "../fs" }
futures = "^0.1.16"
# TODO: Switch to a release once https://github.com/alexcrichton/futures-timer/pull/11 and https://github.com/alexcrichton/futures-timer/pull/12 merge
futures-timer = { git = "https://github.com/pantsbuild/futures-timer", rev = "0b747e565309a58537807ab43c674d8951f9e5a0" }
grpcio = { git = "https://github.com/pantsbuild/grpc-rs.git", rev = "4dfafe9355dc996d7d0702e7386a6fedcd9734c0", default_features = false, features = ["protobuf-codec"] }
h2 = "0.1.13"
hashing = { path = "../hashing" }
http = "0.1"
log = "0.4"
parking_lot = "0.6"
prost = "0.4"
prost-types = "0.4"
protobuf = { version = "2.0.4", features = ["with-bytes"] }
resettable = { path = "../resettable" }
sha2 = "0.8"
Expand Down
1 change: 1 addition & 0 deletions src/rust/engine/process_execution/bazel_protos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bytes = "0.4.5"
futures = "^0.1.16"
grpcio = { git = "https://github.com/pantsbuild/grpc-rs.git", rev = "4dfafe9355dc996d7d0702e7386a6fedcd9734c0", default_features = false, features = ["protobuf-codec"] }
hashing = { path = "../../hashing" }
log = "0.4"
prost = "0.4"
prost-derive = "0.4"
prost-types = "0.4"
Expand Down
8 changes: 5 additions & 3 deletions src/rust/engine/process_execution/bazel_protos/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ fn generate_for_tower(thirdpartyprotobuf: &Path, out_dir: PathBuf) {
.enable_server(true)
.enable_client(true)
.build(
&[PathBuf::from(
"build/bazel/remote/execution/v2/remote_execution.proto",
)],
&[
PathBuf::from("build/bazel/remote/execution/v2/remote_execution.proto"),
PathBuf::from("google/rpc/code.proto"),
PathBuf::from("google/rpc/error_details.proto"),
],
&std::fs::read_dir(&thirdpartyprotobuf)
.unwrap()
.into_iter()
Expand Down
44 changes: 44 additions & 0 deletions src/rust/engine/process_execution/bazel_protos/src/conversions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use bytes::BytesMut;
use hashing;
use log::error;
use prost::Message;

impl<'a> From<&'a hashing::Digest> for crate::remote_execution::Digest {
fn from(d: &hashing::Digest) -> Self {
Expand Down Expand Up @@ -97,6 +100,47 @@ impl From<crate::build::bazel::remote::execution::v2::ExecuteRequest>
}
}

// This should only be used in test contexts. It should be deleted when the mock systems use tower.
impl Into<grpcio::RpcStatus> for crate::google::rpc::Status {
fn into(self) -> grpcio::RpcStatus {
let mut buf = BytesMut::with_capacity(self.encoded_len());
self.encode(&mut buf).unwrap();
grpcio::RpcStatus {
status: self.code.into(),
details: None,
status_proto_bytes: Some(buf.to_vec()),
}
}
}

// TODO: Use num_enum or similar here when TryInto is stable.
pub fn code_from_i32(i: i32) -> crate::google::rpc::Code {
use crate::google::rpc::Code::*;
match i {
0 => Ok,
1 => Cancelled,
2 => Unknown,
3 => InvalidArgument,
4 => DeadlineExceeded,
5 => NotFound,
6 => AlreadyExists,
7 => PermissionDenied,
8 => ResourceExhausted,
9 => FailedPrecondition,
10 => Aborted,
11 => OutOfRange,
12 => Unimplemented,
13 => Internal,
14 => Unavailable,
15 => DataLoss,
16 => Unauthenticated,
_ => {
error!("Unknown grpc error code: {}, default to Unknown", i);
Unknown
}
}
}

pub fn prost_any_to_gcprio_any(any: prost_types::Any) -> protobuf::well_known_types::Any {
let prost_types::Any { type_url, value } = any;
let mut dst = protobuf::well_known_types::Any::new();
Expand Down
1 change: 1 addition & 0 deletions src/rust/engine/process_execution/bazel_protos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ mod gen_for_tower;
pub use crate::gen_for_tower::*;

mod conversions;
pub use crate::conversions::code_from_i32;
mod verification;
pub use crate::verification::verify_directory_canonical;
1 change: 0 additions & 1 deletion src/rust/engine/process_execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use bazel_protos;

use fs;

use grpcio;
use hashing;

#[cfg(test)]
Expand Down
Loading

0 comments on commit 0375b30

Please sign in to comment.