feat(tvix/build): add gRPC client
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
This commit is contained in:
parent
c01ec8ee38
commit
5aa9b29d8c
4 changed files with 32 additions and 1 deletions
|
@ -10240,6 +10240,7 @@ rec {
|
||||||
{
|
{
|
||||||
name = "tonic";
|
name = "tonic";
|
||||||
packageId = "tonic 0.10.2";
|
packageId = "tonic 0.10.2";
|
||||||
|
features = [ "tls" "tls-roots" ];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "tonic-reflection";
|
name = "tonic-reflection";
|
||||||
|
|
|
@ -8,7 +8,7 @@ bytes = "1.4.0"
|
||||||
itertools = "0.12.0"
|
itertools = "0.12.0"
|
||||||
prost = "0.12.1"
|
prost = "0.12.1"
|
||||||
thiserror = "1.0.56"
|
thiserror = "1.0.56"
|
||||||
tonic = "0.10.2"
|
tonic = { version = "0.10.2", features = ["tls", "tls-roots"] }
|
||||||
tvix-castore = { path = "../castore" }
|
tvix-castore = { path = "../castore" }
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
|
|
||||||
|
|
28
tvix/build/src/buildservice/grpc.rs
Normal file
28
tvix/build/src/buildservice/grpc.rs
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ use tonic::async_trait;
|
||||||
use crate::proto::{Build, BuildRequest};
|
use crate::proto::{Build, BuildRequest};
|
||||||
|
|
||||||
mod dummy;
|
mod dummy;
|
||||||
|
mod grpc;
|
||||||
|
|
||||||
pub use dummy::DummyBuildService;
|
pub use dummy::DummyBuildService;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
Loading…
Reference in a new issue