use std::sync::Arc; use crate::smart::push::{NoopPushBackend, PushCoordinator, PushOperations, RedisPushBackend}; use crate::smart::service::SmartService; use config::git::{GitSshConfig, SyncSettings}; #[derive(Clone)] pub struct GitSshService { pub smart: SmartService, pub config: GitSshConfig, pub sync_settings: SyncSettings, } impl GitSshService { pub fn new(smart: SmartService, config: GitSshConfig) -> Self { Self { smart, config, sync_settings: SyncSettings::default(), } } pub fn with_sync_settings(mut self, settings: SyncSettings) -> Self { self.sync_settings = settings; self } pub fn push_coordinator(&self) -> PushCoordinator { let backend: Arc = match &self.smart.kv { Some(kv) => Arc::new(RedisPushBackend { kv: kv.clone() }), None => Arc::new(NoopPushBackend), }; PushCoordinator::new(backend) } pub fn with_ci_event_topic(mut self, topic: Option) -> Self { self.smart = self.smart.with_ci_event_topic(topic); self } }