refactor: extract file-watcher-actor crate

This commit is contained in:
Paul Campbell 2024-06-29 10:57:18 +01:00
parent 2008afa4dd
commit 52d442f2b0
8 changed files with 45 additions and 36 deletions

View file

@ -11,6 +11,7 @@ members = [
"crates/repo-actor",
"crates/webhook-actor",
"crates/actor-macros",
"crates/file-watcher-actor",
]
[workspace.package]
@ -32,6 +33,7 @@ git-next-forge-forgejo = { path = "crates/forge-forgejo" }
git-next-forge-github = { path = "crates/forge-github" }
git-next-repo-actor = { path = "crates/repo-actor" }
git-next-webhook-actor = { path = "crates/webhook-actor" }
git-next-file-watcher-actor = { path = "crates/file-watcher-actor" }
git-next-actor-macros = { path = "crates/actor-macros" }
# CLI parsing

View file

@ -4,26 +4,9 @@ version = { workspace = true }
edition = { workspace = true }
[dependencies]
# git-next-config = { workspace = true }
# git-next-repo-actor = { workspace = true }
#
# # logging
# tracing = { workspace = true }
#
# # Webhooks
# bytes = { workspace = true }
# warp = { 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"

View file

@ -0,0 +1,35 @@
[package]
name = "git-next-file-watcher-actor"
version = { workspace = true }
edition = { workspace = true }
[dependencies]
# git-next-config = { workspace = true }
# git-next-repo-actor = { workspace = true }
# logging
tracing = { workspace = true }
# file watcher
inotify = { workspace = true }
# Webhooks
# bytes = { workspace = true }
# warp = { workspace = true }
# boilerplate
# derive_more = { workspace = true }
thiserror = { 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"

View file

@ -9,6 +9,7 @@ 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
@ -23,10 +24,6 @@ kxio = { workspace = true }
derive_more = { workspace = true }
thiserror = { workspace = true }
# file watcher
inotify = { workspace = true }
# Actors
actix = { workspace = true }
actix-rt = { workspace = true }

View file

@ -1,3 +1,2 @@
pub mod file_watcher;
pub mod messages;
pub mod server;

View file

@ -1,17 +1,16 @@
//
use std::path::PathBuf;
use crate::actors::file_watcher::FileUpdated;
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_file_watcher_actor::FileUpdated;
use git_next_git as git;
use git_next_repo_actor::{messages::CloneRepo, RepoActor};
use git_next_webhook_actor as webhook;
use kxio::{fs::FileSystem, network::Network};
use std::path::PathBuf;
use tracing::{error, info, warn};
use webhook::{AddWebhookRecipient, ShutdownWebhook, WebhookActor, WebhookRouter};

View file

@ -1,19 +1,14 @@
mod actors;
mod config;
//
use crate::actors::server::Server;
use actix::prelude::*;
use git_next_file_watcher_actor::{FileUpdated, FileWatcher};
use git_next_git::repository::RepositoryFactory;
use kxio::{fs::FileSystem, network::Network};
use std::path::PathBuf;
use tracing::{error, info, level_filters::LevelFilter};
use crate::actors::{
file_watcher::{self, FileUpdated},
server::Server,
};
mod actors;
mod config;
pub fn init(fs: FileSystem) {
let file_name = "git-next-server.toml";
@ -50,8 +45,7 @@ pub async fn start(
server.do_send(FileUpdated);
info!("Starting File Watcher...");
let fw = match file_watcher::FileWatcher::new("git-next-server.toml".into(), server.recipient())
{
let fw = match FileWatcher::new("git-next-server.toml".into(), server.recipient()) {
Ok(fw) => fw,
Err(err) => {
error!(?err, "Failed to start file watcher");