forked from rusty-celery/rusty-celery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement backend integration + redis backend
- care was put into being able to run rust celery both as a worker or client with python worker/clients. - for that the TaskError has now a format that captures python exceptions and lets python report rust errors - only content type of application/json is supported for now - the interface to retrieve task results using AsyncResult is minimal. only a timeout option is currently supported To use the redis backend, a celery app can be instantiated like this: ``` celery::app!( broker = RedisBroker { std::env::var("REDIS_ADDR").unwrap() }, backend = RedisBackend { std::env::var("REDIS_ADDR").unwrap() }, tasks = [add, expected_failure, unexpected_failure, task_with_timeout], task_routes = [ "*" => "celery", ], ) .await ``` The result can then be fetched using async result: ```rust pub async fn add(x: i32, y: i32) -> TaskResult<i32> { info!("adding {} + {}", x, y); Ok(x + y) } let task = tasks::add::new(1, 2); let result = app.send_task(task).await.expect("send task"); assert_eq!(3, result.get().fetch().await.expect("get task")); ```
- Loading branch information
Showing
16 changed files
with
854 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.