Skip to content

Commit

Permalink
Concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
imbolc committed Jun 28, 2024
1 parent 4cf5154 commit 179cc1b
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 190 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async-trait = "0.1"
chrono = { version = "0.4", features = ["std", "serde"] }
code-path = "0.3"
displaydoc = "0.2"
num_cpus = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
source-chain = "0.1"
Expand Down
3 changes: 1 addition & 2 deletions examples/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ impl Step<Count> for Proceed {
const RETRY_DELAY: Duration = Duration::from_secs(1);

async fn step(self, _db: &PgPool) -> StepResult<Count> {
// return Err(anyhow::anyhow!("bailing").into());
let Self {
up_to,
mut cur,
started_at,
} = self;

cur += 1;
// println!("1..{up_to}: {cur}");
if cur < up_to {
NextStep::now(Proceed {
up_to,
Expand Down
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ pub enum Error {
WaiterConnect(#[source] sqlx::Error),
/// waiter can't start listening to tables changes
WaiterListen(#[source] sqlx::Error),
/// unreachable: worker semaphore is closed
UnreachableWorkerSemaphoreClosed(#[source] tokio::sync::AcquireError),
}

/// The crate result
pub type Result<T> = StdResult<T, Error>;

/// Error of a task step
pub type StepError = Box<dyn StdError + 'static>;
pub type StepError = Box<dyn StdError + 'static + Send + Sync>;

/// Result returning from task steps
pub type StepResult<T> = StdResult<NextStep<T>, StepError>;
Loading

0 comments on commit 179cc1b

Please sign in to comment.