mirror of
https://github.com/MeiK2333/river.git
synced 2025-11-04 14:49:40 +08:00
Update
This commit is contained in:
parent
e8e335d284
commit
ef62042fdf
@ -45,6 +45,9 @@ message JudgeResponse {
|
|||||||
CompileError = 6;
|
CompileError = 6;
|
||||||
PresentationError = 7;
|
PresentationError = 7;
|
||||||
SystemError = 8;
|
SystemError = 8;
|
||||||
|
Pending = 9;
|
||||||
|
Compiling = 10;
|
||||||
|
Running = 11;
|
||||||
}
|
}
|
||||||
JudgeResult result = 3;
|
JudgeResult result = 3;
|
||||||
int32 errno = 4;
|
int32 errno = 4;
|
||||||
|
|||||||
14
src/main.rs
14
src/main.rs
@ -1,10 +1,11 @@
|
|||||||
|
use futures::StreamExt;
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use river::river_server::{River, RiverServer};
|
use river::river_server::{River, RiverServer};
|
||||||
use river::{JudgeRequest, JudgeResponse};
|
use river::{JudgeRequest, JudgeResponse};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::Arc;
|
use tokio::time::{delay_for, Duration};
|
||||||
use tokio::sync::mpsc;
|
use tonic::transport::Server;
|
||||||
use tonic::{transport::Server, Request, Response, Status};
|
use tonic::{Request, Response, Status};
|
||||||
|
|
||||||
pub mod river {
|
pub mod river {
|
||||||
tonic::include_proto!("river"); // The string specified here must match the proto package name
|
tonic::include_proto!("river"); // The string specified here must match the proto package name
|
||||||
@ -25,7 +26,7 @@ impl River for RiverService {
|
|||||||
let mut stream = request.into_inner();
|
let mut stream = request.into_inner();
|
||||||
|
|
||||||
let output = async_stream::try_stream! {
|
let output = async_stream::try_stream! {
|
||||||
// while let Some(note) = stream.next().await {
|
while let Some(note) = stream.next().await {
|
||||||
yield river::JudgeResponse {
|
yield river::JudgeResponse {
|
||||||
time_used: 1,
|
time_used: 1,
|
||||||
memory_used: 2,
|
memory_used: 2,
|
||||||
@ -35,7 +36,8 @@ impl River for RiverService {
|
|||||||
stdout: "stdout".into(),
|
stdout: "stdout".into(),
|
||||||
stderr: "stderr".into(),
|
stderr: "stderr".into(),
|
||||||
};
|
};
|
||||||
// }
|
delay_for(Duration::from_millis(10000)).await;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Response::new(Box::pin(output) as Self::JudgeStream))
|
Ok(Response::new(Box::pin(output) as Self::JudgeStream))
|
||||||
@ -44,7 +46,7 @@ impl River for RiverService {
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let addr = "[::1]:50051".parse()?;
|
let addr = "127.0.0.1:4003".parse()?;
|
||||||
let greeter = RiverService::default();
|
let greeter = RiverService::default();
|
||||||
|
|
||||||
Server::builder()
|
Server::builder()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user