Update readme with execution diagram

This commit is contained in:
Rafael Caricio 2023-03-18 16:26:12 +01:00
parent ed6a784e02
commit 617bd71bd1
Signed by: rafaelcaricio
GPG key ID: 3C86DBCE8E93C947
3 changed files with 22 additions and 2 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
Cargo.lock
docs/content/docs/CHANGELOG.md
docs/content/docs/README.md
.DS_Store

View file

@ -31,6 +31,25 @@ Here are some of the Backie's key features:
- Task timeout: Tasks are retried if they are not completed in time
- Scheduling of tasks: Tasks can be scheduled to be executed at a specific time
## Task execution protocol
The following diagram shows the protocol used to execute tasks:
```mermaid
stateDiagram-v2
[*] --> Ready
Ready --> Running: Task is picked up by a worker
Running --> Done: Task is finished
Running --> Failed: Task failed
Failed --> Ready: Task is retried
Failed --> [*]: Task is not retried anymore, max retries reached
Done --> [*]
```
When a task goes from `Running` to `Failed` it is retried. The number of retries is controlled by the
[`BackgroundTask::MAX_RETRIES`] attribute. The default implementation uses `3` retries.
## Safety
This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.

View file

@ -53,8 +53,8 @@ pub trait BackgroundTask: Serialize + DeserializeOwned + Sync + Send + 'static {
/// Number of retries for tasks.
///
/// By default, it is set to 5.
const MAX_RETRIES: i32 = 5;
/// By default, it is set to 3.
const MAX_RETRIES: i32 = 3;
/// The application data provided to this task at runtime.
type AppData: Clone + Send + 'static;