From bd62d53a0b59bd4c847bae412ef0e8370a1a3145 Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Sat, 31 Dec 2022 23:51:52 +0000 Subject: [PATCH 01/15] Update --- Cargo.toml | 2 +- acme/Cargo.toml | 12 ++++++------ crates/compilers/Cargo.toml | 2 +- crates/conduits/Cargo.toml | 2 +- crates/core/Cargo.toml | 2 +- crates/gateways/Cargo.toml | 4 ++-- crates/net/Cargo.toml | 2 +- crates/pipelines/Cargo.toml | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f95f7201..1a21e81b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" homepage = "https://github.com/FL03/acme/wikis" license = "Apache-2.0" repository = "https://github.com/FL03/acme" -version = "0.2.4" # TODO - Update cargo package version +version = "0.2.5" # TODO - Update cargo package version [workspace] default-members = [ diff --git a/acme/Cargo.toml b/acme/Cargo.toml index 2c6e6c1a..13ad85a7 100644 --- a/acme/Cargo.toml +++ b/acme/Cargo.toml @@ -32,12 +32,12 @@ pipelines = ["acme-pipelines"] [build-dependencies] [dependencies] -acme-conduits = { features = [], optional = true, path = "../crates/conduits", version = "0.2.4" } -acme-core = { features = [], optional = true, path = "../crates/core", version = "0.2.4" } -acme-compilers = { features = [], optional = true, path = "../crates/compilers", version = "0.2.4" } -acme-gateways = { features = [], optional = true, path = "../crates/gateways", version = "0.2.4" } -acme-net = { features = [], optional = true, path = "../crates/net", version = "0.2.4" } -acme-pipelines = { features = [], optional = true, path = "../crates/pipelines", version = "0.2.4" } +acme-conduits = { features = [], optional = true, path = "../crates/conduits", version = "0.2.5" } +acme-core = { features = [], optional = true, path = "../crates/core", version = "0.2.5" } +acme-compilers = { features = [], optional = true, path = "../crates/compilers", version = "0.2.5" } +acme-gateways = { features = [], optional = true, path = "../crates/gateways", version = "0.2.5" } +acme-net = { features = [], optional = true, path = "../crates/net", version = "0.2.5" } +acme-pipelines = { features = [], optional = true, path = "../crates/pipelines", version = "0.2.5" } [package.metadata.docs.rs] all-features = true diff --git a/crates/compilers/Cargo.toml b/crates/compilers/Cargo.toml index b40b2151..6633e388 100644 --- a/crates/compilers/Cargo.toml +++ b/crates/compilers/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["scsys"] license = "Apache-2.0" name = "acme-compilers" repository = "https://github.com/FL03/acme" -version = "0.2.4" +version = "0.2.5" [lib] crate-type = ["cdylib", "rlib"] diff --git a/crates/conduits/Cargo.toml b/crates/conduits/Cargo.toml index 4b589702..f0f317b2 100644 --- a/crates/conduits/Cargo.toml +++ b/crates/conduits/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["scsys"] license = "Apache-2.0" name = "acme-conduits" repository = "https://github.com/FL03/acme" -version = "0.2.4" +version = "0.2.5" [lib] crate-type = ["cdylib", "rlib"] diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index bc19c6a2..83b83597 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["scsys"] license = "Apache-2.0" name = "acme-core" repository = "https://github.com/FL03/acme" -version = "0.2.4" +version = "0.2.5" [features] default = [ "cli"] diff --git a/crates/gateways/Cargo.toml b/crates/gateways/Cargo.toml index 12b9cdb0..18c70d93 100644 --- a/crates/gateways/Cargo.toml +++ b/crates/gateways/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["scsys"] license = "Apache-2.0" name = "acme-gateways" repository = "https://github.com/FL03/acme" -version = "0.2.4" +version = "0.2.5" [lib] crate-type = ["cdylib", "rlib"] @@ -20,7 +20,7 @@ axum = { features =["headers", "http2", "macros", "ws"], version = "0.6.0" } clap = { features = ["derive"], version = "4.0.29" } http = "0.2.8" hyper = { features = ["full"], version = "0.14.23" } -lru = "0.8.1" +lru = "0.9" rust-s3 = {features = ["with-tokio"], version = "0.32.3" } scsys = { features = ["full"], version = "0.1.38" } serde = { features = ["derive"], version = "1" } diff --git a/crates/net/Cargo.toml b/crates/net/Cargo.toml index 83f4409e..b99eecae 100644 --- a/crates/net/Cargo.toml +++ b/crates/net/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["scsys"] license = "Apache-2.0" name = "acme-net" repository = "https://github.com/FL03/acme" -version = "0.2.4" +version = "0.2.5" [lib] crate-type = ["cdylib", "rlib"] diff --git a/crates/pipelines/Cargo.toml b/crates/pipelines/Cargo.toml index 822aadac..0332bc2d 100644 --- a/crates/pipelines/Cargo.toml +++ b/crates/pipelines/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["scsys"] license = "Apache-2.0" name = "acme-pipelines" repository = "https://github.com/FL03/acme" -version = "0.2.4" +version = "0.2.5" [lib] crate-type = ["cdylib", "rlib"] From 1af4d079c027b0a91d91ae8ffcc34e0f770eb05c Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Sun, 1 Jan 2023 13:57:02 +0000 Subject: [PATCH 02/15] Update --- .github/dependabot.yml | 14 ++++++-- .github/workflows/rust.yml | 3 ++ Cargo.toml | 3 ++ acme/Cargo.toml | 20 +++++++++-- acme/src/lib.rs | 6 +++- {crates/core => core}/Cargo.toml | 2 +- {crates/core => core}/src/events/event.rs | 0 {crates/core => core}/src/events/mod.rs | 0 {crates/core => core}/src/events/opts.rs | 0 core/src/handlers/handler.rs | 9 +++++ core/src/handlers/mod.rs | 30 ++++++++++++++++ {crates/core => core}/src/lib.rs | 3 ++ {crates/core => core}/src/primitives.rs | 0 {crates/core => core}/src/sessions/mod.rs | 0 {crates/core => core}/src/sessions/session.rs | 5 +-- {crates/core => core}/src/specs/apps.rs | 0 {crates/core => core}/src/specs/cli.rs | 14 ++++---- {crates/core => core}/src/specs/mod.rs | 17 ++-------- {crates/core => core}/src/utils.rs | 0 {crates/core => core}/tests/default.rs | 0 crates/compilers/Cargo.toml | 2 +- crates/conduits/Cargo.toml | 3 +- crates/gateways/Cargo.toml | 2 +- crates/net/Cargo.toml | 4 +-- crates/net/src/lib.rs | 2 +- crates/pipelines/Cargo.toml | 2 +- derive/Cargo.toml | 34 +++++++++++++++++++ derive/src/lib.rs | 1 + macros/Cargo.toml | 33 ++++++++++++++++++ macros/src/lib.rs | 1 + xtask/src/main.rs | 6 ++++ 31 files changed, 176 insertions(+), 40 deletions(-) rename {crates/core => core}/Cargo.toml (94%) rename {crates/core => core}/src/events/event.rs (100%) rename {crates/core => core}/src/events/mod.rs (100%) rename {crates/core => core}/src/events/opts.rs (100%) create mode 100644 core/src/handlers/handler.rs create mode 100644 core/src/handlers/mod.rs rename {crates/core => core}/src/lib.rs (84%) rename {crates/core => core}/src/primitives.rs (100%) rename {crates/core => core}/src/sessions/mod.rs (100%) rename {crates/core => core}/src/sessions/session.rs (88%) rename {crates/core => core}/src/specs/apps.rs (100%) rename {crates/core => core}/src/specs/cli.rs (67%) rename {crates/core => core}/src/specs/mod.rs (71%) rename {crates/core => core}/src/utils.rs (100%) rename {crates/core => core}/tests/default.rs (100%) create mode 100644 derive/Cargo.toml create mode 100644 derive/src/lib.rs create mode 100644 macros/Cargo.toml create mode 100644 macros/src/lib.rs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2c4e0673..1e074507 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,15 +13,23 @@ updates: schedule: interval: daily - package-ecosystem: cargo - directory: /crates/compilers + directory: /core schedule: interval: daily - package-ecosystem: cargo - directory: /crates/conduits + directory: /derive + schedule: + interval: daily + - package-ecosystem: cargo + directory: /macros schedule: interval: daily - package-ecosystem: cargo - directory: /crates/core + directory: /crates/compilers + schedule: + interval: daily + - package-ecosystem: cargo + directory: /crates/conduits schedule: interval: daily - package-ecosystem: cargo diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bfe65aa8..1f4bc571 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -37,6 +37,7 @@ jobs: features: if: ${{ github.event.inputs.publish }} name: Publish + needs: [ build ] runs-on: ubuntu-latest strategy: matrix: @@ -44,7 +45,9 @@ jobs: - acme-compilers - acme-conduits - acme-core + - acme-derive - acme-gateways + - acme-macros - acme-net - acme-pipelines steps: diff --git a/Cargo.toml b/Cargo.toml index 1a21e81b..7e9603a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,9 @@ default-members = [ exclude = [ "xtask" ] members = [ "acme", + "core", + "derive", + "macros", "crates/*", ] diff --git a/acme/Cargo.toml b/acme/Cargo.toml index 13ad85a7..7b7df4f7 100644 --- a/acme/Cargo.toml +++ b/acme/Cargo.toml @@ -10,7 +10,7 @@ name = "acme" publish = true readme = "README.md" repository = "https://github.com/scattered-systems/acme" -version = "0.2.4" # TODO - Update cargo package version +version = "0.2.5" # TODO - Update cargo package version [lib] crate-type = ["cdylib", "rlib"] @@ -18,9 +18,21 @@ test = true [features] default = ["core"] -full = ["conduits", "core", "compilers", "extras", "gateways", "net", "pipelines",] +full = [ + "conduits", + "core", + "compilers", + "derive", + "extras", + "gateways", + "macros", + "net", + "pipelines", +] core = ["acme-core"] +derive = ["acme-derive/default"] +macros = ["acme-macros/default"] extras = [] net = ["acme-net"] @@ -33,9 +45,11 @@ pipelines = ["acme-pipelines"] [dependencies] acme-conduits = { features = [], optional = true, path = "../crates/conduits", version = "0.2.5" } -acme-core = { features = [], optional = true, path = "../crates/core", version = "0.2.5" } +acme-core = { features = [], optional = true, path = "../core", version = "0.2.5" } acme-compilers = { features = [], optional = true, path = "../crates/compilers", version = "0.2.5" } +acme-derive = { features = [], optional = true, path = "../derive", version = "0.2.5" } acme-gateways = { features = [], optional = true, path = "../crates/gateways", version = "0.2.5" } +acme-macros = { features = [], optional = true, path = "../macros", version = "0.2.5" } acme-net = { features = [], optional = true, path = "../crates/net", version = "0.2.5" } acme-pipelines = { features = [], optional = true, path = "../crates/pipelines", version = "0.2.5" } diff --git a/acme/src/lib.rs b/acme/src/lib.rs index be374fe0..bfa76416 100644 --- a/acme/src/lib.rs +++ b/acme/src/lib.rs @@ -11,14 +11,19 @@ pub use acme_compilers as compilers; pub use acme_conduits as conduits; #[cfg(feature = "core")] pub use acme_core::*; +#[cfg(feature = "derive")] +pub use acme_derive::*; #[cfg(feature = "gateways")] pub use acme_gateways as gateways; +#[cfg(feature = "macros")] +pub use acme_macros::*; #[cfg(feature = "net")] pub use acme_net as net; #[cfg(feature = "pipelines")] pub use acme_pipelines as pipelines; pub mod prelude { + pub use super::*; #[cfg(feature = "compilers")] pub use super::compilers::*; @@ -30,7 +35,6 @@ pub mod prelude { pub use super::net::*; #[cfg(feature = "pipelines")] pub use super::pipelines::*; - pub use super::*; #[cfg(feature = "core")] pub use super::{events::*, sessions::*}; } diff --git a/crates/core/Cargo.toml b/core/Cargo.toml similarity index 94% rename from crates/core/Cargo.toml rename to core/Cargo.toml index 83b83597..7fd4c15b 100644 --- a/crates/core/Cargo.toml +++ b/core/Cargo.toml @@ -30,7 +30,7 @@ axum-core = "0.3.0" clap = { features = ["cargo", "derive", "env"], optional = true, version = "4.0.29" } config = "0.13.3" futures = "0.3.25" -scsys = { features = ["full"], version = "0.1.38" } +scsys = { features = ["full"], version = "0.1.39" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } diff --git a/crates/core/src/events/event.rs b/core/src/events/event.rs similarity index 100% rename from crates/core/src/events/event.rs rename to core/src/events/event.rs diff --git a/crates/core/src/events/mod.rs b/core/src/events/mod.rs similarity index 100% rename from crates/core/src/events/mod.rs rename to core/src/events/mod.rs diff --git a/crates/core/src/events/opts.rs b/core/src/events/opts.rs similarity index 100% rename from crates/core/src/events/opts.rs rename to core/src/events/opts.rs diff --git a/core/src/handlers/handler.rs b/core/src/handlers/handler.rs new file mode 100644 index 00000000..79b990a1 --- /dev/null +++ b/core/src/handlers/handler.rs @@ -0,0 +1,9 @@ +/* + Appellation: handler + Contrib: FL03 + Description: ... summary ... +*/ + +pub struct Handler { + +} \ No newline at end of file diff --git a/core/src/handlers/mod.rs b/core/src/handlers/mod.rs new file mode 100644 index 00000000..a83d0136 --- /dev/null +++ b/core/src/handlers/mod.rs @@ -0,0 +1,30 @@ +/* + Appellation: handlers + Contrib: FL03 + Description: ... summary ... +*/ +pub use self::handler::*; + +pub(crate) mod handler; + +pub(crate) mod specs { + use async_trait::async_trait; + + /// + #[async_trait] + pub trait AsyncHandle: Clone + Send + Sync { + type Error: std::error::Error + Send + Sync + 'static; + + async fn handler(&self) -> Result<&Self, Self::Error> + where + Self: Sized; + } + /// + pub trait Handle: Clone { + type Error: std::error::Error + 'static; + + fn handler(&self) -> Result<&Self, Self::Error> + where + Self: Sized; + } +} \ No newline at end of file diff --git a/crates/core/src/lib.rs b/core/src/lib.rs similarity index 84% rename from crates/core/src/lib.rs rename to core/src/lib.rs index f4a8db5b..b5cf5b6c 100644 --- a/crates/core/src/lib.rs +++ b/core/src/lib.rs @@ -6,6 +6,7 @@ pub use self::{primitives::*, specs::*, utils::*}; pub mod events; +pub mod handlers; pub mod sessions; pub(crate) mod primitives; @@ -13,4 +14,6 @@ pub(crate) mod utils; pub(crate) mod specs; +pub use crate::handlers::specs::*; + pub trait Tracable {} diff --git a/crates/core/src/primitives.rs b/core/src/primitives.rs similarity index 100% rename from crates/core/src/primitives.rs rename to core/src/primitives.rs diff --git a/crates/core/src/sessions/mod.rs b/core/src/sessions/mod.rs similarity index 100% rename from crates/core/src/sessions/mod.rs rename to core/src/sessions/mod.rs diff --git a/crates/core/src/sessions/session.rs b/core/src/sessions/session.rs similarity index 88% rename from crates/core/src/sessions/session.rs rename to core/src/sessions/session.rs index 668bc64c..d4235823 100644 --- a/crates/core/src/sessions/session.rs +++ b/core/src/sessions/session.rs @@ -3,11 +3,12 @@ Contrib: FL03 Description: ... summary ... */ -use scsys::prelude::{Event, Timestamp}; +use crate::events::Event; +use scsys::prelude::Timestamp; use serde::{Deserialize, Serialize}; use std::convert::From; -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct Session { pub events: Vec, pub timestamp: i64, diff --git a/crates/core/src/specs/apps.rs b/core/src/specs/apps.rs similarity index 100% rename from crates/core/src/specs/apps.rs rename to core/src/specs/apps.rs diff --git a/crates/core/src/specs/cli.rs b/core/src/specs/cli.rs similarity index 67% rename from crates/core/src/specs/cli.rs rename to core/src/specs/cli.rs index f1bd0c36..9d943975 100644 --- a/crates/core/src/specs/cli.rs +++ b/core/src/specs/cli.rs @@ -3,9 +3,13 @@ Contrib: FL03 Description: ... summary ... */ -use super::{AsyncHandler, Handler}; use clap::{Parser, Subcommand}; +pub trait CLIAction { + type Action: clap::FromArgMatches; +} + +/// pub trait Commands: Clone + Default + Subcommand { fn command(&self) -> Self where @@ -15,9 +19,8 @@ pub trait Commands: Clone + Default + Subcommand { } } -pub trait AsyncCommands: Commands + AsyncHandler {} - -pub trait CliSpec: Parser { +/// +pub trait CLISpec: Parser { type Cmds: Commands; fn new() -> Self { @@ -28,6 +31,3 @@ pub trait CliSpec: Parser { Self: Sized; } -pub trait CliSpecExt: CliSpec + Handler {} - -pub trait AsyncCliSpec: CliSpec + AsyncHandler {} diff --git a/crates/core/src/specs/mod.rs b/core/src/specs/mod.rs similarity index 71% rename from crates/core/src/specs/mod.rs rename to core/src/specs/mod.rs index 0ef117e6..f675df62 100644 --- a/crates/core/src/specs/mod.rs +++ b/core/src/specs/mod.rs @@ -9,17 +9,10 @@ pub(crate) mod apps; #[cfg(feature = "cli")] pub(crate) mod cli; -use async_trait::async_trait; -/// -#[async_trait] -pub trait AsyncHandler: Clone + Send + Sync { - type Error: std::error::Error + Send + Sync + 'static; - async fn handler(&self) -> Result<&Self, Self::Error> - where - Self: Sized; -} +use async_trait::async_trait; + /// #[async_trait] pub trait AsyncSpawable { @@ -42,13 +35,7 @@ pub trait BaseObject { fn symbol(&self) -> String; } /// -pub trait Handler: Clone { - type Error: std::error::Error + 'static; - fn handler(&self) -> Result<&Self, Self::Error> - where - Self: Sized; -} /// pub trait Spawnable { fn spawn(&mut self) -> scsys::Result<&Self>; diff --git a/crates/core/src/utils.rs b/core/src/utils.rs similarity index 100% rename from crates/core/src/utils.rs rename to core/src/utils.rs diff --git a/crates/core/tests/default.rs b/core/tests/default.rs similarity index 100% rename from crates/core/tests/default.rs rename to core/tests/default.rs diff --git a/crates/compilers/Cargo.toml b/crates/compilers/Cargo.toml index 6633e388..f45484c9 100644 --- a/crates/compilers/Cargo.toml +++ b/crates/compilers/Cargo.toml @@ -24,7 +24,7 @@ axum = "0.6.1" hyper = { features = ["full"], version = "0.14.23" } http = "0.2.8" http-body = "0.4.5" -scsys = { features = ["full"], version = "0.1.38" } +scsys = { features = ["full"], version = "0.1.39" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } diff --git a/crates/conduits/Cargo.toml b/crates/conduits/Cargo.toml index f0f317b2..89612732 100644 --- a/crates/conduits/Cargo.toml +++ b/crates/conduits/Cargo.toml @@ -18,13 +18,12 @@ test = true [dependencies] mio = "0.8.4" -scsys = { features = ["full"], version = "0.1.38" } +scsys = { features = ["full"], version = "0.1.39" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } tokio = { features = ["macros"], version = "1.21.2" } [dev-dependencies] -acme-core = { path = "../core" } [target.wasm32-unknown-unknown] diff --git a/crates/gateways/Cargo.toml b/crates/gateways/Cargo.toml index 18c70d93..65760c76 100644 --- a/crates/gateways/Cargo.toml +++ b/crates/gateways/Cargo.toml @@ -22,7 +22,7 @@ http = "0.2.8" hyper = { features = ["full"], version = "0.14.23" } lru = "0.9" rust-s3 = {features = ["with-tokio"], version = "0.32.3" } -scsys = { features = ["full"], version = "0.1.38" } +scsys = { features = ["full"], version = "0.1.39" } serde = { features = ["derive"], version = "1" } serde_json = "1" tokio = { features = ["full"], version = "1.22.0" } diff --git a/crates/net/Cargo.toml b/crates/net/Cargo.toml index b99eecae..fe2ca0d3 100644 --- a/crates/net/Cargo.toml +++ b/crates/net/Cargo.toml @@ -23,7 +23,7 @@ http = "0.2.8" http-body = "0.4.5" hyper = { features = ["full"], version = "0.14.23" } mio = "0.8.4" -scsys = { features = ["full"], version = "0.1.38" } +scsys = { features = ["full"], version = "0.1.39" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } @@ -34,6 +34,6 @@ tracing = { features = [], version = "0.1.37" } tracing-subscriber = { features = [], version = "0.3.16" } [dev-dependencies] -acme-core = { path = "../core" } + [target.wasm32-unknown-unknown] diff --git a/crates/net/src/lib.rs b/crates/net/src/lib.rs index c17c460e..bc42da25 100644 --- a/crates/net/src/lib.rs +++ b/crates/net/src/lib.rs @@ -25,4 +25,4 @@ pub trait WebBackend { async fn serve(&self) -> AsyncResult { self.server().serve(self.client().await).await } -} \ No newline at end of file +} diff --git a/crates/pipelines/Cargo.toml b/crates/pipelines/Cargo.toml index 0332bc2d..36ba2f96 100644 --- a/crates/pipelines/Cargo.toml +++ b/crates/pipelines/Cargo.toml @@ -24,7 +24,7 @@ axum = "0.6.1" hyper = { features = ["full"], version = "0.14.23" } http = "0.2.8" http-body = "0.4.5" -scsys = { features = ["full"], version = "0.1.38" } +scsys = { features = ["full"], version = "0.1.39" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } diff --git a/derive/Cargo.toml b/derive/Cargo.toml new file mode 100644 index 00000000..fca72215 --- /dev/null +++ b/derive/Cargo.toml @@ -0,0 +1,34 @@ +[package] +authors = ["FL03 (https://github.com/FL03)"] +categories = [] +description = "Acme is a complete development toolkit for extending platform functionality" +edition = "2021" +homepage = "https://github.com/FL03/acme/wikis" +keywords = ["async", "proc-macros", "scsys"] +license = "Apache-2.0" +name = "acme-derive" +repository = "https://github.com/FL03/acme" +version = "0.2.5" # TODO - Update cargo package version + +[features] +default = [] + +[lib] +proc-macro = true +test = true + +[build-dependencies] + +[dependencies] +syn = { features = [], version = "1" } +proc-macro2 = "1.0.49" + +[dev-dependencies] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] + +[target.wasm32-unknown-unknown] + +[target.wasm32-wasi] diff --git a/derive/src/lib.rs b/derive/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/derive/src/lib.rs @@ -0,0 +1 @@ + diff --git a/macros/Cargo.toml b/macros/Cargo.toml new file mode 100644 index 00000000..7a4078a5 --- /dev/null +++ b/macros/Cargo.toml @@ -0,0 +1,33 @@ +[package] +authors = ["FL03 (https://github.com/FL03)"] +categories = [] +description = "Acme is a complete development toolkit for extending platform functionality" +edition = "2021" +homepage = "https://github.com/FL03/acme/wikis" +keywords = ["async", "macros", "scsys"] +license = "Apache-2.0" +name = "acme-macros" +repository = "https://github.com/FL03/acme" +version = "0.2.5" # TODO - Update cargo package version + +[features] +default = [] + +[lib] +crate-type = ["cdylib", "rlib"] +test = true + +[build-dependencies] + +[dependencies] +syn = { features = [], version = "1" } + +[dev-dependencies] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] + +[target.wasm32-unknown-unknown] + +[target.wasm32-wasi] diff --git a/macros/src/lib.rs b/macros/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/macros/src/lib.rs @@ -0,0 +1 @@ + diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 94cf0833..1f158f93 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -21,6 +21,12 @@ fn main() -> anyhow::Result<()> { Ok(()) } +pub fn cli() -> anyhow::Result<()> { + let matches = clap::builder::Command::new("app"); + + Ok(()) +} + /// pub type Bundle = std::collections::HashMap>>; From 1a62a2debda123d99b48666d6914ef659dcb4ea6 Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Sun, 1 Jan 2023 14:06:20 +0000 Subject: [PATCH 03/15] Update --- core/src/handlers/handler.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/handlers/handler.rs b/core/src/handlers/handler.rs index 79b990a1..da49570a 100644 --- a/core/src/handlers/handler.rs +++ b/core/src/handlers/handler.rs @@ -3,7 +3,19 @@ Contrib: FL03 Description: ... summary ... */ +use serde::{Deserialize, Serialize}; -pub struct Handler { - -} \ No newline at end of file + +pub type TransitionFunction = dyn Fn(S) -> T; + +pub trait Transition { + type Output; + + fn data(&self) -> S; + fn transition(&self, dirac: &TransitionFunction) -> Self::Output { + dirac(self.data()) + } +} + +#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct Handler; \ No newline at end of file From 65b23da4eeeacc6a89d5e05789973aa484836f7d Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Sun, 1 Jan 2023 14:11:14 +0000 Subject: [PATCH 04/15] Update --- core/src/handlers/handler.rs | 3 +- core/src/handlers/mod.rs | 6 ++-- core/src/lib.rs | 47 ++++++++++++++++++++++++++++- core/src/specs/apps.rs | 18 ++--------- core/src/specs/cli.rs | 1 - core/src/specs/mod.rs | 39 ------------------------ crates/gateways/src/config/creds.rs | 2 +- crates/gateways/src/utils.rs | 6 ++-- 8 files changed, 57 insertions(+), 65 deletions(-) diff --git a/core/src/handlers/handler.rs b/core/src/handlers/handler.rs index da49570a..44d19bde 100644 --- a/core/src/handlers/handler.rs +++ b/core/src/handlers/handler.rs @@ -5,7 +5,6 @@ */ use serde::{Deserialize, Serialize}; - pub type TransitionFunction = dyn Fn(S) -> T; pub trait Transition { @@ -18,4 +17,4 @@ pub trait Transition { } #[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct Handler; \ No newline at end of file +pub struct Handler; diff --git a/core/src/handlers/mod.rs b/core/src/handlers/mod.rs index a83d0136..0df719a2 100644 --- a/core/src/handlers/mod.rs +++ b/core/src/handlers/mod.rs @@ -9,7 +9,7 @@ pub(crate) mod handler; pub(crate) mod specs { use async_trait::async_trait; - + /// #[async_trait] pub trait AsyncHandle: Clone + Send + Sync { @@ -22,9 +22,9 @@ pub(crate) mod specs { /// pub trait Handle: Clone { type Error: std::error::Error + 'static; - + fn handler(&self) -> Result<&Self, Self::Error> where Self: Sized; } -} \ No newline at end of file +} diff --git a/core/src/lib.rs b/core/src/lib.rs index b5cf5b6c..8f567f39 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -16,4 +16,49 @@ pub(crate) mod specs; pub use crate::handlers::specs::*; -pub trait Tracable {} +use async_trait::async_trait; +use scsys::prelude::{AsyncResult, Logger, Result}; + +/// +#[async_trait] +pub trait AsyncSpawable { + async fn spawn(&mut self) -> AsyncResult<&Self>; +} +/// +pub trait BaseApplication: BaseObject + Versionable { + fn application(&self) -> &Self { + self + } + fn namespace(&self) -> String; +} + +/// +pub trait BaseObject { + fn count(&self) -> usize; + fn name(&self) -> String; + fn slug(&self) -> String { + self.name().to_ascii_lowercase() + } + fn symbol(&self) -> String; +} +/// +pub trait Spawnable { + fn spawn(&mut self) -> Result<&Self>; +} +/// +pub trait Traceable { + fn with_tracing(&self, level: Option<&str>) -> AsyncResult<&Self> { + // TODO: Introduce a more refined system of tracing logged events + let mut logger = Logger::new(level.unwrap_or("info").to_string()); + logger.setup(None); + tracing_subscriber::fmt::init(); + Ok(self) + } +} +/// +pub trait Versionable { + type Error; + + fn update(&mut self) -> Result<()>; + fn version(&self) -> String; +} diff --git a/core/src/specs/apps.rs b/core/src/specs/apps.rs index 441665ec..d3044c65 100644 --- a/core/src/specs/apps.rs +++ b/core/src/specs/apps.rs @@ -3,8 +3,8 @@ Contrib: FL03 Description: ... summary ... */ -use super::AsyncSpawable; -use scsys::prelude::{BoxResult, Locked, Logger}; +use crate::AsyncSpawable; +use scsys::prelude::{AsyncResult, Locked}; /// Implements the base interface for creating compatible platform applications pub trait AppSpec: Default + AsyncSpawable { @@ -15,21 +15,9 @@ pub trait AppSpec: Default + AsyncSpawable { fn context(&self) -> Self::Ctx; fn name(&self) -> String; fn settings(&self) -> Self::Cnf; - fn setup(&mut self) -> BoxResult<&Self>; + fn setup(&mut self) -> AsyncResult<&Self>; fn slug(&self) -> String { self.name().to_ascii_lowercase() } fn state(&self) -> &Locked; } - -/// Extends the core interface to include logging capabilities -pub trait ApplicationLoggerSpec: AppSpec { - /// Creates a service handle for toggling the tracing systems implemented - fn with_tracing(&self, level: Option<&str>) -> BoxResult<&Self> { - // TODO: Introduce a more refined system of tracing logged events - let mut logger = Logger::new(level.unwrap_or("info").to_string()); - logger.setup(None); - tracing_subscriber::fmt::init(); - Ok(self) - } -} diff --git a/core/src/specs/cli.rs b/core/src/specs/cli.rs index 9d943975..1daecb49 100644 --- a/core/src/specs/cli.rs +++ b/core/src/specs/cli.rs @@ -30,4 +30,3 @@ pub trait CLISpec: Parser { where Self: Sized; } - diff --git a/core/src/specs/mod.rs b/core/src/specs/mod.rs index f675df62..88d77ed4 100644 --- a/core/src/specs/mod.rs +++ b/core/src/specs/mod.rs @@ -8,42 +8,3 @@ pub use self::{apps::*, cli::*}; pub(crate) mod apps; #[cfg(feature = "cli")] pub(crate) mod cli; - - - -use async_trait::async_trait; - -/// -#[async_trait] -pub trait AsyncSpawable { - async fn spawn(&mut self) -> scsys::AsyncResult<&Self>; -} -/// -pub trait BaseApplication: BaseObject + Versionable { - fn application(&self) -> &Self { - self - } - fn namespace(&self) -> String; -} -/// -pub trait BaseObject { - fn count(&self) -> usize; - fn name(&self) -> String; - fn slug(&self) -> String { - self.name().to_ascii_lowercase() - } - fn symbol(&self) -> String; -} -/// - -/// -pub trait Spawnable { - fn spawn(&mut self) -> scsys::Result<&Self>; -} -/// -pub trait Versionable { - type Error; - - fn update(&mut self) -> Result<(), Box>; - fn version(&self) -> String; -} diff --git a/crates/gateways/src/config/creds.rs b/crates/gateways/src/config/creds.rs index 0e7520e6..26ecfb9b 100644 --- a/crates/gateways/src/config/creds.rs +++ b/crates/gateways/src/config/creds.rs @@ -23,7 +23,7 @@ impl GatewayCreds { &mut self, access_key: Option<&str>, secret_key: Option<&str>, - ) -> scsys::BoxResult<&Self> { + ) -> scsys::AsyncResult<&Self> { self.access_key = std::env::var(access_key.unwrap_or("S3_ACCESS_KEY"))?; self.secret_key = std::env::var(secret_key.unwrap_or("S3_SECRET_KEY"))?; Ok(self) diff --git a/crates/gateways/src/utils.rs b/crates/gateways/src/utils.rs index bc6fc1c5..0fe47d1c 100644 --- a/crates/gateways/src/utils.rs +++ b/crates/gateways/src/utils.rs @@ -5,7 +5,7 @@ */ use crate::Gateway; use s3::{creds::Credentials, serde_types::ListBucketResult, Region}; -use scsys::prelude::{BoxResult, S3Credential}; +use scsys::prelude::{AsyncResult, S3Credential}; /// pub fn convert_credentials(cred: S3Credential) -> Credentials { @@ -42,11 +42,11 @@ pub async fn fetch_bucket_contents( bucket: s3::Bucket, prefix: &str, delim: Option, -) -> BoxResult> { +) -> AsyncResult> { let res = bucket.list(prefix.to_string(), delim).await?; Ok(res) } /// -pub async fn fetch_bucket(gateway: &Gateway, name: &str) -> BoxResult { +pub async fn fetch_bucket(gateway: &Gateway, name: &str) -> AsyncResult { Ok(gateway.bucket(name)?) } From 5eecf26779ada3c512e83de40616fcb19587872f Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Mon, 2 Jan 2023 23:49:34 +0000 Subject: [PATCH 05/15] Update --- .github/dependabot.yml | 4 - .github/workflows/rust.yml | 1 - acme/Cargo.toml | 3 - acme/src/lib.rs | 4 - crates/gateways/Cargo.toml | 32 ----- crates/gateways/src/api/mod.rs | 7 -- crates/gateways/src/api/routes/mod.rs | 7 -- crates/gateways/src/api/routes/s3/buckets.rs | 63 ---------- crates/gateways/src/api/routes/s3/mod.rs | 11 -- crates/gateways/src/config/creds.rs | 62 ---------- crates/gateways/src/config/mod.rs | 120 ------------------- crates/gateways/src/config/regions.rs | 68 ----------- crates/gateways/src/contexts/context.rs | 28 ----- crates/gateways/src/contexts/mod.rs | 9 -- crates/gateways/src/gateway.rs | 57 --------- crates/gateways/src/lib.rs | 18 --- crates/gateways/src/middleware/gateway.rs | 23 ---- crates/gateways/src/middleware/mod.rs | 27 ----- crates/gateways/src/primitives.rs | 14 --- crates/gateways/src/sessions.rs | 14 --- crates/gateways/src/states.rs | 45 ------- crates/gateways/src/utils.rs | 52 -------- 22 files changed, 669 deletions(-) delete mode 100644 crates/gateways/Cargo.toml delete mode 100644 crates/gateways/src/api/mod.rs delete mode 100644 crates/gateways/src/api/routes/mod.rs delete mode 100644 crates/gateways/src/api/routes/s3/buckets.rs delete mode 100644 crates/gateways/src/api/routes/s3/mod.rs delete mode 100644 crates/gateways/src/config/creds.rs delete mode 100644 crates/gateways/src/config/mod.rs delete mode 100644 crates/gateways/src/config/regions.rs delete mode 100644 crates/gateways/src/contexts/context.rs delete mode 100644 crates/gateways/src/contexts/mod.rs delete mode 100644 crates/gateways/src/gateway.rs delete mode 100644 crates/gateways/src/lib.rs delete mode 100644 crates/gateways/src/middleware/gateway.rs delete mode 100644 crates/gateways/src/middleware/mod.rs delete mode 100644 crates/gateways/src/primitives.rs delete mode 100644 crates/gateways/src/sessions.rs delete mode 100644 crates/gateways/src/states.rs delete mode 100644 crates/gateways/src/utils.rs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1e074507..27392af0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -32,10 +32,6 @@ updates: directory: /crates/conduits schedule: interval: daily - - package-ecosystem: cargo - directory: /crates/gateways - schedule: - interval: daily - package-ecosystem: cargo directory: /crates/net schedule: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1f4bc571..5c19381b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -46,7 +46,6 @@ jobs: - acme-conduits - acme-core - acme-derive - - acme-gateways - acme-macros - acme-net - acme-pipelines diff --git a/acme/Cargo.toml b/acme/Cargo.toml index 7b7df4f7..75253072 100644 --- a/acme/Cargo.toml +++ b/acme/Cargo.toml @@ -24,7 +24,6 @@ full = [ "compilers", "derive", "extras", - "gateways", "macros", "net", "pipelines", @@ -38,7 +37,6 @@ extras = [] net = ["acme-net"] conduits = ["acme-conduits"] compilers = ["acme-compilers"] -gateways = ["acme-gateways"] pipelines = ["acme-pipelines"] [build-dependencies] @@ -48,7 +46,6 @@ acme-conduits = { features = [], optional = true, path = "../crates/conduits", v acme-core = { features = [], optional = true, path = "../core", version = "0.2.5" } acme-compilers = { features = [], optional = true, path = "../crates/compilers", version = "0.2.5" } acme-derive = { features = [], optional = true, path = "../derive", version = "0.2.5" } -acme-gateways = { features = [], optional = true, path = "../crates/gateways", version = "0.2.5" } acme-macros = { features = [], optional = true, path = "../macros", version = "0.2.5" } acme-net = { features = [], optional = true, path = "../crates/net", version = "0.2.5" } acme-pipelines = { features = [], optional = true, path = "../crates/pipelines", version = "0.2.5" } diff --git a/acme/src/lib.rs b/acme/src/lib.rs index bfa76416..8d113ab2 100644 --- a/acme/src/lib.rs +++ b/acme/src/lib.rs @@ -13,8 +13,6 @@ pub use acme_conduits as conduits; pub use acme_core::*; #[cfg(feature = "derive")] pub use acme_derive::*; -#[cfg(feature = "gateways")] -pub use acme_gateways as gateways; #[cfg(feature = "macros")] pub use acme_macros::*; #[cfg(feature = "net")] @@ -29,8 +27,6 @@ pub mod prelude { pub use super::compilers::*; #[cfg(feature = "conduits")] pub use super::conduits::*; - #[cfg(feature = "gateways")] - pub use super::gateways::*; #[cfg(feature = "net")] pub use super::net::*; #[cfg(feature = "pipelines")] diff --git a/crates/gateways/Cargo.toml b/crates/gateways/Cargo.toml deleted file mode 100644 index 65760c76..00000000 --- a/crates/gateways/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] -description = "acme" -edition = "2021" -homepage = "https://github.com/FL03/acme/wiki" -keywords = ["scsys"] -license = "Apache-2.0" -name = "acme-gateways" -repository = "https://github.com/FL03/acme" -version = "0.2.5" - -[lib] -crate-type = ["cdylib", "rlib"] -test = true - -[dependencies] -async-trait = "0.1" -axum = { features =["headers", "http2", "macros", "ws"], version = "0.6.0" } -clap = { features = ["derive"], version = "4.0.29" } -http = "0.2.8" -hyper = { features = ["full"], version = "0.14.23" } -lru = "0.9" -rust-s3 = {features = ["with-tokio"], version = "0.32.3" } -scsys = { features = ["full"], version = "0.1.39" } -serde = { features = ["derive"], version = "1" } -serde_json = "1" -tokio = { features = ["full"], version = "1.22.0" } -tower = "0.4.13" -tower-http = { features = ["full"], version = "0.3.4" } -tracing = "0.1.37" -tracing-subscriber = { features = ["env-filter"], version = "0.3.16" } diff --git a/crates/gateways/src/api/mod.rs b/crates/gateways/src/api/mod.rs deleted file mode 100644 index ba89b2b7..00000000 --- a/crates/gateways/src/api/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -/* - Appellation: api - Contrib: FL03 - Description: ... Summary ... -*/ - -pub mod routes; diff --git a/crates/gateways/src/api/routes/mod.rs b/crates/gateways/src/api/routes/mod.rs deleted file mode 100644 index b1d89d95..00000000 --- a/crates/gateways/src/api/routes/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -/* - Appellation: routes - Contrib: FL03 - Description: ... Summary ... -*/ - -pub mod s3; diff --git a/crates/gateways/src/api/routes/s3/buckets.rs b/crates/gateways/src/api/routes/s3/buckets.rs deleted file mode 100644 index 38abde22..00000000 --- a/crates/gateways/src/api/routes/s3/buckets.rs +++ /dev/null @@ -1,63 +0,0 @@ -/* - Appellation: buckets - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::{collect_obj_names, contexts::Context, fetch_bucket_contents}; -use axum::{ - extract::{Path, Query}, - routing::get, - Extension, Json, Router, -}; -use scsys::prelude::Message; -use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; - -pub fn router() -> Router { - Router::new() - .route("/bucket", get(landing)) - .route("/bucket/:name", get(fetch_bucket_object_names)) -} - -// Base path for the S3 Gateway -pub async fn landing(Extension(ctx): Extension) -> Json { - let mut auth = false; - if ctx.credentials().access_key.is_some() && ctx.credentials().secret_key.is_some() { - auth = true - } - let msg = Message::from(json!({ - "auth": auth, - "message": "S3 Gateway" - })); - Json(msg) -} - -#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct BucketParams { - pub delim: Option, - pub name: String, - pub path: Vec, - pub prefix: Option, -} - -// Given -pub async fn fetch_bucket_object_names( - Extension(ctx): Extension, - Path(name): Path, - Query(params): Query, -) -> Json { - let delim = Some(params.delim.unwrap_or_else(|| "/".to_string())); - let prefix = params.prefix.unwrap_or_else(|| "/".to_string()); - let bucket = ctx.bucket(params.name.as_str()).expect(""); - let objects = fetch_bucket_contents(bucket, prefix.as_str(), delim) - .await - .unwrap_or_default(); - let names = collect_obj_names(objects).await; - let payload = json!({"name": name, "data": names}); - Json(payload) -} - -pub async fn list_bucket_contents() -> Json { - let payload = json!({"": ""}); - Json(payload) -} diff --git a/crates/gateways/src/api/routes/s3/mod.rs b/crates/gateways/src/api/routes/s3/mod.rs deleted file mode 100644 index 260ed31c..00000000 --- a/crates/gateways/src/api/routes/s3/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -/* - Appellation: s3 - Contrib: FL03 - Description: ... Summary ... -*/ - -pub mod buckets; - -pub fn buckets() -> axum::Router { - buckets::router() -} diff --git a/crates/gateways/src/config/creds.rs b/crates/gateways/src/config/creds.rs deleted file mode 100644 index 26ecfb9b..00000000 --- a/crates/gateways/src/config/creds.rs +++ /dev/null @@ -1,62 +0,0 @@ -/* - Appellation: creds - Contrib: FL03 - Description: ... Summary ... -*/ -use s3::creds::Credentials; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct GatewayCreds { - pub access_key: String, - pub(crate) secret_key: String, -} - -impl GatewayCreds { - pub fn new(access_key: String, secret_key: String) -> Self { - Self { - access_key, - secret_key, - } - } - pub fn from_env( - &mut self, - access_key: Option<&str>, - secret_key: Option<&str>, - ) -> scsys::AsyncResult<&Self> { - self.access_key = std::env::var(access_key.unwrap_or("S3_ACCESS_KEY"))?; - self.secret_key = std::env::var(secret_key.unwrap_or("S3_SECRET_KEY"))?; - Ok(self) - } -} - -impl std::fmt::Display for GatewayCreds { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", serde_json::json!({"access_key": &self.access_key})) - } -} - -impl std::convert::TryFrom for GatewayCreds { - type Error = Box; - fn try_from(data: Credentials) -> Result { - if data.access_key.is_some() & data.secret_key.is_some() { - let res = Self::new(data.access_key.unwrap(), data.secret_key.unwrap()); - Ok(res) - } else { - panic!("Failed to find any credentials") - } - } -} - -impl std::convert::TryFrom for Credentials { - type Error = s3::creds::error::CredentialsError; - fn try_from(data: GatewayCreds) -> Result { - Credentials::new( - Some(data.access_key.as_str()), - Some(data.secret_key.as_str()), - None, - None, - None, - ) - } -} diff --git a/crates/gateways/src/config/mod.rs b/crates/gateways/src/config/mod.rs deleted file mode 100644 index 80342585..00000000 --- a/crates/gateways/src/config/mod.rs +++ /dev/null @@ -1,120 +0,0 @@ -/* - Appellation: config - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::{creds::*, regions::*, settings::*}; - -pub(crate) mod creds; -pub(crate) mod regions; - -pub(crate) mod settings { - use super::*; - use s3::{creds::Credentials, Region}; - use scsys::prelude::{ - config::{Config, Environment}, - try_collect_config_files, AsyncResult, ConfigResult, - }; - use serde::{Deserialize, Serialize}; - - #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] - pub struct GatewayConfig { - pub access_key: String, - pub(crate) secret_key: String, - pub endpoint: String, - pub region: String, - } - - impl GatewayConfig { - pub fn new( - access_key: String, - secret_key: String, - endpoint: String, - region: String, - ) -> Self { - Self { - access_key, - secret_key, - endpoint, - region, - } - } - pub fn build() -> ConfigResult { - let mut builder = Config::builder() - .add_source(Environment::default().prefix("S3").separator("_")) - .set_default("access_key", "")? - .set_default("secret_key", "")? - .set_default("endpoint", "https://gateway.storjshare.io")? - .set_default("region", "us-east-1")?; - - if let Ok(v) = try_collect_config_files("**/*.config.*", false) { - builder = builder.add_source(v); - }; - if let Ok(v) = std::env::var("S3_ACCESS_KEY") { - builder = builder.set_override("access_key", v)?; - } - if let Ok(v) = std::env::var("S3_SECRET_KEY") { - builder = builder.set_override("secret_key", v)?; - } - - builder.build()?.try_deserialize() - } - pub fn partial_env( - access_key: Option<&str>, - secret_key: Option<&str>, - endpoint: String, - region: String, - ) -> AsyncResult { - let access_key = std::env::var(access_key.unwrap_or("S3_ACCESS_KEY"))?; - let secret_key = std::env::var(secret_key.unwrap_or("S3_SECRET_KEY"))?; - Ok(Self::new(access_key, secret_key, endpoint, region)) - } - pub fn credentials(&self) -> Credentials { - let cred = GatewayCreds::new(self.access_key.clone(), self.secret_key.clone()); - cred.try_into().ok().unwrap() - } - pub fn region(&self) -> Region { - Region::Custom { - endpoint: self.endpoint.clone(), - region: self.region.clone(), - } - } - } - - impl std::convert::From<&GatewayCreds> for GatewayConfig { - fn from(data: &GatewayCreds) -> Self { - let region = S3Region::default(); - Self::new( - data.access_key.clone(), - data.secret_key.clone(), - region.endpoint(), - region.region(), - ) - } - } - - impl std::convert::From<&S3Region> for GatewayConfig { - fn from(data: &S3Region) -> Self { - let cred = GatewayCreds::default(); - Self::new( - cred.access_key.clone(), - cred.secret_key, - data.endpoint(), - data.region(), - ) - } - } - - impl Default for GatewayConfig { - fn default() -> Self { - Self::partial_env( - None, - None, - "https://gateway.storjshare.io".to_string(), - "us-east-1".to_string(), - ) - .ok() - .unwrap() - } - } -} diff --git a/crates/gateways/src/config/regions.rs b/crates/gateways/src/config/regions.rs deleted file mode 100644 index eb611fff..00000000 --- a/crates/gateways/src/config/regions.rs +++ /dev/null @@ -1,68 +0,0 @@ -/* - Appellation: regions - Contrib: FL03 - Description: ... Summary ... -*/ -use s3::Region; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct S3Region { - pub endpoint: String, - pub region: String, -} - -impl S3Region { - pub fn new(endpoint: String, region: String) -> Self { - Self { endpoint, region } - } - pub fn endpoint(&self) -> String { - self.endpoint.clone() - } - pub fn region(&self) -> String { - self.region.clone() - } - pub fn update_endpoint(&mut self, endpoint: String) -> &Self { - self.endpoint = endpoint; - self - } - pub fn update_region(&mut self, region: String) -> &Self { - self.region = region; - self - } -} - -impl Default for S3Region { - fn default() -> Self { - Self::new( - "https://gateway.storjshare.io".to_string(), - "us-east-1".to_string(), - ) - } -} - -impl std::fmt::Display for S3Region { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", serde_json::to_string(&self).unwrap()) - } -} - -impl std::convert::From<(&str, &str)> for S3Region { - fn from(data: (&str, &str)) -> Self { - Self::new(data.0.to_string(), data.1.to_string()) - } -} -impl std::convert::From<&Region> for S3Region { - fn from(data: &Region) -> Self { - Self::new(data.clone().endpoint(), data.clone().host()) - } -} - -impl std::convert::From<&S3Region> for Region { - fn from(data: &S3Region) -> Self { - Self::Custom { - endpoint: data.clone().endpoint, - region: data.clone().region, - } - } -} diff --git a/crates/gateways/src/contexts/context.rs b/crates/gateways/src/contexts/context.rs deleted file mode 100644 index a83ff95e..00000000 --- a/crates/gateways/src/contexts/context.rs +++ /dev/null @@ -1,28 +0,0 @@ -/* - Appellation: context - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::config::GatewayConfig; -use s3::{error::S3Error, Bucket}; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct Context { - pub cnf: GatewayConfig, -} - -impl Context { - pub fn new(cnf: GatewayConfig) -> Self { - Self { cnf } - } - pub fn credentials(&self) -> s3::creds::Credentials { - self.cnf.credentials() - } - pub fn region(&self) -> s3::Region { - self.cnf.region() - } - pub fn bucket(&self, name: &str) -> Result { - Bucket::new(name, self.region(), self.credentials()) - } -} diff --git a/crates/gateways/src/contexts/mod.rs b/crates/gateways/src/contexts/mod.rs deleted file mode 100644 index ae87d178..00000000 --- a/crates/gateways/src/contexts/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -/* - Appellation: contexts - Contrib: FL03 - Description: ... Summary ... -*/ -#[doc(inline)] -pub use self::context::*; - -pub(crate) mod context; diff --git a/crates/gateways/src/gateway.rs b/crates/gateways/src/gateway.rs deleted file mode 100644 index 9106dcba..00000000 --- a/crates/gateways/src/gateway.rs +++ /dev/null @@ -1,57 +0,0 @@ -/* - Appellation: gateway - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::config::{GatewayConfig, GatewayCreds, S3Region}; -use s3::{creds::Credentials, error::S3Error, Bucket, Region}; -use serde::{Deserialize, Serialize}; -use std::convert::From; - -#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] -pub struct Gateway { - pub cnf: GatewayConfig, -} - -impl Gateway { - pub fn new(creds: GatewayCreds, region: S3Region) -> Self { - let cnf = GatewayConfig::new( - creds.access_key.clone(), - creds.secret_key, - region.endpoint(), - region.region(), - ); - Self { cnf } - } - pub fn credentials(&self) -> Credentials { - let cred = GatewayCreds::new(self.cnf.access_key.clone(), self.cnf.secret_key.clone()); - cred.try_into().ok().unwrap() - } - pub fn region(&self) -> Region { - Region::Custom { - endpoint: self.cnf.endpoint.clone(), - region: self.cnf.region.clone(), - } - } - pub fn bucket(&self, name: &str) -> Result { - Bucket::new(name, self.region(), self.credentials()) - } -} - -impl From<&S3Region> for Gateway { - fn from(value: &S3Region) -> Self { - Self::new(Default::default(), value.clone()) - } -} - -impl From<&Gateway> for Credentials { - fn from(value: &Gateway) -> Self { - value.credentials() - } -} - -impl From<&Gateway> for Region { - fn from(value: &Gateway) -> Self { - value.region() - } -} diff --git a/crates/gateways/src/lib.rs b/crates/gateways/src/lib.rs deleted file mode 100644 index 24cc9f2a..00000000 --- a/crates/gateways/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -/* - Appellation: pzzld-gateway - Contrib: FL03 - Description: ... Summary ... -*/ -#[doc(inline)] -pub use self::{gateway::*, primitives::*, utils::*}; - -pub mod api; -pub mod config; -pub mod contexts; -pub mod middleware; -pub mod sessions; -pub mod states; - -pub(crate) mod gateway; -pub(crate) mod primitives; -pub(crate) mod utils; diff --git a/crates/gateways/src/middleware/gateway.rs b/crates/gateways/src/middleware/gateway.rs deleted file mode 100644 index da87ced9..00000000 --- a/crates/gateways/src/middleware/gateway.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* - Appellation: gateway - Contrib: FL03 - Description: ... Summary ... -*/ -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] -pub struct GatewayMiddleware { - pub handle: String, -} - -impl GatewayMiddleware { - pub fn new(handle: String) -> Self { - Self { handle } - } -} - -impl Default for GatewayMiddleware { - fn default() -> Self { - Self::new(Default::default()) - } -} diff --git a/crates/gateways/src/middleware/mod.rs b/crates/gateways/src/middleware/mod.rs deleted file mode 100644 index 096b46a8..00000000 --- a/crates/gateways/src/middleware/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* - Appellation: middleware - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::{gateway::*, specs::*}; - -pub(crate) mod gateway; - -pub(crate) mod specs { - use async_trait::async_trait; - use scsys::AsyncResult; - use tower::layer::Layer; - - #[async_trait] - pub trait GatewayService { - fn handle(&self) -> String; - fn service(&self) -> &Self { - self - } - async fn start(&mut self) -> AsyncResult<&Self>; - } - - pub trait GatewayServiceLayer: Layer {} - - pub trait IntoGatewayService {} -} diff --git a/crates/gateways/src/primitives.rs b/crates/gateways/src/primitives.rs deleted file mode 100644 index 84350d0c..00000000 --- a/crates/gateways/src/primitives.rs +++ /dev/null @@ -1,14 +0,0 @@ -/* - Appellation: primitives - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::{constants::*, statics::*, types::*}; - -pub(crate) mod constants { - pub const STORJ_GATEWAY_ENDPOINT: &str = "https://gatway.storjshare.io"; -} - -pub(crate) mod statics {} - -pub(crate) mod types {} diff --git a/crates/gateways/src/sessions.rs b/crates/gateways/src/sessions.rs deleted file mode 100644 index 26855f04..00000000 --- a/crates/gateways/src/sessions.rs +++ /dev/null @@ -1,14 +0,0 @@ -/* - Appellation: sessions - Contrib: FL03 - Description: ... Summary ... -*/ -use scsys::prelude::{Id, Timestamp}; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct Session { - pub id: Id, - pub timestamp: Timestamp, - pub data: Vec, -} diff --git a/crates/gateways/src/states.rs b/crates/gateways/src/states.rs deleted file mode 100644 index 6d801fcf..00000000 --- a/crates/gateways/src/states.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* - Appellation: states - Contrib: FL03 - Description: ... Summary ... -*/ -use scsys::prelude::{Id, Message, Timestamp}; -use serde::{Deserialize, Serialize}; -use std::sync::Arc; - -#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct Session { - pub id: Id, - pub timestamp: Timestamp, - pub data: Vec, -} - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub enum State { - Connect { name: String, endpoint: String }, - Idle, -} - -impl State { - pub fn into_message(&self) -> Message { - self.clone().into() - } - pub fn boxed(&self) -> Box<&Self> { - Box::new(self) - } - pub fn shared(&self) -> Arc { - Arc::new(self.clone()) - } -} - -impl Default for State { - fn default() -> Self { - Self::Idle - } -} - -impl std::fmt::Display for State { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", serde_json::to_string(&self).unwrap()) - } -} diff --git a/crates/gateways/src/utils.rs b/crates/gateways/src/utils.rs deleted file mode 100644 index 0fe47d1c..00000000 --- a/crates/gateways/src/utils.rs +++ /dev/null @@ -1,52 +0,0 @@ -/* - Appellation: utils - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::Gateway; -use s3::{creds::Credentials, serde_types::ListBucketResult, Region}; -use scsys::prelude::{AsyncResult, S3Credential}; - -/// -pub fn convert_credentials(cred: S3Credential) -> Credentials { - Credentials { - access_key: Some(cred.access_key), - secret_key: Some(cred.secret_key), - security_token: None, - session_token: None, - expiration: None, - } -} -/// -pub fn simple_creds(access_key: &str, secret_key: &str) -> Credentials { - Credentials::new(Some(access_key), Some(secret_key), None, None, None).expect("msg") -} -/// -pub fn simple_region(endpoint: T, region: T) -> Region { - Region::Custom { - endpoint: endpoint.to_string(), - region: region.to_string(), - } -} - -/// -pub async fn collect_obj_names(objects: Vec) -> Vec { - tracing::info!("Collecting information on the given data..."); - objects - .iter() - .map(|i| i.clone().name) - .collect::>() -} -/// -pub async fn fetch_bucket_contents( - bucket: s3::Bucket, - prefix: &str, - delim: Option, -) -> AsyncResult> { - let res = bucket.list(prefix.to_string(), delim).await?; - Ok(res) -} -/// -pub async fn fetch_bucket(gateway: &Gateway, name: &str) -> AsyncResult { - Ok(gateway.bucket(name)?) -} From c23ec0bc2d887bdfb7a50c8b705edacb5a1e511b Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Tue, 3 Jan 2023 00:05:16 +0000 Subject: [PATCH 06/15] Update --- core/Cargo.toml | 2 +- core/src/events/event.rs | 2 +- core/src/events/mod.rs | 2 +- core/src/events/opts.rs | 2 +- core/src/handlers/mod.rs | 2 +- core/src/lib.rs | 1 + core/src/specs/apps.rs | 9 ++++----- core/src/utils.rs | 8 ++++++++ 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 7fd4c15b..f672a891 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -34,7 +34,7 @@ scsys = { features = ["full"], version = "0.1.39" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } -tokio = { features = ["full"], version = "1.23.0" } +tokio = { features = ["macros", "process", "signal", "sync"], version = "1" } tracing-subscriber = "0.3.16" [package.metadata.docs.rs] diff --git a/core/src/events/event.rs b/core/src/events/event.rs index 6acace02..24a162d9 100644 --- a/core/src/events/event.rs +++ b/core/src/events/event.rs @@ -3,7 +3,7 @@ Contrib: FL03 Description: ... Summary ... */ -use super::{EventSpec, Eventful}; +use crate::{EventSpec, Eventful}; use scsys::prelude::Message; use serde::{Deserialize, Serialize}; diff --git a/core/src/events/mod.rs b/core/src/events/mod.rs index a1d1491f..78aaecbf 100644 --- a/core/src/events/mod.rs +++ b/core/src/events/mod.rs @@ -3,7 +3,7 @@ Contrib: FL03 Description: ... Summary ... */ -pub use self::{event::*, opts::*, specs::*}; +pub use self::{event::*, opts::*}; pub(crate) mod event; pub(crate) mod opts; diff --git a/core/src/events/opts.rs b/core/src/events/opts.rs index 379e5db9..b240cbc2 100644 --- a/core/src/events/opts.rs +++ b/core/src/events/opts.rs @@ -3,7 +3,7 @@ Contrib: FL03 Description: ... Summary ... */ -use super::{Event, Eventful}; +use crate::{events::Event, Eventful}; use scsys::prelude::Message; use serde::{Deserialize, Serialize}; diff --git a/core/src/handlers/mod.rs b/core/src/handlers/mod.rs index 0df719a2..c9c05a22 100644 --- a/core/src/handlers/mod.rs +++ b/core/src/handlers/mod.rs @@ -13,7 +13,7 @@ pub(crate) mod specs { /// #[async_trait] pub trait AsyncHandle: Clone + Send + Sync { - type Error: std::error::Error + Send + Sync + 'static; + type Error: std::error::Error + Send + Sync; async fn handler(&self) -> Result<&Self, Self::Error> where diff --git a/core/src/lib.rs b/core/src/lib.rs index 8f567f39..6d81b9b0 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -14,6 +14,7 @@ pub(crate) mod utils; pub(crate) mod specs; +pub use crate::events::specs::*; pub use crate::handlers::specs::*; use async_trait::async_trait; diff --git a/core/src/specs/apps.rs b/core/src/specs/apps.rs index d3044c65..a2b12bb7 100644 --- a/core/src/specs/apps.rs +++ b/core/src/specs/apps.rs @@ -4,17 +4,16 @@ Description: ... summary ... */ use crate::AsyncSpawable; -use scsys::prelude::{AsyncResult, Locked}; +use scsys::prelude::{AsyncResult, Configurable, Contextual, Locked}; /// Implements the base interface for creating compatible platform applications -pub trait AppSpec: Default + AsyncSpawable { - type Cnf; - type Ctx; +pub trait AppSpec: Default + AsyncSpawable { + type Ctx: Contextual; type State; fn init() -> Self; fn context(&self) -> Self::Ctx; fn name(&self) -> String; - fn settings(&self) -> Self::Cnf; + fn settings(&self) -> Cnf; fn setup(&mut self) -> AsyncResult<&Self>; fn slug(&self) -> String { self.name().to_ascii_lowercase() diff --git a/core/src/utils.rs b/core/src/utils.rs index 5a7b9ed6..0ab0cdb9 100644 --- a/core/src/utils.rs +++ b/core/src/utils.rs @@ -3,3 +3,11 @@ Contrib: FL03 Description: ... Summary ... */ +use crate::{Host, Port}; +use std::net::SocketAddr; + +/// Simple function wrapper for creating [SocketAddr] from its pieces: ([Host], [Port]) +pub fn socket_address(host: Host, port: Port) -> SocketAddr { + SocketAddr::from((host, port)) +} + From 4cb91003d8ec869a31d76dab7f95b0ea047882c4 Mon Sep 17 00:00:00 2001 From: Joe McCain III <92560746+FL03@users.noreply.github.com> Date: Mon, 2 Jan 2023 18:44:59 -0600 Subject: [PATCH 07/15] Update lib.rs --- core/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/lib.rs b/core/src/lib.rs index 6d81b9b0..b63c4a98 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -22,7 +22,7 @@ use scsys::prelude::{AsyncResult, Logger, Result}; /// #[async_trait] -pub trait AsyncSpawable { +pub trait AsyncSpawnable { async fn spawn(&mut self) -> AsyncResult<&Self>; } /// From 23ec839478af1414a31f57a0c8813699ea10c928 Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Tue, 3 Jan 2023 00:59:08 +0000 Subject: [PATCH 08/15] Update --- core/src/specs/apps.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/specs/apps.rs b/core/src/specs/apps.rs index a2b12bb7..1cba2b47 100644 --- a/core/src/specs/apps.rs +++ b/core/src/specs/apps.rs @@ -3,11 +3,11 @@ Contrib: FL03 Description: ... summary ... */ -use crate::AsyncSpawable; +use crate::AsyncSpawnable; use scsys::prelude::{AsyncResult, Configurable, Contextual, Locked}; /// Implements the base interface for creating compatible platform applications -pub trait AppSpec: Default + AsyncSpawable { +pub trait AppSpec: Default + AsyncSpawnable { type Ctx: Contextual; type State; fn init() -> Self; From 1a92304bea0d69f57785c517b4545bbfc66b36f7 Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Tue, 3 Jan 2023 01:02:48 +0000 Subject: [PATCH 09/15] Update --- core/src/specs/apps.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/specs/apps.rs b/core/src/specs/apps.rs index 1cba2b47..82826b5e 100644 --- a/core/src/specs/apps.rs +++ b/core/src/specs/apps.rs @@ -20,3 +20,11 @@ pub trait AppSpec: Default + AsyncSpawnable { } fn state(&self) -> &Locked; } + +pub struct Application(Ctx); + +impl Application { + pub fn new() -> Self { + Self(Default::default()) + } +} From 1526fac9e705a33c99db468383699c5512276d42 Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Tue, 3 Jan 2023 02:37:33 +0000 Subject: [PATCH 10/15] Update --- core/Cargo.toml | 2 +- crates/compilers/Cargo.toml | 2 +- crates/conduits/Cargo.toml | 2 +- crates/net/Cargo.toml | 2 +- crates/pipelines/Cargo.toml | 18 +++++++++--------- derive/Cargo.toml | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index f672a891..175a310f 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -30,7 +30,7 @@ axum-core = "0.3.0" clap = { features = ["cargo", "derive", "env"], optional = true, version = "4.0.29" } config = "0.13.3" futures = "0.3.25" -scsys = { features = ["full"], version = "0.1.39" } +scsys = { features = ["full"], version = "0.1.40" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } diff --git a/crates/compilers/Cargo.toml b/crates/compilers/Cargo.toml index f45484c9..a3968b03 100644 --- a/crates/compilers/Cargo.toml +++ b/crates/compilers/Cargo.toml @@ -24,7 +24,7 @@ axum = "0.6.1" hyper = { features = ["full"], version = "0.14.23" } http = "0.2.8" http-body = "0.4.5" -scsys = { features = ["full"], version = "0.1.39" } +scsys = { features = ["full"], version = "0.1.40" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } diff --git a/crates/conduits/Cargo.toml b/crates/conduits/Cargo.toml index 89612732..c2e8d9bc 100644 --- a/crates/conduits/Cargo.toml +++ b/crates/conduits/Cargo.toml @@ -18,7 +18,7 @@ test = true [dependencies] mio = "0.8.4" -scsys = { features = ["full"], version = "0.1.39" } +scsys = { features = ["full"], version = "0.1.40" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } diff --git a/crates/net/Cargo.toml b/crates/net/Cargo.toml index fe2ca0d3..6cfbacc0 100644 --- a/crates/net/Cargo.toml +++ b/crates/net/Cargo.toml @@ -23,7 +23,7 @@ http = "0.2.8" http-body = "0.4.5" hyper = { features = ["full"], version = "0.14.23" } mio = "0.8.4" -scsys = { features = ["full"], version = "0.1.39" } +scsys = { features = ["full"], version = "0.1.40" } serde = { features = ["derive"], version = "1" } serde_json = "1" strum = { features = ["derive"], version = "0.24.1" } diff --git a/crates/pipelines/Cargo.toml b/crates/pipelines/Cargo.toml index 36ba2f96..89f7eb90 100644 --- a/crates/pipelines/Cargo.toml +++ b/crates/pipelines/Cargo.toml @@ -19,17 +19,17 @@ test = true [dev-dependencies] [dependencies] -async-trait = "0.1.59" -axum = "0.6.1" -hyper = { features = ["full"], version = "0.14.23" } -http = "0.2.8" -http-body = "0.4.5" -scsys = { features = ["full"], version = "0.1.39" } +async-trait = "0.1" +axum-core = "0.3" +hyper = { features = ["full"], version = "0.14" } +http = "0.2" +http-body = "0.4" +scsys = { features = ["full"], version = "0.1.40" } serde = { features = ["derive"], version = "1" } serde_json = "1" -strum = { features = ["derive"], version = "0.24.1" } -tokio = { features = ["macros"], version = "1.23.0" } -tracing = { features = [], version = "0.1.37" } +strum = { features = ["derive"], version = "0.24" } +tokio = { features = ["macros", "process", "signal", "sync"], version = "1" } +tracing = { features = [], version = "0.1" } [package.metadata.docs.rs] diff --git a/derive/Cargo.toml b/derive/Cargo.toml index fca72215..4c528b0b 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -21,7 +21,7 @@ test = true [dependencies] syn = { features = [], version = "1" } -proc-macro2 = "1.0.49" +proc-macro2 = "1" [dev-dependencies] From 3b656d49d35ae5a0bb16790372de18df58f0d545 Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Fri, 6 Jan 2023 14:26:04 +0000 Subject: [PATCH 11/15] Update --- core/src/events/event.rs | 8 ++++++-- core/src/utils.rs | 1 - crates/net/src/servers/server.rs | 6 +++--- xtask/src/main.rs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/events/event.rs b/core/src/events/event.rs index 24a162d9..1889383c 100644 --- a/core/src/events/event.rs +++ b/core/src/events/event.rs @@ -4,20 +4,23 @@ Description: ... Summary ... */ use crate::{EventSpec, Eventful}; -use scsys::prelude::Message; +use scsys::prelude::{Hash, Hashable, Message, Timestamp}; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Event { pub event: E, pub message: Message, + pub timestamp: i64, } impl Event { pub fn new(event: E, message: Option) -> Self { + let timestamp = Timestamp::default().into(); Self { event, message: message.unwrap_or_default(), + timestamp, } } } @@ -80,6 +83,7 @@ mod tests { #[test] fn test_events_default() { let a = Event::::default(); + a.hash(); assert_eq!(a.event(), crate::events::Events::None); } } diff --git a/core/src/utils.rs b/core/src/utils.rs index 0ab0cdb9..ff4beefa 100644 --- a/core/src/utils.rs +++ b/core/src/utils.rs @@ -10,4 +10,3 @@ use std::net::SocketAddr; pub fn socket_address(host: Host, port: Port) -> SocketAddr { SocketAddr::from((host, port)) } - diff --git a/crates/net/src/servers/server.rs b/crates/net/src/servers/server.rs index 2b881563..f6151bb7 100644 --- a/crates/net/src/servers/server.rs +++ b/crates/net/src/servers/server.rs @@ -16,7 +16,7 @@ pub struct Server { impl Server { pub fn new(host: Option<[u8; 4]>, port: Option) -> Self { Self { - host: host.unwrap_or([127, 0, 0, 1]), + host: host.unwrap_or([0, 0, 0, 0]), port: port.unwrap_or(8080), } } @@ -40,7 +40,7 @@ impl ServerSpec for Server { impl Default for Server { fn default() -> Self { - Self::new(Some([127, 0, 0, 1]), Some(8080)) + Self::new(Some([0, 0, 0, 0]), Some(8080)) } } @@ -63,7 +63,7 @@ mod tests { #[tokio::test] async fn test_server() { let server = Server::default(); - assert_eq!(server.host, [127, 0, 0, 1]); + assert_eq!(server.host, [0, 0, 0, 0]); assert_eq!(server.port, 8080); } } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1f158f93..94160c4b 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -23,7 +23,7 @@ fn main() -> anyhow::Result<()> { pub fn cli() -> anyhow::Result<()> { let matches = clap::builder::Command::new("app"); - + Ok(()) } From 3433f3a894fed1228be80d4ef03e9c75cc59ca1c Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Mon, 9 Jan 2023 13:59:38 +0000 Subject: [PATCH 12/15] Update --- core/Cargo.toml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 175a310f..859cdae9 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -25,17 +25,16 @@ test = true [dev-dependencies] [dependencies] -async-trait = "0.1.60" -axum-core = "0.3.0" -clap = { features = ["cargo", "derive", "env"], optional = true, version = "4.0.29" } -config = "0.13.3" -futures = "0.3.25" +async-trait = "0.1" +axum-core = "0.3" +clap = { features = ["cargo", "derive", "env"], optional = true, version = "4" } +futures = "0.3" scsys = { features = ["full"], version = "0.1.40" } serde = { features = ["derive"], version = "1" } serde_json = "1" -strum = { features = ["derive"], version = "0.24.1" } +strum = { features = ["derive"], version = "0.24" } tokio = { features = ["macros", "process", "signal", "sync"], version = "1" } -tracing-subscriber = "0.3.16" +tracing-subscriber = "0.3" [package.metadata.docs.rs] all-features = true From bc46cc270ff4d6bd834db1e9e4ef6e617046524d Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Sat, 14 Jan 2023 15:13:26 +0000 Subject: [PATCH 13/15] Update --- .github/dependabot.yml | 4 ---- .github/workflows/rust.yml | 7 ++++--- acme/Cargo.toml | 3 --- acme/src/lib.rs | 4 ---- crates/conduits/Cargo.toml | 29 ----------------------------- crates/conduits/src/api/mod.rs | 1 - crates/conduits/src/cli/mod.rs | 1 - crates/conduits/src/lib.rs | 15 --------------- crates/conduits/src/rpc/mod.rs | 1 - crates/conduits/tests/default.rs | 10 ---------- 10 files changed, 4 insertions(+), 71 deletions(-) delete mode 100644 crates/conduits/Cargo.toml delete mode 100644 crates/conduits/src/api/mod.rs delete mode 100644 crates/conduits/src/cli/mod.rs delete mode 100644 crates/conduits/src/lib.rs delete mode 100644 crates/conduits/src/rpc/mod.rs delete mode 100644 crates/conduits/tests/default.rs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 27392af0..d5ce448e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -28,10 +28,6 @@ updates: directory: /crates/compilers schedule: interval: daily - - package-ecosystem: cargo - directory: /crates/conduits - schedule: - interval: daily - package-ecosystem: cargo directory: /crates/net schedule: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5c19381b..77e402eb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,6 +10,8 @@ on: push: branches: [ "main", "master", "prod" ] tags: [ "prod-*", "v*.*.*" ] + release: + types: [ created ] schedule: - cron: "30 9 * * *" workflow_dispatch: @@ -35,7 +37,7 @@ jobs: - run: cargo build --release -v --workspace - run: cargo test --all --all-features --release -v features: - if: ${{ github.event.inputs.publish }} + if: ${{ github.event.inputs.publish }} || ${{ github.event.release.created }} name: Publish needs: [ build ] runs-on: ubuntu-latest @@ -43,7 +45,6 @@ jobs: matrix: package: - acme-compilers - - acme-conduits - acme-core - acme-derive - acme-macros @@ -54,7 +55,7 @@ jobs: - name: Publish (${{matrix.package}}) run: cargo publish --all-features -v -p ${{ matrix.package }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }} publish: - if: ${{ github.event.inputs.publish }} + if: ${{ github.event.inputs.publish }} || ${{ github.event.release.created }} name: Publish needs: features runs-on: ubuntu-latest diff --git a/acme/Cargo.toml b/acme/Cargo.toml index 75253072..d562f346 100644 --- a/acme/Cargo.toml +++ b/acme/Cargo.toml @@ -19,7 +19,6 @@ test = true [features] default = ["core"] full = [ - "conduits", "core", "compilers", "derive", @@ -35,14 +34,12 @@ macros = ["acme-macros/default"] extras = [] net = ["acme-net"] -conduits = ["acme-conduits"] compilers = ["acme-compilers"] pipelines = ["acme-pipelines"] [build-dependencies] [dependencies] -acme-conduits = { features = [], optional = true, path = "../crates/conduits", version = "0.2.5" } acme-core = { features = [], optional = true, path = "../core", version = "0.2.5" } acme-compilers = { features = [], optional = true, path = "../crates/compilers", version = "0.2.5" } acme-derive = { features = [], optional = true, path = "../derive", version = "0.2.5" } diff --git a/acme/src/lib.rs b/acme/src/lib.rs index 8d113ab2..b1dffe66 100644 --- a/acme/src/lib.rs +++ b/acme/src/lib.rs @@ -7,8 +7,6 @@ */ #[cfg(feature = "compilers")] pub use acme_compilers as compilers; -#[cfg(feature = "conduits")] -pub use acme_conduits as conduits; #[cfg(feature = "core")] pub use acme_core::*; #[cfg(feature = "derive")] @@ -25,8 +23,6 @@ pub mod prelude { #[cfg(feature = "compilers")] pub use super::compilers::*; - #[cfg(feature = "conduits")] - pub use super::conduits::*; #[cfg(feature = "net")] pub use super::net::*; #[cfg(feature = "pipelines")] diff --git a/crates/conduits/Cargo.toml b/crates/conduits/Cargo.toml deleted file mode 100644 index c2e8d9bc..00000000 --- a/crates/conduits/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] -description = "acme" -edition = "2021" -homepage = "https://github.com/FL03/acme/wiki" -keywords = ["scsys"] -license = "Apache-2.0" -name = "acme-conduits" -repository = "https://github.com/FL03/acme" -version = "0.2.5" - -[lib] -crate-type = ["cdylib", "rlib"] -test = true - -[build-dependencies] - -[dependencies] -mio = "0.8.4" -scsys = { features = ["full"], version = "0.1.40" } -serde = { features = ["derive"], version = "1" } -serde_json = "1" -strum = { features = ["derive"], version = "0.24.1" } -tokio = { features = ["macros"], version = "1.21.2" } - -[dev-dependencies] - -[target.wasm32-unknown-unknown] diff --git a/crates/conduits/src/api/mod.rs b/crates/conduits/src/api/mod.rs deleted file mode 100644 index 8b137891..00000000 --- a/crates/conduits/src/api/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/conduits/src/cli/mod.rs b/crates/conduits/src/cli/mod.rs deleted file mode 100644 index 8b137891..00000000 --- a/crates/conduits/src/cli/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/conduits/src/lib.rs b/crates/conduits/src/lib.rs deleted file mode 100644 index f3b4f653..00000000 --- a/crates/conduits/src/lib.rs +++ /dev/null @@ -1,15 +0,0 @@ -/* - Appellation: acme-conduits - Contrib: FL03 - Description: - A conduit describes a viable surface which facilitates at least one, if not all, of the four possible types of interactions. - Those interactions describe the different engagements the system may undergo and follow the logic below - I Peer-to-Peer (P -> P) - II Peer-to-Machine (P -> M) - III Machine-to-Machine (M -> M) - IV Machine-to-Peer (M -> P) -*/ - -pub mod api; -pub mod cli; -pub mod rpc; diff --git a/crates/conduits/src/rpc/mod.rs b/crates/conduits/src/rpc/mod.rs deleted file mode 100644 index 8b137891..00000000 --- a/crates/conduits/src/rpc/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/conduits/tests/default.rs b/crates/conduits/tests/default.rs deleted file mode 100644 index c26d18f3..00000000 --- a/crates/conduits/tests/default.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[cfg(test)] -mod tests { - - #[test] - fn lib_compiles() { - let f = |i: usize, j: usize| i * j; - - assert_eq!(f(10, 2), 20); - } -} From 5a663a087bf3208cfe70327334e6cef3f25eb91b Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Sat, 21 Jan 2023 16:27:56 +0000 Subject: [PATCH 14/15] Update --- .cargo/config | 2 - .github/dependabot.yml | 16 +-- .github/workflows/rust.yml | 10 +- .gitpod.yml | 2 +- Cargo.toml | 8 +- acme/Cargo.toml | 29 +++--- acme/src/lib.rs | 10 +- core/Cargo.toml | 24 +++-- core/src/events/event.rs | 3 +- crates/compilers/Cargo.toml | 37 ------- crates/compilers/src/compiler.rs | 61 ----------- crates/compilers/src/lib.rs | 9 -- crates/compilers/src/states/compiler.rs | 108 -------------------- crates/compilers/src/states/mod.rs | 10 -- crates/compilers/tests/default.rs | 7 -- crates/pipelines/Cargo.toml | 37 ------- crates/pipelines/src/lib.rs | 14 --- crates/pipelines/src/pipeline.rs | 33 ------ crates/pipelines/src/stages.rs | 21 ---- crates/pipelines/src/utils.rs | 7 -- crates/pipelines/tests/default.rs | 7 -- derive/Cargo.toml | 16 +-- macros/Cargo.toml | 16 +-- {crates/net => net}/Cargo.toml | 22 ++-- {crates/net => net}/src/lib.rs | 0 {crates/net => net}/src/middleware/mod.rs | 0 {crates/net => net}/src/proxies/mod.rs | 0 {crates/net => net}/src/proxies/proxy.rs | 0 {crates/net => net}/src/servers/mod.rs | 0 {crates/net => net}/src/servers/server.rs | 0 {crates/net => net}/src/signals/mod.rs | 0 {crates/net => net}/src/signals/shutdown.rs | 0 {crates/net => net}/tests/default.rs | 0 scripts/cargo/test.sh | 4 - scripts/publish.sh | 3 - scripts/rustup.sh | 4 + scripts/setup.sh | 5 +- xtask/Cargo.toml | 38 ------- xtask/src/cli/args/builder.rs | 46 --------- xtask/src/cli/args/mod.rs | 57 ----------- xtask/src/cli/args/runner.rs | 38 ------- xtask/src/cli/args/setup.rs | 63 ------------ xtask/src/cli/commands.rs | 47 --------- xtask/src/cli/mod.rs | 61 ----------- xtask/src/main.rs | 52 ---------- xtask/src/utils.rs | 54 ---------- 46 files changed, 76 insertions(+), 905 deletions(-) delete mode 100644 .cargo/config delete mode 100644 crates/compilers/Cargo.toml delete mode 100644 crates/compilers/src/compiler.rs delete mode 100644 crates/compilers/src/lib.rs delete mode 100644 crates/compilers/src/states/compiler.rs delete mode 100644 crates/compilers/src/states/mod.rs delete mode 100644 crates/compilers/tests/default.rs delete mode 100644 crates/pipelines/Cargo.toml delete mode 100644 crates/pipelines/src/lib.rs delete mode 100644 crates/pipelines/src/pipeline.rs delete mode 100644 crates/pipelines/src/stages.rs delete mode 100644 crates/pipelines/src/utils.rs delete mode 100644 crates/pipelines/tests/default.rs rename {crates/net => net}/Cargo.toml (62%) rename {crates/net => net}/src/lib.rs (100%) rename {crates/net => net}/src/middleware/mod.rs (100%) rename {crates/net => net}/src/proxies/mod.rs (100%) rename {crates/net => net}/src/proxies/proxy.rs (100%) rename {crates/net => net}/src/servers/mod.rs (100%) rename {crates/net => net}/src/servers/server.rs (100%) rename {crates/net => net}/src/signals/mod.rs (100%) rename {crates/net => net}/src/signals/shutdown.rs (100%) rename {crates/net => net}/tests/default.rs (100%) delete mode 100644 scripts/cargo/test.sh delete mode 100644 scripts/publish.sh create mode 100644 scripts/rustup.sh delete mode 100644 xtask/Cargo.toml delete mode 100644 xtask/src/cli/args/builder.rs delete mode 100644 xtask/src/cli/args/mod.rs delete mode 100644 xtask/src/cli/args/runner.rs delete mode 100644 xtask/src/cli/args/setup.rs delete mode 100644 xtask/src/cli/commands.rs delete mode 100644 xtask/src/cli/mod.rs delete mode 100644 xtask/src/main.rs delete mode 100644 xtask/src/utils.rs diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index d8c2032b..00000000 --- a/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[alias] -xtask = "run --manifest-path ./xtask/Cargo.toml --" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d5ce448e..8d4a17fd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,11 @@ version: 2 updates: - - package-ecosystem: github-actions + - package-ecosystem: cargo directory: / schedule: interval: daily - - package-ecosystem: cargo - directory: /xtask + - package-ecosystem: github-actions + directory: / schedule: interval: daily - package-ecosystem: cargo @@ -25,14 +25,6 @@ updates: schedule: interval: daily - package-ecosystem: cargo - directory: /crates/compilers + directory: /net schedule: interval: daily - - package-ecosystem: cargo - directory: /crates/net - schedule: - interval: daily - - package-ecosystem: cargo - directory: /crates/pipelines - schedule: - interval: daily \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 77e402eb..a69bb803 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,7 +11,7 @@ on: branches: [ "main", "master", "prod" ] tags: [ "prod-*", "v*.*.*" ] release: - types: [ created ] + types: [ published ] schedule: - cron: "30 9 * * *" workflow_dispatch: @@ -35,27 +35,25 @@ jobs: - uses: actions/checkout@v3 - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - run: cargo build --release -v --workspace - - run: cargo test --all --all-features --release -v + - run: cargo test --all -F full --release -v features: - if: ${{ github.event.inputs.publish }} || ${{ github.event.release.created }} + if: ${{ github.event.inputs.publish }} name: Publish needs: [ build ] runs-on: ubuntu-latest strategy: matrix: package: - - acme-compilers - acme-core - acme-derive - acme-macros - acme-net - - acme-pipelines steps: - uses: actions/checkout@v3 - name: Publish (${{matrix.package}}) run: cargo publish --all-features -v -p ${{ matrix.package }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }} publish: - if: ${{ github.event.inputs.publish }} || ${{ github.event.release.created }} + if: ${{ github.event.inputs.publish }} name: Publish needs: features runs-on: ubuntu-latest diff --git a/.gitpod.yml b/.gitpod.yml index 42fad13c..b6598339 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -3,5 +3,5 @@ tasks: rustup default nightly rustup target add wasm32-unknown-unknown wasm32-wasi --toolchain nightly rustup component add clippy rustfmt --toolchain nightly - cargo build --workspace --release + cargo build -F full --workspace --release command: cargo watch -x test --all \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 7e9603a4..3723fbb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" homepage = "https://github.com/FL03/acme/wikis" license = "Apache-2.0" repository = "https://github.com/FL03/acme" +readme = "README.md" version = "0.2.5" # TODO - Update cargo package version [workspace] @@ -17,9 +18,14 @@ members = [ "core", "derive", "macros", - "crates/*", + "net", ] +[workspace.dependencies] +scsys = { features = ["full"], version = "0.1.41" } +serde = { features = ["derive"], version = "1" } +serde_json = "1" + [profile.dev] codegen-units = 256 debug = true diff --git a/acme/Cargo.toml b/acme/Cargo.toml index d562f346..1ca40cb0 100644 --- a/acme/Cargo.toml +++ b/acme/Cargo.toml @@ -1,16 +1,17 @@ [package] -authors = ["FL03 (https://github.com)"] categories = [] -description = "Acme is a complete development toolkit for extending platform functionality" -edition = "2021" -homepage = "https://github.com/scattered-systems/acme/wikis" keywords = ["async", "scsys"] -license = "Apache-2.0" name = "acme" publish = true -readme = "README.md" -repository = "https://github.com/scattered-systems/acme" -version = "0.2.5" # TODO - Update cargo package version + +authors.workspace = true +description.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +version.workspace = true [lib] crate-type = ["cdylib", "rlib"] @@ -19,13 +20,11 @@ test = true [features] default = ["core"] full = [ - "core", - "compilers", + "core", "derive", "extras", "macros", - "net", - "pipelines", + "net", ] core = ["acme-core"] @@ -34,18 +33,14 @@ macros = ["acme-macros/default"] extras = [] net = ["acme-net"] -compilers = ["acme-compilers"] -pipelines = ["acme-pipelines"] [build-dependencies] [dependencies] acme-core = { features = [], optional = true, path = "../core", version = "0.2.5" } -acme-compilers = { features = [], optional = true, path = "../crates/compilers", version = "0.2.5" } acme-derive = { features = [], optional = true, path = "../derive", version = "0.2.5" } acme-macros = { features = [], optional = true, path = "../macros", version = "0.2.5" } -acme-net = { features = [], optional = true, path = "../crates/net", version = "0.2.5" } -acme-pipelines = { features = [], optional = true, path = "../crates/pipelines", version = "0.2.5" } +acme-net = { features = [], optional = true, path = "../net", version = "0.2.5" } [package.metadata.docs.rs] all-features = true diff --git a/acme/src/lib.rs b/acme/src/lib.rs index b1dffe66..5d9a9a86 100644 --- a/acme/src/lib.rs +++ b/acme/src/lib.rs @@ -5,8 +5,6 @@ Acme was inspired by projects like Python's FastAPI, seeking to simplify the creation of powerful Rust-native applications targeting WebAssembly runtime's. Additionally, Acme services the ecosystem by forming the basis of our composable runtime environment facilitated by the tandem between Proton, Flow, and Reaction. */ -#[cfg(feature = "compilers")] -pub use acme_compilers as compilers; #[cfg(feature = "core")] pub use acme_core::*; #[cfg(feature = "derive")] @@ -15,18 +13,12 @@ pub use acme_derive::*; pub use acme_macros::*; #[cfg(feature = "net")] pub use acme_net as net; -#[cfg(feature = "pipelines")] -pub use acme_pipelines as pipelines; pub mod prelude { pub use super::*; - #[cfg(feature = "compilers")] - pub use super::compilers::*; #[cfg(feature = "net")] pub use super::net::*; - #[cfg(feature = "pipelines")] - pub use super::pipelines::*; #[cfg(feature = "core")] - pub use super::{events::*, sessions::*}; + pub use super::{events::*, handlers::*, sessions::*}; } diff --git a/core/Cargo.toml b/core/Cargo.toml index 859cdae9..965d0490 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,14 +1,14 @@ [package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] description = "acme" -edition = "2021" -homepage = "https://github.com/FL03/acme/wiki" -keywords = ["scsys"] -license = "Apache-2.0" name = "acme-core" -repository = "https://github.com/FL03/acme" -version = "0.2.5" + +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +version.workspace = true [features] default = [ "cli"] @@ -25,13 +25,15 @@ test = true [dev-dependencies] [dependencies] +scsys.workspace = true +serde.workspace = true +serde_json.workspace = true + async-trait = "0.1" axum-core = "0.3" clap = { features = ["cargo", "derive", "env"], optional = true, version = "4" } +decanter = { features = ["derive"], version = "0.1.3" } futures = "0.3" -scsys = { features = ["full"], version = "0.1.40" } -serde = { features = ["derive"], version = "1" } -serde_json = "1" strum = { features = ["derive"], version = "0.24" } tokio = { features = ["macros", "process", "signal", "sync"], version = "1" } tracing-subscriber = "0.3" diff --git a/core/src/events/event.rs b/core/src/events/event.rs index 1889383c..0951cc54 100644 --- a/core/src/events/event.rs +++ b/core/src/events/event.rs @@ -4,7 +4,8 @@ Description: ... Summary ... */ use crate::{EventSpec, Eventful}; -use scsys::prelude::{Hash, Hashable, Message, Timestamp}; +use decanter::prelude::{Hash, Hashable}; +use scsys::prelude::{Message, Timestamp}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] diff --git a/crates/compilers/Cargo.toml b/crates/compilers/Cargo.toml deleted file mode 100644 index a3968b03..00000000 --- a/crates/compilers/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] -description = "acme" -edition = "2021" -homepage = "https://github.com/FL03/acme/wiki" -keywords = ["scsys"] -license = "Apache-2.0" -name = "acme-compilers" -repository = "https://github.com/FL03/acme" -version = "0.2.5" - -[lib] -crate-type = ["cdylib", "rlib"] -test = true - -[build-dependencies] - -[dev-dependencies] - -[dependencies] -async-trait = "0.1.59" -axum = "0.6.1" -hyper = { features = ["full"], version = "0.14.23" } -http = "0.2.8" -http-body = "0.4.5" -scsys = { features = ["full"], version = "0.1.40" } -serde = { features = ["derive"], version = "1" } -serde_json = "1" -strum = { features = ["derive"], version = "0.24.1" } -tokio = { features = ["macros"], version = "1.23.0" } -tracing = { features = [], version = "0.1.37" } -wasmer = { features = [], version = "3.0.2" } - -[package.metadata.docs.rs] -all-features = true -rustc-args = ["--cfg", "docsrs"] diff --git a/crates/compilers/src/compiler.rs b/crates/compilers/src/compiler.rs deleted file mode 100644 index 595f670b..00000000 --- a/crates/compilers/src/compiler.rs +++ /dev/null @@ -1,61 +0,0 @@ -/* - Appellation: compiler - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::states::{CompilerState, CompilerStates}; -use std::sync::Arc; - -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct Compiler { - state: Arc, -} - -impl Compiler { - pub fn set_state(&mut self, state: CompilerStates) -> &Self { - self.state = Arc::new(CompilerState::new(None, None, Some(state))); - self - } - pub fn init(&mut self) -> &Self { - self.set_state(CompilerStates::init()); - self - } - - pub fn read_input(&mut self) -> &Self { - self.set_state(CompilerStates::read()); - // read the input WebAssembly code - // ... - // return the next state - self - } - - pub fn compile(&mut self) -> &Self { - self.set_state(CompilerStates::compile()); - // compile the input WebAssembly code using Wasmer - // ... - // return the next state - self - } - - pub fn write_output(&mut self) -> &Self { - self.set_state(CompilerStates::write()); - // write the compiled WebAssembly code to the output - // ... - // return the next state - self - } - - pub fn finish(&mut self) -> &Self { - self.set_state(CompilerStates::complete()); - // clean up and finalize the compilation process - // ... - // return the final state - self - } - - pub fn run(&mut self) { - // update the current state of the state-machine - // by calling the appropriate state method based - // on the current state - } -} diff --git a/crates/compilers/src/lib.rs b/crates/compilers/src/lib.rs deleted file mode 100644 index a218fa5b..00000000 --- a/crates/compilers/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -/* - Appellation: pzzld-compilers - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::compiler::*; - -pub(crate) mod compiler; -pub mod states; diff --git a/crates/compilers/src/states/compiler.rs b/crates/compilers/src/states/compiler.rs deleted file mode 100644 index 5ac31736..00000000 --- a/crates/compilers/src/states/compiler.rs +++ /dev/null @@ -1,108 +0,0 @@ -/* - Appellation: compiler - Contrib: FL03 - Description: ... Summary ... -*/ -use scsys::prelude::{fnl_remove, StatePack}; -use serde::{Deserialize, Serialize}; -use std::convert::From; -use strum::{EnumString, EnumVariantNames}; - -#[derive( - Clone, Copy, Debug, Deserialize, EnumString, EnumVariantNames, Eq, Hash, PartialEq, Serialize, -)] -#[strum(serialize_all = "snake_case")] -pub enum CompilerStates { - Idle = 0, - Init = 1, - Read = 2, - Compile = 3, - Write = 4, - Complete = 5, - Invalid = 6, -} - -impl CompilerStates { - pub fn idle() -> Self { - Self::Idle - } - pub fn init() -> Self { - Self::Init - } - pub fn invalid() -> Self { - Self::Invalid - } - pub fn read() -> Self { - Self::Read - } - pub fn write() -> Self { - Self::Write - } - pub fn compile() -> Self { - Self::Compile - } - pub fn complete() -> Self { - Self::Complete - } -} - -impl StatePack for CompilerStates {} - -impl std::fmt::Display for CompilerStates { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - fnl_remove(serde_json::to_string(self).unwrap()).to_ascii_lowercase() - ) - } -} - -impl Default for CompilerStates { - fn default() -> Self { - Self::Idle - } -} - -impl From for CompilerStates { - fn from(data: i64) -> Self { - match data { - 0 => Self::idle(), - 1 => Self::init(), - 2 => Self::read(), - 3 => Self::compile(), - 4 => Self::write(), - 5 => Self::complete(), - _ => Self::invalid(), - } - } -} - -impl From for i64 { - fn from(data: CompilerStates) -> Self { - match data { - CompilerStates::Idle => 0, - CompilerStates::Init => 1, - CompilerStates::Read => 2, - CompilerStates::Compile => 3, - CompilerStates::Write => 4, - CompilerStates::Complete => 5, - CompilerStates::Invalid => 6, - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_compiler_state() { - let a: i64 = CompilerStates::default().into(); - assert_eq!(a, 0i64); - assert_eq!( - CompilerStates::try_from("idle").ok().unwrap(), - CompilerStates::from(a) - ) - } -} diff --git a/crates/compilers/src/states/mod.rs b/crates/compilers/src/states/mod.rs deleted file mode 100644 index 7837ce0a..00000000 --- a/crates/compilers/src/states/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -/* - Appellation: states - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::compiler::*; - -pub(crate) mod compiler; - -pub type CompilerState = scsys::prelude::State; diff --git a/crates/compilers/tests/default.rs b/crates/compilers/tests/default.rs deleted file mode 100644 index 5a2a8993..00000000 --- a/crates/compilers/tests/default.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[cfg(test)] -#[test] -fn lib_compiles() { - let f = |l: usize, r: usize| l + r; - let result = f(2, 2); - assert_eq!(result, 4); -} diff --git a/crates/pipelines/Cargo.toml b/crates/pipelines/Cargo.toml deleted file mode 100644 index 89f7eb90..00000000 --- a/crates/pipelines/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] -description = "acme" -edition = "2021" -homepage = "https://github.com/FL03/acme/wiki" -keywords = ["scsys"] -license = "Apache-2.0" -name = "acme-pipelines" -repository = "https://github.com/FL03/acme" -version = "0.2.5" - -[lib] -crate-type = ["cdylib", "rlib"] -test = true - -[build-dependencies] - -[dev-dependencies] - -[dependencies] -async-trait = "0.1" -axum-core = "0.3" -hyper = { features = ["full"], version = "0.14" } -http = "0.2" -http-body = "0.4" -scsys = { features = ["full"], version = "0.1.40" } -serde = { features = ["derive"], version = "1" } -serde_json = "1" -strum = { features = ["derive"], version = "0.24" } -tokio = { features = ["macros", "process", "signal", "sync"], version = "1" } -tracing = { features = [], version = "0.1" } - - -[package.metadata.docs.rs] -all-features = true -rustc-args = ["--cfg", "docsrs"] diff --git a/crates/pipelines/src/lib.rs b/crates/pipelines/src/lib.rs deleted file mode 100644 index dd89d951..00000000 --- a/crates/pipelines/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -/* - Appellation: pzzld-pipelines - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::{pipeline::*, primitives::*, stages::*, utils::*}; - -pub(crate) mod pipeline; -pub(crate) mod stages; -pub(crate) mod utils; - -pub(crate) mod primitives { - pub const DEFAULT_WORKDIR: &str = "."; -} diff --git a/crates/pipelines/src/pipeline.rs b/crates/pipelines/src/pipeline.rs deleted file mode 100644 index b02df354..00000000 --- a/crates/pipelines/src/pipeline.rs +++ /dev/null @@ -1,33 +0,0 @@ -/* - Appellation: pipeline - Contrib: FL03 - Description: - PipelineStage: - Stages in the build process which specify when a particular hook will execute -*/ -use crate::PipelineStage; - -use scsys::prelude::{Message, Timestamp}; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] -pub struct Pipeline { - pub message: Message, - pub name: String, - pub stage: PipelineStage, - pub timestamp: i64, -} - -impl Pipeline { - pub fn new(message: Option, name: String) -> Self { - let message = message.unwrap_or_default(); - let stage = PipelineStage::PreBuild; - let timestamp = Timestamp::default().into(); - Self { - message, - name, - stage, - timestamp, - } - } -} diff --git a/crates/pipelines/src/stages.rs b/crates/pipelines/src/stages.rs deleted file mode 100644 index 38cc3d0f..00000000 --- a/crates/pipelines/src/stages.rs +++ /dev/null @@ -1,21 +0,0 @@ -/* - Appellation: pipeline - Contrib: FL03 - Description: - Stages - - -*/ -use serde::{Deserialize, Serialize}; - -#[allow(clippy::enum_variant_names)] -#[derive( - Clone, Copy, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, -)] -#[serde(rename_all = "snake_case")] -pub enum PipelineStage { - PreBuild = 0, - #[default] - Build = 1, - - PostBuild = -1, -} diff --git a/crates/pipelines/src/utils.rs b/crates/pipelines/src/utils.rs deleted file mode 100644 index fb8b2f29..00000000 --- a/crates/pipelines/src/utils.rs +++ /dev/null @@ -1,7 +0,0 @@ -/* - Appellation: utils - Contrib: FL03 - Description: ... Summary ... -*/ - -pub fn remove_dir_all() {} diff --git a/crates/pipelines/tests/default.rs b/crates/pipelines/tests/default.rs deleted file mode 100644 index 5a2a8993..00000000 --- a/crates/pipelines/tests/default.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[cfg(test)] -#[test] -fn lib_compiles() { - let f = |l: usize, r: usize| l + r; - let result = f(2, 2); - assert_eq!(result, 4); -} diff --git a/derive/Cargo.toml b/derive/Cargo.toml index 4c528b0b..6ce6d5b0 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,14 +1,14 @@ [package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] description = "Acme is a complete development toolkit for extending platform functionality" -edition = "2021" -homepage = "https://github.com/FL03/acme/wikis" -keywords = ["async", "proc-macros", "scsys"] -license = "Apache-2.0" name = "acme-derive" -repository = "https://github.com/FL03/acme" -version = "0.2.5" # TODO - Update cargo package version + +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +version.workspace = true [features] default = [] diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 7a4078a5..f2f6ccb2 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,14 +1,14 @@ [package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] description = "Acme is a complete development toolkit for extending platform functionality" -edition = "2021" -homepage = "https://github.com/FL03/acme/wikis" -keywords = ["async", "macros", "scsys"] -license = "Apache-2.0" name = "acme-macros" -repository = "https://github.com/FL03/acme" -version = "0.2.5" # TODO - Update cargo package version + +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +version.workspace = true [features] default = [] diff --git a/crates/net/Cargo.toml b/net/Cargo.toml similarity index 62% rename from crates/net/Cargo.toml rename to net/Cargo.toml index 6cfbacc0..da59eeeb 100644 --- a/crates/net/Cargo.toml +++ b/net/Cargo.toml @@ -1,14 +1,14 @@ [package] -authors = ["FL03 (https://github.com/FL03)"] -categories = [] description = "acme" -edition = "2021" -homepage = "https://github.com/FL03/acme/wiki" -keywords = ["scsys"] -license = "Apache-2.0" name = "acme-net" -repository = "https://github.com/FL03/acme" -version = "0.2.5" + +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +version.workspace = true [lib] crate-type = ["cdylib", "rlib"] @@ -23,9 +23,9 @@ http = "0.2.8" http-body = "0.4.5" hyper = { features = ["full"], version = "0.14.23" } mio = "0.8.4" -scsys = { features = ["full"], version = "0.1.40" } -serde = { features = ["derive"], version = "1" } -serde_json = "1" +scsys.workspace = true +serde.workspace = true +serde_json.workspace = true strum = { features = ["derive"], version = "0.24.1" } tokio = { features = ["macros", "signal"], version = "1.23.0" } tower = "0.4.13" diff --git a/crates/net/src/lib.rs b/net/src/lib.rs similarity index 100% rename from crates/net/src/lib.rs rename to net/src/lib.rs diff --git a/crates/net/src/middleware/mod.rs b/net/src/middleware/mod.rs similarity index 100% rename from crates/net/src/middleware/mod.rs rename to net/src/middleware/mod.rs diff --git a/crates/net/src/proxies/mod.rs b/net/src/proxies/mod.rs similarity index 100% rename from crates/net/src/proxies/mod.rs rename to net/src/proxies/mod.rs diff --git a/crates/net/src/proxies/proxy.rs b/net/src/proxies/proxy.rs similarity index 100% rename from crates/net/src/proxies/proxy.rs rename to net/src/proxies/proxy.rs diff --git a/crates/net/src/servers/mod.rs b/net/src/servers/mod.rs similarity index 100% rename from crates/net/src/servers/mod.rs rename to net/src/servers/mod.rs diff --git a/crates/net/src/servers/server.rs b/net/src/servers/server.rs similarity index 100% rename from crates/net/src/servers/server.rs rename to net/src/servers/server.rs diff --git a/crates/net/src/signals/mod.rs b/net/src/signals/mod.rs similarity index 100% rename from crates/net/src/signals/mod.rs rename to net/src/signals/mod.rs diff --git a/crates/net/src/signals/shutdown.rs b/net/src/signals/shutdown.rs similarity index 100% rename from crates/net/src/signals/shutdown.rs rename to net/src/signals/shutdown.rs diff --git a/crates/net/tests/default.rs b/net/tests/default.rs similarity index 100% rename from crates/net/tests/default.rs rename to net/tests/default.rs diff --git a/scripts/cargo/test.sh b/scripts/cargo/test.sh deleted file mode 100644 index 06fb6bca..00000000 --- a/scripts/cargo/test.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -cargo fmt --all -cargo test --all --all-features --color always --verbose - \ No newline at end of file diff --git a/scripts/publish.sh b/scripts/publish.sh deleted file mode 100644 index ee361cd9..00000000 --- a/scripts/publish.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -cargo publish --all-features --color always --jobs 1 --token ${'$'}CARGO_REGISTRY_TOKEN --verbose -p acme-minis -cargo publish --all-features --color always --jobs 1 --token ${'$'}CARGO_REGISTRY_TOKEN --verbose -p acme \ No newline at end of file diff --git a/scripts/rustup.sh b/scripts/rustup.sh new file mode 100644 index 00000000..7fb2cbc0 --- /dev/null +++ b/scripts/rustup.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +rustup default nightly +rustup target add wasm32-unknown-unknown wasm32-wasi --toolchain nightly +rustup component add clippy rustfmt --toolchain nightly \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/setup.sh index 20405f8e..242a4275 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,7 +1,4 @@ #!/usr/bin/env bash - sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y sudo apt install -y protobuf-compiler -rustup install nightly -rustup component add clippy rustfmt --toolchain nightly -rustup target add wasm32-unknown-unknown --toolchain nightly +sh scripts/rustup.sh \ No newline at end of file diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml deleted file mode 100644 index 0fdab48f..00000000 --- a/xtask/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -[package] -authors = ["FL03 (https://github.com/FL03)"] -description = "xtask" -edition = "2021" -license = "Apache-2.0" -name = "xtask" -publish = false -version = "0.1.0" - -[[bin]] -bench = false -name = "xtask" -path = "src/main.rs" -test = false - -[build-dependencies] - -[dependencies] -anyhow = "1.0.66" -clap = { features = ["cargo", "derive", "env"], version = "4.0.29" } -config = "0.13.3" -devx-cmd = "0.5.0" -devx-pre-commit = "0.5.0" -duct = "0.13.6" -serde = { features = ["derive"], version = "1" } -serde_json = "1" -tracing = "0.1.37" -tracing-subscriber = "0.3.16" - -[dev-dependencies] - -[package.metadata.docs.rs] -all-features = true -rustc-args = ["--cfg", "docsrs"] - -[target.wasm32-unknown-unknown] - -[target.wasm32-wasi] diff --git a/xtask/src/cli/args/builder.rs b/xtask/src/cli/args/builder.rs deleted file mode 100644 index 451f9187..00000000 --- a/xtask/src/cli/args/builder.rs +++ /dev/null @@ -1,46 +0,0 @@ -/* - Appellation: builder - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::command; -use anyhow::Result; -use clap::Args; -use serde::{Deserialize, Serialize}; - -#[derive(Args, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct Builder { - #[arg(action = clap::ArgAction::SetTrue, long, short)] - release: bool, - #[arg(action = clap::ArgAction::SetFalse, long, short)] - workspace: bool, -} - -impl Builder { - pub fn new(release: bool, workspace: bool) -> Self { - Self { release, workspace } - } - fn commands(&self) -> Result<&Self> { - let mut args = vec!["build"]; - - if self.release { - args.push("--release"); - } - if self.workspace { - args.push("--workspace"); - } - command("cargo", args)?; - Ok(self) - } - pub fn handler(&self) -> Result<&Self> { - tracing::info!("Building the workspace..."); - self.commands()?; - Ok(self) - } -} - -impl Default for Builder { - fn default() -> Self { - Self::new(false, true) - } -} \ No newline at end of file diff --git a/xtask/src/cli/args/mod.rs b/xtask/src/cli/args/mod.rs deleted file mode 100644 index ba872b4f..00000000 --- a/xtask/src/cli/args/mod.rs +++ /dev/null @@ -1,57 +0,0 @@ -/* - Appellation: args - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::{auto::*, builder::*, runner::*, setup::*}; - -pub(crate) mod builder; -pub(crate) mod runner; -pub(crate) mod setup; - -pub(crate) mod auto { - use crate::command; - use anyhow::Result; - use clap::Args; - use serde::{Deserialize, Serialize}; - - #[derive(Args, Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] - pub struct Auto { - #[arg(action = clap::ArgAction::SetFalse, long, short)] - clippy: bool, - #[arg(action = clap::ArgAction::SetTrue, long, short)] - bench: bool, - #[arg(action = clap::ArgAction::SetFalse, long, short)] - rustfmt: bool, - #[arg(action = clap::ArgAction::SetFalse, long, short)] - test: bool, - } - - impl Auto { - fn clippy(&self) -> Result<&Self> { - tracing::info!("Analyzing the codespace..."); - command("cargo", vec!["clippy", "--all", "--allow-dirty", "--fix"])?; - Ok(self) - } - fn rustfmt(&self) -> Result<&Self> { - tracing::info!("Formatting the codespace..."); - command("cargo", vec!["fmt", "--all"])?; - Ok(self) - } - fn testing(&self) -> Result<&Self> { - tracing::info!("Testing the workspace..."); - - command( - "cargo", - vec!["test", "--all", "--all-features", "--release"], - )?; - Ok(self) - } - pub fn handler(&self) -> Result<&Self> { - self.clippy()?.rustfmt()?; - super::Builder::default().handler()?; - self.testing()?; - Ok(self) - } - } -} diff --git a/xtask/src/cli/args/runner.rs b/xtask/src/cli/args/runner.rs deleted file mode 100644 index eb1a1aaf..00000000 --- a/xtask/src/cli/args/runner.rs +++ /dev/null @@ -1,38 +0,0 @@ -/* - Appellation: runner - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::command; -use anyhow::Result; -use clap::Args; -use serde::{Deserialize, Serialize}; - -#[derive(Args, Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct Runner { - #[clap(long, short, value_parser)] - package: Option, - #[arg(action = clap::ArgAction::SetTrue, long, short)] - release: bool, -} - -impl Runner { - pub fn new(package: Option, release: bool) -> Self { - Self { package, release } - } - fn commands(&self) -> Result<&Self> { - let mut args = vec!["run"]; - if self.release { - args.push("--release"); - } - args.push("--"); - args.push("--h"); - command("cargo", args.clone())?; - Ok(self) - } - pub fn handler(&self) -> Result<&Self> { - tracing::info!("Initializing the application..."); - self.commands()?; - Ok(self) - } -} diff --git a/xtask/src/cli/args/setup.rs b/xtask/src/cli/args/setup.rs deleted file mode 100644 index 67fb160d..00000000 --- a/xtask/src/cli/args/setup.rs +++ /dev/null @@ -1,63 +0,0 @@ -/* - Appellation: setup - Contrib: FL03 - Description: ... Summary ... -*/ -use crate::{command, dist_dir}; -use anyhow::Result; -use clap::Args; -use serde::{Deserialize, Serialize}; - -#[derive(Args, Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct Setup { - #[arg(action = clap::ArgAction::SetTrue, long, short)] - extras: bool, -} - -impl Setup { - pub fn new(extras: bool) -> Self { - Self { extras } - } - fn setup_artifacts(&self) -> Result<&Self> { - if std::fs::create_dir_all(&dist_dir()).is_err() { - tracing::info!("Clearing out the previous build"); - std::fs::remove_dir_all(&dist_dir())?; - std::fs::create_dir_all(&dist_dir())?; - }; - Ok(self) - } - fn commands(&self) -> Result<&Self> { - command("rustup", vec!["default", "nightly"])?; - command( - "rustup", - vec![ - "target", - "add", - "wasm32-unknown-unknown", - "wasm32-wasi", - "--toolchain", - "nightly", - ], - )?; - if self.extras { - command( - "rustup", - vec![ - "component", - "add", - "clippy", - "rustfmt", - "--toolchain", - "nightly", - ], - )?; - command("npm", vec!["install", "-g", "wasm-pack"])?; - }; - Ok(self) - } - pub fn handler(&self) -> Result<&Self> { - tracing::info!("Setting up the workspace..."); - self.setup_artifacts()?.commands()?; - Ok(self) - } -} diff --git a/xtask/src/cli/commands.rs b/xtask/src/cli/commands.rs deleted file mode 100644 index 004aa0a7..00000000 --- a/xtask/src/cli/commands.rs +++ /dev/null @@ -1,47 +0,0 @@ -/* - Appellation: commands - Contrib: FL03 - Description: ... Summary ... -*/ -use super::{Auto, Builder, Runner, Setup}; -use anyhow::Result; -use clap::Subcommand; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize, Subcommand)] -pub enum Commands { - Auto(Auto), - Build(Builder), - Run(Runner), - Setup(Setup), -} - -impl Commands { - pub fn handler(&self) -> Result<&Self> { - tracing::info!("Processing commands issued to the cli..."); - match self { - Self::Auto(auto) => { - tracing::info!("Initializing the CI/CD pipeline"); - auto.handler()?; - } - Self::Build(build) => { - tracing::info!("Compiling the codebase..."); - build.handler()?; - } - Self::Run(runner) => { - runner.handler()?; - } - Self::Setup(setup) => { - tracing::info!("Setting up the environment..."); - setup.handler()?; - } - }; - Ok(self) - } -} - -impl Default for Commands { - fn default() -> Self { - Self::Setup(Default::default()) - } -} diff --git a/xtask/src/cli/mod.rs b/xtask/src/cli/mod.rs deleted file mode 100644 index 1b393acc..00000000 --- a/xtask/src/cli/mod.rs +++ /dev/null @@ -1,61 +0,0 @@ -/* - Appellation: cli - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::{args::*, commands::*, context::*}; - -pub(crate) mod args; -pub(crate) mod commands; - -use std::{sync::Arc, thread::JoinHandle}; - -/// -pub fn new() -> CommandLineInterface { - CommandLineInterface::default() -} -/// -pub fn handle() -> JoinHandle> { - let tmp = Arc::new(new()); - std::thread::spawn(move || { - tmp.handler().expect(""); - tmp - }) -} - -pub(crate) mod context { - use super::Commands; - use anyhow::Result; - use clap::Parser; - - #[derive(Clone, Debug, Hash, Parser, PartialEq)] - #[clap(about, author, version)] - #[clap(long_about = None)] - pub struct CommandLineInterface { - #[clap(subcommand)] - pub command: Option, - #[arg(action = clap::ArgAction::SetTrue, long, short)] - pub debug: bool, - #[arg(action = clap::ArgAction::SetTrue, long, short)] - pub update: bool, - } - - impl CommandLineInterface { - pub fn new() -> Self { - Self::parse() - } - pub fn handler(&self) -> Result<&Self> { - if self.debug {} - if let Some(cmds) = &self.command { - cmds.handler()?; - } - Ok(self) - } - } - - impl Default for CommandLineInterface { - fn default() -> Self { - Self::parse() - } - } -} diff --git a/xtask/src/main.rs b/xtask/src/main.rs deleted file mode 100644 index 94160c4b..00000000 --- a/xtask/src/main.rs +++ /dev/null @@ -1,52 +0,0 @@ -/* - Appellation: xtask - Contrib: FL03 - Description: ... Summary ... -*/ -pub use self::utils::*; - -pub(crate) mod utils; - -pub mod cli; - -fn main() -> anyhow::Result<()> { - tracing_subscriber::fmt::init(); - tracing::info!("Welcome to xtask..."); - - let handle = std::thread::spawn(move || { - cli::handle().join().unwrap(); - }); - handle.join().ok().unwrap(); - - Ok(()) -} - -pub fn cli() -> anyhow::Result<()> { - let matches = clap::builder::Command::new("app"); - - Ok(()) -} - -/// -pub type Bundle = std::collections::HashMap>>; - -/// -#[macro_export] -macro_rules! cmd { - ($( - $x:expr; - [ $( $y:expr ),* ] - );*) => { - { - $( - let mut cmd = std::process::Command::new($x); - cmd.current_dir(scsys_xtask::project_root()); - let mut tmp = Vec::new(); - $( - tmp.push($y); - )* - cmd.args(tmp.as_slice()).status().expect(""); - )* - } - }; -} \ No newline at end of file diff --git a/xtask/src/utils.rs b/xtask/src/utils.rs deleted file mode 100644 index 8b72a60c..00000000 --- a/xtask/src/utils.rs +++ /dev/null @@ -1,54 +0,0 @@ -/* - Appellation: utils - Contrib: FL03 - Description: ... Summary ... -*/ -use anyhow::Result; -use std::path::{Path, PathBuf}; -use std::{collections::HashMap, fs, io, process::Command}; - -/// -pub fn command(program: &str, args: Vec<&str>) -> Result<()> { - let mut cmd = Command::new(program); - cmd.current_dir(project_root()); - cmd.args(args.as_slice()).status()?; - Ok(()) -} -/// -pub fn copy_dir_all(src: impl AsRef, dst: impl AsRef) -> io::Result<()> { - fs::create_dir_all(&dst)?; - for entry in fs::read_dir(src)? { - let entry = entry?; - let ty = entry.file_type()?; - if ty.is_dir() { - copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?; - } else { - fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?; - } - } - Ok(()) -} -/// -pub fn dist_dir() -> PathBuf { - project_root().join(".artifacts/dist") -} -/// -pub fn execute_bundle(bundle: HashMap<&str, Vec>>) -> Result<()> { - for k in bundle.keys() { - // Step 1: Rustup - for i in 0..bundle[k].len() { - let mut cmd = Command::new(k); - cmd.current_dir(project_root()); - cmd.args(bundle[k][i].clone().as_slice()).status()?; - } - } - Ok(()) -} -/// Fetch the project root unless specified otherwise with a CARGO_MANIFEST_DIR env variable -pub fn project_root() -> PathBuf { - Path::new(&env!("CARGO_MANIFEST_DIR")) - .ancestors() - .nth(1) - .unwrap() - .to_path_buf() -} From 6967054cf9141836c991701973e80419d112f443 Mon Sep 17 00:00:00 2001 From: Joe McCain III Date: Sat, 21 Jan 2023 16:29:57 +0000 Subject: [PATCH 15/15] Update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cb6edb9d..7d9bb3d1 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Clippy](https://github.com/FL03/acme/actions/workflows/clippy.yml/badge.svg)](https://github.com/FL03/acme/actions/workflows/clippy.yml) [![Rust](https://github.com/FL03/acme/actions/workflows/rust.yml/badge.svg)](https://github.com/FL03/acme/actions/workflows/rust.yml) +[![crates.io](https://img.shields.io/crates/v/acme.svg)](https://crates.io/crates/acme) +[![docs.rs](https://docs.rs/acme/badge.svg)](https://docs.rs/acme) ***