MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / start

Function start

fendermint/testing/materializer/src/docker/dropper.rs:75–136  ·  view source on GitHub ↗

Start a background task to remove docker constructs. The loop will exit when all clones of the sender channel have been dropped.

(docker: Docker)

Source from the content-addressed store, hash-verified

73///
74/// The loop will exit when all clones of the sender channel have been dropped.
75pub fn start(docker: Docker) -> (DropHandle, DropChute) {
76 let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
77
78 let handle = tokio::task::spawn(async move {
79 while let Some(cmd) = rx.recv().await {
80 match cmd {
81 DropCommand::DropNetwork(id) => {
82 eprintln!("dropping docker network {id}");
83 if let Err(e) = docker.remove_network(&id).await {
84 eprintln!("failed to remove docker network: {e}");
85 tracing::error!(
86 error = e.to_string(),
87 id,
88 "failed to remove docker network"
89 );
90 }
91 }
92 DropCommand::DropContainer(id) => {
93 eprintln!("dropping docker container {id}");
94
95 if let Err(e) = docker
96 .stop_container(
97 &id,
98 Some(StopContainerOptions {
99 t: KILL_TIMEOUT_SECS,
100 }),
101 )
102 .await
103 {
104 tracing::error!(
105 error = e.to_string(),
106 id,
107 "failed to stop docker container"
108 );
109 }
110
111 if let Err(e) = docker
112 .remove_container(
113 &id,
114 Some(RemoveContainerOptions {
115 force: true,
116 v: true,
117 ..Default::default()
118 }),
119 )
120 .await
121 {
122 eprintln!("failed to remove container: {e}");
123
124 tracing::error!(
125 error = e.to_string(),
126 id,
127 "failed to remove docker container"
128 );
129 }
130 }
131 }
132 }

Callers 4

newMethod · 0.70
take_dropperMethod · 0.70
test_networkFunction · 0.70
make_runnerFunction · 0.70

Calls 1

recvMethod · 0.80

Tested by 1

test_networkFunction · 0.56