diff --git a/.github/workflows/common-tests.yml b/.github/workflows/common-tests.yml index 117b5858..b93db510 100644 --- a/.github/workflows/common-tests.yml +++ b/.github/workflows/common-tests.yml @@ -30,4 +30,5 @@ jobs: -p patchable-async-sleep \ -p serai-db \ -p serai-env \ + -p serai-task \ -p simple-request diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml index f969f755..409f5a9b 100644 --- a/.github/workflows/msrv.yml +++ b/.github/workflows/msrv.yml @@ -24,6 +24,7 @@ jobs: cargo msrv verify --manifest-path common/std-shims/Cargo.toml cargo msrv verify --manifest-path common/env/Cargo.toml cargo msrv verify --manifest-path common/db/Cargo.toml + cargo msrv verify --manifest-path common/task/Cargo.toml cargo msrv verify --manifest-path common/request/Cargo.toml cargo msrv verify --manifest-path common/patchable-async-sleep/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index 444b1756..4266d05a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8922,6 +8922,7 @@ dependencies = [ "parity-scale-codec", "serai-coins-primitives", "serai-primitives", + "serai-task", "tokio", ] @@ -9150,6 +9151,14 @@ dependencies = [ "zeroize", ] +[[package]] +name = "serai-task" +version = "0.1.0" +dependencies = [ + "log", + "tokio", +] + [[package]] name = "serai-validator-sets-pallet" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 16c12262..6fe5fe89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ members = [ "common/patchable-async-sleep", "common/db", "common/env", + "common/task", "common/request", "crypto/transcript", diff --git a/common/task/Cargo.toml b/common/task/Cargo.toml new file mode 100644 index 00000000..f96e4557 --- /dev/null +++ b/common/task/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "serai-task" +version = "0.1.0" +description = "A task schema for Serai services" +license = "AGPL-3.0-only" +repository = "https://github.com/serai-dex/serai/tree/develop/common/task" +authors = ["Luke Parker "] +keywords = [] +edition = "2021" +publish = false +rust-version = "1.75" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +log = { version = "0.4", default-features = false, features = ["std"] } +tokio = { version = "1", default-features = false, features = ["macros", "sync", "time"] } diff --git a/common/task/LICENSE b/common/task/LICENSE new file mode 100644 index 00000000..41d5a261 --- /dev/null +++ b/common/task/LICENSE @@ -0,0 +1,15 @@ +AGPL-3.0-only license + +Copyright (c) 2022-2024 Luke Parker + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License Version 3 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . diff --git a/common/task/README.md b/common/task/README.md new file mode 100644 index 00000000..db1d02ba --- /dev/null +++ b/common/task/README.md @@ -0,0 +1,3 @@ +# Task + +A schema to define tasks to be run ad infinitum. diff --git a/processor/primitives/src/task.rs b/common/task/src/lib.rs similarity index 98% rename from processor/primitives/src/task.rs rename to common/task/src/lib.rs index e8efc64c..b5523cda 100644 --- a/processor/primitives/src/task.rs +++ b/common/task/src/lib.rs @@ -1,3 +1,7 @@ +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![doc = include_str!("../README.md")] +#![deny(missing_docs)] + use core::{future::Future, time::Duration}; use std::sync::Arc; diff --git a/deny.toml b/deny.toml index 7581a9db..66bd4bc6 100644 --- a/deny.toml +++ b/deny.toml @@ -41,6 +41,7 @@ allow = [ exceptions = [ { allow = ["AGPL-3.0"], name = "serai-env" }, + { allow = ["AGPL-3.0"], name = "serai-task" }, { allow = ["AGPL-3.0"], name = "ethereum-schnorr-contract" }, { allow = ["AGPL-3.0"], name = "serai-ethereum-relayer" }, diff --git a/processor/primitives/Cargo.toml b/processor/primitives/Cargo.toml index 6eba2e5b..a950a61b 100644 --- a/processor/primitives/Cargo.toml +++ b/processor/primitives/Cargo.toml @@ -28,3 +28,5 @@ borsh = { version = "1", default-features = false, features = ["std", "derive", log = { version = "0.4", default-features = false, features = ["std"] } tokio = { version = "1", default-features = false, features = ["macros", "sync", "time"] } + +serai-task = { path = "../../common/task", default-features = false } diff --git a/processor/primitives/src/lib.rs b/processor/primitives/src/lib.rs index cc915ca2..371bdafb 100644 --- a/processor/primitives/src/lib.rs +++ b/processor/primitives/src/lib.rs @@ -10,7 +10,7 @@ use scale::{Encode, Decode}; use borsh::{BorshSerialize, BorshDeserialize}; /// A module for task-related structs and functionality. -pub mod task; +pub use serai_task as task; mod output; pub use output::*;