Skip to content

Commit

Permalink
Remove services.rs
Browse files Browse the repository at this point in the history
Signed-off-by: Aisuko <[email protected]>
  • Loading branch information
Aisuko committed Oct 20, 2023
1 parent b92677b commit a2bb86f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 47 deletions.
7 changes: 6 additions & 1 deletion backend/rust/bunker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SocketAddr>) -> anyhow::Result<()> {
pub async fn run(
backend: impl BackendService,
addr: impl Into<SocketAddr>,
) -> Result<(), Box<dyn std::error::Error>> {
let svc = BackendServer::new(backend);

let r = Server::builder()
Expand All @@ -18,3 +22,4 @@ pub async fn run(backend: impl BackendService, addr: impl Into<SocketAddr>) -> a
.await?;

Ok(r)
}
43 changes: 0 additions & 43 deletions backend/rust/bunker/src/service.rs

This file was deleted.

8 changes: 6 additions & 2 deletions backend/rust/burn/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -14,7 +15,9 @@ use async_trait::async_trait;
struct BurnBackend;

#[async_trait]
impl BackendService<ReceiverStream<Result<Reply, Status>>> for BurnBackend {
impl BackendService for BurnBackend {
type PredictStreamStream = ReceiverStream<Result<Reply, Status>>;

async fn health(&self, request: Request<HealthMessage>) -> Result<Response<Reply>, Status> {
// return a Result<Response<Reply>,Status>
let reply = Reply {
Expand Down Expand Up @@ -84,5 +87,6 @@ impl BackendService<ReceiverStream<Result<Reply, Status>>> for BurnBackend {

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// call bunker::run with BurnBackend
todo!()
}
3 changes: 2 additions & 1 deletion backend/rust/codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

//! Here is for the more complex situation of code generation. For example, defind the constant for
//! the different build target.

0 comments on commit a2bb86f

Please sign in to comment.