#![allow(clippy::print_stdout)]
#[path = "shared/remote_ping.rs"]
mod remote_shared_task;
use std::sync::Arc;
use std::time::Duration;
use boson::{configure, Boson, JsonExecutionContextFactory};
use boson_backend_redis::{RedisQueueBackend, RedisQueueConfig};
use remote_shared_task::{RemotePing, RemotePingParams};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let url = std::env::var("BOSON_REDIS_URL").unwrap_or_else(|_| "redis://127.0.0.1:6379".into());
let backend = RedisQueueBackend::connect(RedisQueueConfig {
url: url.clone(),
..RedisQueueConfig::default()
})
.await?;
let boson = Boson::builder()
.queue_backend(Arc::new(backend))
.execution_context_factory(JsonExecutionContextFactory)
.auto_registry()
.without_worker()
.build()?;
configure(boson);
let job_id = RemotePing::send_with(
serde_json::json!({"System": {"operation": "remote-demo"}}),
RemotePingParams {
message: "hello from redis fleet enqueue host".into(),
},
)
.await?;
println!("enqueued job_id={job_id} (url={url})");
tokio::time::sleep(Duration::from_millis(200)).await;
Ok(())
}