Skip to content

Commit

Permalink
Fix crates that depend on new ttrpc
Browse files Browse the repository at this point in the history
Signed-off-by: Maksym Pavlenko <[email protected]>
  • Loading branch information
mxpv committed Oct 3, 2024
1 parent 217f0ee commit 8688bcc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
4 changes: 1 addition & 3 deletions crates/shim-protos/examples/ttrpc-server-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ impl Task for FakeServer {
async fn main() {
simple_logger::SimpleLogger::new().init().unwrap();

let t = Box::new(FakeServer::new()) as Box<dyn Task + Send + Sync>;
let t = Arc::new(t);
let tservice = create_task(t);
let tservice = create_task(Arc::new(FakeServer::new()));

let mut server = Server::new()
.bind("unix:///tmp/shim-proto-ttrpc-001")
Expand Down
4 changes: 1 addition & 3 deletions crates/shim-protos/examples/ttrpc-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ impl Task for FakeServer {
fn main() {
simple_logger::SimpleLogger::new().init().unwrap();

let t = Box::new(FakeServer::new()) as Box<dyn Task + Send + Sync>;
let t = Arc::new(t);
let tservice = create_task(t);
let tservice = create_task(Arc::new(FakeServer::new()));

let mut server = Server::new()
.bind("unix:///tmp/shim-proto-ttrpc-001")
Expand Down
10 changes: 3 additions & 7 deletions crates/shim-protos/tests/ttrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ fn create_ttrpc_context() -> (

#[test]
fn test_task_method_num() {
let server = Arc::new(Box::new(FakeServer::new()) as Box<dyn Task + Send + Sync>);
let task = create_task(server.clone());

let task = create_task(Arc::new(FakeServer::new()));
assert_eq!(task.len(), 17);
}

Expand All @@ -98,8 +96,7 @@ fn test_create_task() {
request.set_timeout_nano(10000);
request.set_metadata(ttrpc::context::to_pb(ctx.metadata.clone()));

let server = Arc::new(Box::new(FakeServer::new()) as Box<dyn Task + Send + Sync>);
let task = create_task(server.clone());
let task = create_task(Arc::new(FakeServer::new()));
let create = task.get("/containerd.task.v2.Task/Create").unwrap();
create.handler(ctx, request).unwrap();

Expand Down Expand Up @@ -140,8 +137,7 @@ fn test_delete_task() {
request.set_timeout_nano(10000);
request.set_metadata(ttrpc::context::to_pb(ctx.metadata.clone()));

let server = Arc::new(Box::new(FakeServer::new()) as Box<dyn Task + Send + Sync>);
let task = create_task(server.clone());
let task = create_task(Arc::new(FakeServer::new()));
let delete = task.get("/containerd.task.v2.Task/Delete").unwrap();
delete.handler(ctx, request).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion crates/shim/src/asynchronous/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ where

let publisher = RemotePublisher::new(&ttrpc_address).await?;
let task = shim.create_task_service(publisher).await;
let task_service = create_task(Arc::new(Box::new(task)));
let task_service = create_task(Arc::new(task));
let mut server = Server::new().register_service(task_service);
server = server.add_listener(SOCKET_FD)?;
server = server.set_domain_unix();
Expand Down
3 changes: 1 addition & 2 deletions crates/shim/src/asynchronous/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ mod tests {
let barrier2 = barrier.clone();
let server_thread = tokio::spawn(async move {
let listener = UnixListener::bind(&path1).unwrap();
let t = Arc::new(Box::new(server) as Box<dyn Events + Send + Sync>);
let service = create_events(t);
let service = create_events(Arc::new(server));
let mut server = Server::new()
.set_domain_unix()
.add_listener(listener.as_raw_fd())
Expand Down

0 comments on commit 8688bcc

Please sign in to comment.