dockworker
dockworker copied to clipboard
Fixed Send + Sync issue with the list_containers function when called by tokio::task::spawn
fixes #159
The example change probably won't need to get merged in. Just wanted to show some context that caused compilation failures in some contexts
@DrWalrus1 I have confirmed the issue reproduction, but I have a few questions. First, it seems that there are multiple places in the code that have a similar issue aside from list_containers. For instance, is there no problem with stop_container ? Also, instead of encapsulating the entire creation of the URL parameters in a closure, wouldn’t it be possible to resolve the issue by handling it as shown below?
let param = {
let mut param = url::form_urlencoded::Serializer::new(String::new());
param.append_pair("all", &(all.unwrap_or(false) as u64).to_string());
if let Some(limit) = limit {
param.append_pair("limit", &limit.to_string());
}
param.append_pair("size", &(size.unwrap_or(false) as u64).to_string());
param.append_pair("filters", &serde_json::to_string(&filters).unwrap());
param.finish()
};
debug!("filter: {}", serde_json::to_string(&filters).unwrap());
let res = self
.http_client()
.get(self.headers(), &format!("/containers/json?{}", param))
.await?;
api_result(res).map_err(Into::into)
Notes taken aboard. I've expanded the fixes as you advised
Look good thank you 👍