Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
imbolc committed Jun 30, 2024
1 parent 23d2948 commit 8db6ebb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
license = "MIT"
name = "pg_task"
repository = "https://github.com/imbolc/pg_task"
version = "0.0.7"
version = "0.1.0"

[dependencies]
async-trait = "0.1"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ before returning the next step creates a couple of issues:
Use [`NextStep::delay`] instead - it schedules the next step with the delay
and finishes the current one right away.

You can find a runnable example in the [examples/delay.rs][delay-example]

## Retrying Steps

Use [`Step::RETRY_LIMIT`] and [`Step::RETRY_DELAY`] when you need to retry a
Expand All @@ -208,6 +210,7 @@ impl Step<MyTask> for ApiRequest {
}
```
[tutorial-example]: https://github.com/imbolc/pg_task/blob/main/examples/tutorial.rs
[delay-example]: https://github.com/imbolc/pg_task/blob/main/examples/delay.rs

<!-- cargo-sync-readme end -->

Expand Down
5 changes: 1 addition & 4 deletions examples/counter.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! A counter task gives some idea on the worker performatnce
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use pg_task::{NextStep, Step, StepResult};
use serde::{Deserialize, Serialize};
use sqlx::PgPool;
use std::time::Duration;

mod util;

Expand Down Expand Up @@ -54,9 +54,6 @@ pub struct Proceed {
}
#[async_trait]
impl Step<Count> for Proceed {
const RETRY_LIMIT: i32 = 5;
const RETRY_DELAY: Duration = Duration::from_secs(1);

async fn step(self, _db: &PgPool) -> StepResult<Count> {
let Self {
up_to,
Expand Down
1 change: 1 addition & 0 deletions examples/delay.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Scheduling delayed steps
use async_trait::async_trait;
use pg_task::{NextStep, Step, StepResult};
use serde::{Deserialize, Serialize};
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
//! Use [`NextStep::delay`] instead - it schedules the next step with the delay
//! and finishes the current one right away.
//!
//! You can find a runnable example in the [examples/delay.rs][delay-example]
//!
//! ## Retrying Steps
//!
//! Use [`Step::RETRY_LIMIT`] and [`Step::RETRY_DELAY`] when you need to retry a
Expand All @@ -204,6 +206,7 @@
//! }
//! ```
//! [tutorial-example]: https://github.com/imbolc/pg_task/blob/main/examples/tutorial.rs
//! [delay-example]: https://github.com/imbolc/pg_task/blob/main/examples/delay.rs
#![warn(clippy::all, missing_docs, nonstandard_style, future_incompatible)]

Expand Down

0 comments on commit 8db6ebb

Please sign in to comment.