Skip to content

Commit

Permalink
updating cargo.toml (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f authored Mar 6, 2023
1 parent 4d7839a commit 5993ba1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
15 changes: 7 additions & 8 deletions tanour-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ capnpc = { git = "https://github.com/capnproto/capnproto-rust" }
[dependencies]
capnp = { git = "https://github.com/capnproto/capnproto-rust" }
capnp-rpc = { git = "https://github.com/capnproto/capnproto-rust" }
futures = "0.3.0"
tokio = { version = "0.2.0", features = [
futures = "0.3"
tokio = { version = "1.26", features = [
"time",
"sync",
"rt-util",
"rt-core",
"net",
"macros",
"rt",
"rt-multi-thread",
] }
tokio-util = { version = "0.3.0", features = ["compat"] }
tanour = { version = "0.2.0" }
async-std = "1.5.0"
tokio-util = { version = "0.7", features = ["compat"] }
tanour = { version = "0.2.0", path = "../tanour" }
log = "0.4"
simple_logger = "1.4.0"
simple_logger = "4.0"
2 changes: 1 addition & 1 deletion tanour-server/src/executor_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl executor::Server for ExecutorImpl {
return Err(Error::failed(format!("{e}")));
}
Ok(result_data) => {
tokio::time::delay_for(std::time::Duration::from_millis(10_u64)).await;
tokio::time::sleep(std::time::Duration::from_millis(10_u64)).await;

let mut builder = results.get().get_result_data().unwrap();
builder.set_data(&result_data);
Expand Down
23 changes: 12 additions & 11 deletions tanour-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ mod executor_impl;

use capnp_rpc::{rpc_twoparty_capnp, twoparty, RpcSystem};
use executor_impl::ExecutorImpl;
use futures::{AsyncReadExt, FutureExt, TryFutureExt};
use futures::{AsyncReadExt, TryFutureExt};
use std::net::ToSocketAddrs;
use tanour_capnp::executor;

use tokio::net::TcpListener;

#[tokio::main]
Expand All @@ -22,33 +23,33 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
}

let addr = args[1]
.to_socket_addrs()
.unwrap()
.to_socket_addrs()?
.next()
.expect("could not parse address");

tokio::task::LocalSet::new()
.run_until(async move {
let mut listener = TcpListener::bind(&addr).await?;
let executor_impl = ExecutorImpl {};
let executor: executor::Client = capnp_rpc::new_client(executor_impl);
let listener = TcpListener::bind(&addr).await?;

loop {
let (stream, _) = listener.accept().await?;
stream.set_nodelay(true)?;
let (reader, writer) =
tokio_util::compat::Tokio02AsyncReadCompatExt::compat(stream).split();
tokio_util::compat::TokioAsyncReadCompatExt::compat(stream).split();
let network = twoparty::VatNetwork::new(
reader,
writer,
rpc_twoparty_capnp::Side::Server,
Default::default(),
);

let rpc_system = RpcSystem::new(Box::new(network), Some(executor.clone().client));
tokio::task::spawn_local(Box::pin(
rpc_system.map_err(|e| println!("error: {e:?}")).map(|_| ()),
));
let executor_impl = ExecutorImpl {};
let executor_client: executor::Client = capnp_rpc::new_client(executor_impl);
let rpc_system = RpcSystem::new(Box::new(network), Some(executor_client.client));

tokio::task::spawn_local(
rpc_system.map_err(|err| log::error!("rpc_system error : {err}")),
);
}
})
.await
Expand Down

0 comments on commit 5993ba1

Please sign in to comment.