Scaffold the federated services daemon
Protocol-agnostic core: a Protocol trait maps raw server-to-server lines to a normalized event/action model, so the engine never touches a raw line and a new ircd is one new module. Adds event-log state (state is a fold over the log) and a service framework. First protocol impl links to an InspIRCd (insp4) uplink — completes the CAPAB/SERVER handshake, bursts, and introduces NickServ.
This commit is contained in:
commit
f82ab0c70a
15 changed files with 890 additions and 0 deletions
39
src/engine/state.rs
Normal file
39
src/engine/state.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
// Live network view the services reason about.
|
||||
#[derive(Default)]
|
||||
pub struct Network {
|
||||
pub users: HashMap<String, User>, // keyed by UID
|
||||
pub channels: HashMap<String, Channel>,
|
||||
}
|
||||
|
||||
pub struct User {
|
||||
pub uid: String,
|
||||
pub nick: String,
|
||||
pub account: Option<String>,
|
||||
}
|
||||
|
||||
pub struct Channel {
|
||||
pub name: String,
|
||||
pub ts: u64,
|
||||
}
|
||||
|
||||
// The Sable-inspired core: every persistent change is an Event, and state is a
|
||||
// fold over the log. Single-node today; replicating this log across service
|
||||
// nodes is what turns it federated later, without rewriting the services.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Event {
|
||||
AccountRegistered { account: String, uid: String },
|
||||
ChannelRegistered { channel: String, founder: String },
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct EventLog {
|
||||
pub events: Vec<Event>,
|
||||
}
|
||||
|
||||
impl EventLog {
|
||||
pub fn append(&mut self, event: Event) {
|
||||
self.events.push(event);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue