mirror of
https://github.com/mii443/rs-docker-bot.git
synced 2025-08-22 16:15:40 +00:00
add container to pool
This commit is contained in:
@ -24,6 +24,7 @@ impl ContainerPool {
|
||||
false
|
||||
}
|
||||
}) {
|
||||
println!("Using container from pool");
|
||||
let container = pool[i].clone();
|
||||
pool.remove(i);
|
||||
container
|
||||
@ -31,4 +32,11 @@ impl ContainerPool {
|
||||
Container::from_language(language).await
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn add_container(&mut self, language: Language) {
|
||||
self.containers
|
||||
.lock()
|
||||
.await
|
||||
.push(Container::from_language(language).await);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,12 @@ async fn main() -> Result<(), ()> {
|
||||
let intents =
|
||||
serenity::GatewayIntents::non_privileged() | serenity::GatewayIntents::MESSAGE_CONTENT;
|
||||
|
||||
let mut pool = ContainerPool::new();
|
||||
for _ in 0..10 {
|
||||
pool.add_container(config.get_language(&"Ruby".to_string()).unwrap())
|
||||
.await;
|
||||
}
|
||||
|
||||
let framework = poise::Framework::builder()
|
||||
.setup({
|
||||
let config = config.clone();
|
||||
@ -57,7 +63,7 @@ async fn main() -> Result<(), ()> {
|
||||
Box::pin(async move {
|
||||
Ok(Data {
|
||||
config: Arc::new(Mutex::new(config)),
|
||||
container_pool: Arc::new(Mutex::new(ContainerPool::new())),
|
||||
container_pool: Arc::new(Mutex::new(pool)),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user