diff --git a/backend/rust/bunker/src/lib.rs b/backend/rust/bunker/src/lib.rs index b1a3c3508b12..9e0f781e0443 100644 --- a/backend/rust/bunker/src/lib.rs +++ b/backend/rust/bunker/src/lib.rs @@ -3,13 +3,17 @@ pub mod pb { include!("../generated/backend.rs"); } +use std::net::SocketAddr; use tonic::transport::Server; pub use crate::pb::backend_server::Backend as BackendService; use crate::pb::backend_server::BackendServer; // Run the backend with the default behavior -pub async fn run(backend: impl BackendService, addr: impl Into) -> anyhow::Result<()> { +pub async fn run( + backend: impl BackendService, + addr: impl Into, +) -> Result<(), Box> { let svc = BackendServer::new(backend); let r = Server::builder() @@ -18,3 +22,4 @@ pub async fn run(backend: impl BackendService, addr: impl Into) -> a .await?; Ok(r) +} diff --git a/backend/rust/bunker/src/service.rs b/backend/rust/bunker/src/service.rs deleted file mode 100644 index 81cf3132cea0..000000000000 --- a/backend/rust/bunker/src/service.rs +++ /dev/null @@ -1,43 +0,0 @@ -//! Contains the service trait for the bunker service. - -use crate::pb::Result as PbResult; -use crate::pb::{ - EmbeddingResult, GenerateImageRequest, HealthMessage, ModelOptions, PredictOptions, Reply, - StatusResponse, TokenizationResponse, TranscriptRequest, TranscriptResult, TtsRequest, -}; -use async_trait::async_trait; -use tokio_stream::wrappers::ReceiverStream; -use tonic::{Request, Response, Status}; - -#[async_trait] -pub trait BackendService>> { - async fn health(&self, request: Request) -> Result, Status>; - async fn predict(&self, request: Request) -> Result, Status>; - async fn load_model( - &self, - request: Request, - ) -> Result, Status>; - async fn predict_stream(&self, request: Request) - -> Result, Status>; // https://github.com/rust-lang/rust/issues/29661 - async fn embedding( - &self, - request: Request, - ) -> Result, Status>; - async fn generate_image( - &self, - request: Request, - ) -> Result, Status>; - async fn audio_transcription( - &self, - request: Request, - ) -> Result, Status>; - async fn tts(&self, request: Request) -> Result, Status>; - async fn tokenize_string( - &self, - request: Request, - ) -> Result, Status>; - async fn status( - &self, - request: Request, - ) -> Result, Status>; -} diff --git a/backend/rust/burn/src/main.rs b/backend/rust/burn/src/main.rs index 11035a14c582..409363eb5688 100644 --- a/backend/rust/burn/src/main.rs +++ b/backend/rust/burn/src/main.rs @@ -3,7 +3,8 @@ use bunker::pb::{ EmbeddingResult, GenerateImageRequest, HealthMessage, ModelOptions, PredictOptions, Reply, StatusResponse, TokenizationResponse, TranscriptRequest, TranscriptResult, TtsRequest, }; -use bunker::service::BackendService; + +use bunker::BackendService; use tokio_stream::wrappers::ReceiverStream; use tonic::{Request, Response, Status}; @@ -14,7 +15,9 @@ use async_trait::async_trait; struct BurnBackend; #[async_trait] -impl BackendService>> for BurnBackend { +impl BackendService for BurnBackend { + type PredictStreamStream = ReceiverStream>; + async fn health(&self, request: Request) -> Result, Status> { // return a Result,Status> let reply = Reply { @@ -84,5 +87,6 @@ impl BackendService>> for BurnBackend { #[tokio::main] async fn main() -> Result<(), Box> { + // call bunker::run with BurnBackend todo!() }