Skip to content

Commit

Permalink
feat(jstzd): define Task trait
Browse files Browse the repository at this point in the history
  • Loading branch information
huancheng-trili committed Sep 16, 2024
1 parent 1475a6a commit 027eeb5
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 2 deletions.
85 changes: 83 additions & 2 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"crates/jstz_rollup",
"crates/jstz_sdk",
"crates/jstz_wpt",
"crates/jstzd",
"crates/octez"
]

Expand Down Expand Up @@ -98,6 +99,8 @@ tokio-util = "0.7.10"
url = "2.4.1"
urlpattern = "0.2.0"
wasm-bindgen = "0.2.92"
async-dropper = { version = "0.3.1", features = ["tokio", "simple"] }
async-trait = "0.1.82"

[workspace.dependencies.tezos-smart-rollup]
version = "0.2.2"
Expand Down
13 changes: 13 additions & 0 deletions crates/jstzd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "jstzd"
authors.workspace = true
version.workspace = true
edition.workspace = true
repository.workspace = true

[dependencies]
anyhow.workspace = true
tokio.workspace = true
async-dropper.workspace = true
async-trait.workspace = true
futures-util.workspace = true
1 change: 1 addition & 0 deletions crates/jstzd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod task;
16 changes: 16 additions & 0 deletions crates/jstzd/src/task/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use anyhow::Result;
use async_trait::async_trait;

#[async_trait]
pub trait Task: Sized {
type Config;

/// Spins up the task with the given config.
async fn spawn(config: Self::Config) -> Result<Self>;

/// Aborts the running task.
async fn kill(&mut self) -> Result<()>;

/// Conducts a health check on the running task.
async fn health_check(&self) -> Result<bool>;
}

0 comments on commit 027eeb5

Please sign in to comment.