diff options
author | Florian Klink <flokli@flokli.de> | 2024-01-15T17·07+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-01-15T18·41+0000 |
commit | 5aa9b29d8cdf870ee6f3ad01a874604ff9f93e45 (patch) | |
tree | 413bbe05eafb58e86710544c2fddf7bd1f2226b0 /tvix/build/src | |
parent | c01ec8ee383553344c75cef26f986ac1ae8687e9 (diff) |
feat(tvix/build): add gRPC client r/7385
Change-Id: I0d917a9a308227b13d096def22945db917830d18 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10629 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r-- | tvix/build/src/buildservice/grpc.rs | 28 | ||||
-rw-r--r-- | tvix/build/src/buildservice/mod.rs | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tvix/build/src/buildservice/grpc.rs b/tvix/build/src/buildservice/grpc.rs new file mode 100644 index 000000000000..9d22d8397abf --- /dev/null +++ b/tvix/build/src/buildservice/grpc.rs @@ -0,0 +1,28 @@ +use tonic::{async_trait, transport::Channel}; + +use crate::proto::{build_service_client::BuildServiceClient, Build, BuildRequest}; + +use super::BuildService; + +pub struct GRPCBuildService { + client: BuildServiceClient<Channel>, +} + +impl GRPCBuildService { + #[allow(dead_code)] + pub fn from_client(client: BuildServiceClient<Channel>) -> Self { + Self { client } + } +} + +#[async_trait] +impl BuildService for GRPCBuildService { + async fn do_build(&self, request: BuildRequest) -> std::io::Result<Build> { + let mut client = self.client.clone(); + client + .do_build(request) + .await + .map(|resp| resp.into_inner()) + .map_err(std::io::Error::other) + } +} diff --git a/tvix/build/src/buildservice/mod.rs b/tvix/build/src/buildservice/mod.rs index cd0b7eb5d70f..cbee221a5e23 100644 --- a/tvix/build/src/buildservice/mod.rs +++ b/tvix/build/src/buildservice/mod.rs @@ -3,6 +3,8 @@ use tonic::async_trait; use crate::proto::{Build, BuildRequest}; mod dummy; +mod grpc; + pub use dummy::DummyBuildService; #[async_trait] |