Function sidekiq::with_custom_namespace
source · pub fn with_custom_namespace(namespace: String) -> Box<NamespaceCustomizer>Examples found in repository?
examples/namespaced_demo.rs (line 25)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
// Redis
let manager = RedisConnectionManager::new("redis://127.0.0.1/")?;
let redis = Pool::builder()
.max_size(100)
.connection_customizer(sidekiq::with_custom_namespace("yolo_app".to_string()))
.build(manager)
.await?;
tokio::spawn({
let redis = redis.clone();
async move {
loop {
HelloWorker::perform_async(&redis, ()).await.unwrap();
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
}
});
// Sidekiq server
let mut p = Processor::new(redis.clone(), vec!["default".to_string()]);
// Add known workers
p.register(HelloWorker);
// Start!
p.run().await;
Ok(())
}