From 4fb4fc263d31e207f0fc842f17e98ca276094e00 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 15 Jan 2024 18:43:15 +0200 Subject: [PATCH] feat(tvix/build): add BuildService trait Also provide a dummy implementation that just fails on any build that's requested. Change-Id: I0df743a730c5331ec9ce6e97a966abe18ce067f5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10627 Autosubmit: flokli Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- tvix/Cargo.lock | 1 + tvix/Cargo.nix | 4 ++++ tvix/build/Cargo.toml | 1 + tvix/build/src/buildservice/dummy.rs | 19 +++++++++++++++++++ tvix/build/src/buildservice/mod.rs | 12 ++++++++++++ tvix/build/src/lib.rs | 1 + 6 files changed, 38 insertions(+) create mode 100644 tvix/build/src/buildservice/dummy.rs create mode 100644 tvix/build/src/buildservice/mod.rs diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock index 4ce2993cb..95cc50a40 100644 --- a/tvix/Cargo.lock +++ b/tvix/Cargo.lock @@ -3291,6 +3291,7 @@ dependencies = [ "tonic 0.10.2", "tonic-build", "tonic-reflection", + "tracing", "tvix-castore", ] diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix index d3947281d..a67738397 100644 --- a/tvix/Cargo.nix +++ b/tvix/Cargo.nix @@ -10246,6 +10246,10 @@ rec { packageId = "tonic-reflection"; optional = true; } + { + name = "tracing"; + packageId = "tracing"; + } { name = "tvix-castore"; packageId = "tvix-castore"; diff --git a/tvix/build/Cargo.toml b/tvix/build/Cargo.toml index 7b1594abc..2782128db 100644 --- a/tvix/build/Cargo.toml +++ b/tvix/build/Cargo.toml @@ -10,6 +10,7 @@ prost = "0.12.1" thiserror = "1.0.56" tonic = "0.10.2" tvix-castore = { path = "../castore" } +tracing = "0.1.37" [dependencies.tonic-reflection] optional = true diff --git a/tvix/build/src/buildservice/dummy.rs b/tvix/build/src/buildservice/dummy.rs new file mode 100644 index 000000000..d20444755 --- /dev/null +++ b/tvix/build/src/buildservice/dummy.rs @@ -0,0 +1,19 @@ +use tonic::async_trait; +use tracing::instrument; + +use super::BuildService; +use crate::proto::{Build, BuildRequest}; + +#[derive(Default)] +pub struct DummyBuildService {} + +#[async_trait] +impl BuildService for DummyBuildService { + #[instrument(skip(self), ret, err)] + async fn do_build(&self, _request: BuildRequest) -> std::io::Result { + Err(std::io::Error::new( + std::io::ErrorKind::Other, + "builds are not supported with DummyBuildService", + )) + } +} diff --git a/tvix/build/src/buildservice/mod.rs b/tvix/build/src/buildservice/mod.rs new file mode 100644 index 000000000..cd0b7eb5d --- /dev/null +++ b/tvix/build/src/buildservice/mod.rs @@ -0,0 +1,12 @@ +use tonic::async_trait; + +use crate::proto::{Build, BuildRequest}; + +mod dummy; +pub use dummy::DummyBuildService; + +#[async_trait] +pub trait BuildService: Send + Sync { + /// TODO: document + async fn do_build(&self, request: BuildRequest) -> std::io::Result; +} diff --git a/tvix/build/src/lib.rs b/tvix/build/src/lib.rs index febacec69..b173657e4 100644 --- a/tvix/build/src/lib.rs +++ b/tvix/build/src/lib.rs @@ -1 +1,2 @@ +pub mod buildservice; pub mod proto;