From 113192042b8a2e43ccf37440ee85e4d1c280cc9d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 29 Jun 2024 11:14:09 +0100 Subject: [PATCH] refactos: extract server-actor crate --- Cargo.toml | 2 ++ crates/file-watcher-actor/Cargo.toml | 3 +- crates/server-actor/Cargo.toml | 35 +++++++++++++++++++ .../server.rs => server-actor/src/lib.rs} | 7 ++-- crates/server/Cargo.toml | 10 ++---- crates/server/src/actors/messages.rs | 1 - crates/server/src/actors/mod.rs | 2 -- crates/server/src/lib.rs | 3 +- 8 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 crates/server-actor/Cargo.toml rename crates/{server/src/actors/server.rs => server-actor/src/lib.rs} (97%) delete mode 100644 crates/server/src/actors/messages.rs delete mode 100644 crates/server/src/actors/mod.rs diff --git a/Cargo.toml b/Cargo.toml index b458a73..efdb604 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ resolver = "2" members = [ "crates/cli", "crates/server", + "crates/server-actor", "crates/config", "crates/git", "crates/forge", @@ -26,6 +27,7 @@ expect_used = "warn" [workspace.dependencies] git-next-server = { path = "crates/server" } +git-next-server-actor = { path = "crates/server-actor" } git-next-config = { path = "crates/config" } git-next-git = { path = "crates/git" } git-next-forge = { path = "crates/forge" } diff --git a/crates/file-watcher-actor/Cargo.toml b/crates/file-watcher-actor/Cargo.toml index 8b672c0..bf9c2dd 100644 --- a/crates/file-watcher-actor/Cargo.toml +++ b/crates/file-watcher-actor/Cargo.toml @@ -4,7 +4,8 @@ version = { workspace = true } edition = { workspace = true } [dependencies] -# git-next-config = { workspace = true } +git-next-config = { workspace = true } +git-next-actor-macros = { workspace = true } # git-next-repo-actor = { workspace = true } # logging diff --git a/crates/server-actor/Cargo.toml b/crates/server-actor/Cargo.toml new file mode 100644 index 0000000..c146af2 --- /dev/null +++ b/crates/server-actor/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "git-next-server-actor" +version = { workspace = true } +edition = { workspace = true } + +[dependencies] +git-next-config = { workspace = true } +git-next-git = { workspace = true } +git-next-forge = { workspace = true } +git-next-repo-actor = { workspace = true } +git-next-actor-macros = { workspace = true } +git-next-file-watcher-actor = { workspace = true } +git-next-webhook-actor = { workspace = true } + +# logging +tracing = { workspace = true } + +# fs/network +kxio = { workspace = true } + +# boilerplate +derive_more = { workspace = true } + +# Actors +actix = { workspace = true } + +[dev-dependencies] +# Testing +# assert2 = { workspace = true } + +[lints.clippy] +nursery = { level = "warn", priority = -1 } +# pedantic = "warn" +unwrap_used = "warn" +expect_used = "warn" diff --git a/crates/server/src/actors/server.rs b/crates/server-actor/src/lib.rs similarity index 97% rename from crates/server/src/actors/server.rs rename to crates/server-actor/src/lib.rs index a55a941..a35c67f 100644 --- a/crates/server/src/actors/server.rs +++ b/crates/server-actor/src/lib.rs @@ -1,12 +1,11 @@ // use actix::prelude::*; -use config::server::{ServerConfig, ServerStorage, Webhook}; -use config::{ForgeAlias, ForgeConfig, GitDir, RepoAlias, ServerRepoConfig}; -use git::{repository::RepositoryFactory, Generation, RepoDetails}; use git_next_actor_macros::message; use git_next_config as config; +use git_next_config::server::{ServerConfig, ServerStorage, Webhook}; +use git_next_config::{ForgeAlias, ForgeConfig, GitDir, RepoAlias, ServerRepoConfig}; use git_next_file_watcher_actor::FileUpdated; -use git_next_git as git; +use git_next_git::{repository::RepositoryFactory, Generation, RepoDetails}; use git_next_repo_actor::{messages::CloneRepo, RepoActor}; use git_next_webhook_actor as webhook; use kxio::{fs::FileSystem, network::Network}; diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index 6eba0d3..ef426be 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -6,11 +6,8 @@ edition = { workspace = true } [dependencies] git-next-config = { workspace = true } git-next-git = { workspace = true } -git-next-forge = { workspace = true } -git-next-repo-actor = { workspace = true } -git-next-actor-macros = { workspace = true } git-next-file-watcher-actor = { workspace = true } -git-next-webhook-actor = { workspace = true } +git-next-server-actor = { workspace = true } # logging console-subscriber = { workspace = true } @@ -20,10 +17,7 @@ tracing-subscriber = { workspace = true } # fs/network kxio = { workspace = true } -# boilerplate -derive_more = { workspace = true } -thiserror = { workspace = true } - +# Actors actix = { workspace = true } actix-rt = { workspace = true } diff --git a/crates/server/src/actors/messages.rs b/crates/server/src/actors/messages.rs deleted file mode 100644 index 8b13789..0000000 --- a/crates/server/src/actors/messages.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/server/src/actors/mod.rs b/crates/server/src/actors/mod.rs deleted file mode 100644 index 372682a..0000000 --- a/crates/server/src/actors/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod messages; -pub mod server; diff --git a/crates/server/src/lib.rs b/crates/server/src/lib.rs index 2c201c5..3c980e1 100644 --- a/crates/server/src/lib.rs +++ b/crates/server/src/lib.rs @@ -1,13 +1,12 @@ // -use crate::actors::server::Server; use actix::prelude::*; use git_next_file_watcher_actor::{FileUpdated, FileWatcher}; use git_next_git::repository::RepositoryFactory; +use git_next_server_actor::Server; use kxio::{fs::FileSystem, network::Network}; use std::path::PathBuf; use tracing::{error, info, level_filters::LevelFilter}; -mod actors; mod config; pub fn init(fs: FileSystem) {