-
-
Notifications
You must be signed in to change notification settings - Fork 80
Closed
Description
The hello world in readme seemed a bit long compared to axum few lines.
use axum::{
routing::get,
Router,
};
#[tokio::main]
async fn main() {
// build our application with a single route
let app = Router::new().route("/", get(|| async { "Hello, World!" }));
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}With apalis:
use apalis::prelude::*;
use serde::{Deserialize, Serialize};
use apalis_redis::{RedisStorage, Config};
#[derive(Debug, Deserialize, Serialize)]
struct Email {
to: String,
}
async fn send_email(job: Email, data: Data<usize>) -> Result<(), Error> {
Ok(())
}
#[tokio::main]
async fn main() {
let redis = std::env::var("REDIS_URL").expect("Missing REDIS_URL env variable");
let conn = apalis_redis::connect(redis).await.unwrap();
let storage = RedisStorage::new(conn);
Monitor::new()
.register({
WorkerBuilder::new(&format!("quick-sand"))
.concurrency(2)
.data(0usize)
.backend(storage.clone())
.build_fn(send_email)
})
.run()
.await
.unwrap();
}Can we simplify it further?
use apalis_redis::RedisStorage;
use apalis::{Monitor, Router, task};
#[tokio::main]
async fn main() {
let monitor = Monitor::new().register(task(|| async { "Hello, world!" }));
let storage = RedisStorage::from_url("redis://").await.unwrap();
apalis::start(storage, monitor).await.unwrap();
}I don't really have that much experience with apalis and I did notice that apalis supports multiple backends. Maybe something simpler would make it less overwhelming for new users?
Metadata
Metadata
Assignees
Labels
No labels