From cecb6a4f0ffc28143ac9d437048484c83a37d277 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 7 Dec 2021 15:58:00 +0100 Subject: Add submodules for behaviour-specific reactors Signed-off-by: Matthias Beyer --- lib/src/reactor/account.rs | 19 +++++++++++++++++++ lib/src/reactor/device.rs | 19 +++++++++++++++++++ lib/src/reactor/gossip.rs | 24 ++++++++++++++++++++++++ lib/src/reactor/mod.rs | 15 +++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 lib/src/reactor/account.rs create mode 100644 lib/src/reactor/device.rs create mode 100644 lib/src/reactor/gossip.rs diff --git a/lib/src/reactor/account.rs b/lib/src/reactor/account.rs new file mode 100644 index 0000000..c6be1ce --- /dev/null +++ b/lib/src/reactor/account.rs @@ -0,0 +1,19 @@ +//! Module for account handling (following accounts, caching account updates) using the gossip +//! module for the lower-level handling + +use std::sync::Arc; + +use anyhow::Result; +use tokio::sync::RwLock; + +use crate::profile::Profile; +use crate::reactor::gossip::GossipReactor; + +#[derive(Debug)] +pub struct AccountReactor(GossipReactor); + +impl AccountReactor { + pub(super) fn new(profile: Arc>) -> Self { + Self(GossipReactor::new(profile)) + } +} diff --git a/lib/src/reactor/device.rs b/lib/src/reactor/device.rs new file mode 100644 index 0000000..c013db6 --- /dev/null +++ b/lib/src/reactor/device.rs @@ -0,0 +1,19 @@ +//! Module for multi-device support functionality, +//! which uses the gossip module for the lower-level handling + +use std::sync::Arc; + +use anyhow::Result; +use tokio::sync::RwLock; + +use crate::profile::Profile; +use crate::reactor::gossip::GossipReactor; + +#[derive(Debug)] +pub struct DeviceReactor(GossipReactor); + +impl DeviceReactor { + pub(super) fn new(profile: Arc>) -> Self { + Self(GossipReactor::new(profile)) + } +} diff --git a/lib/src/reactor/gossip.rs b/lib/src/reactor/gossip.rs new file mode 100644 index 0000000..e695dac --- /dev/null +++ b/lib/src/reactor/gossip.rs @@ -0,0 +1,24 @@ +//! Low-level module for gossip'ing code +//! +//! This module implements the low-level gossiping functionality that other modules use to +//! implement actual behaviours on +//! + +use std::sync::Arc; + +use anyhow::Result; +use tokio::sync::RwLock; + +use crate::profile::Profile; + +#[derive(Debug)] +pub struct GossipReactor { + profile: Arc>, +} + +impl GossipReactor { + pub(super) fn new(profile: Arc>) -> Self { + Self { profile } + } +} + diff --git a/lib/src/reactor/mod.rs b/lib/src/reactor/mod.rs index 70088a3..d55f5c6 100644 --- a/lib/src/reactor/mod.rs +++ b/lib/src/reactor/mod.rs @@ -5,6 +5,10 @@ use tokio::sync::RwLock; use crate::profile::Profile; +mod gossip; +mod device; +mod account; + /// Reactor type, for running the application logic /// /// The Reactor runs the whole application logic, that is syncing with other devices, fetching and @@ -43,4 +47,15 @@ impl Reactor { } } + /// Run the reactor + /// + /// Starts all inner functionality and exposes things + /// + /// # Return + /// + /// Return types are WIP, as this must return "running" objects that can be communicated with + pub async fn run(self) -> Result<()> { + unimplemented!() + } + } -- cgit v1.2.3