forked from lavina/lavina
core: add configuration for clustering
This commit is contained in:
parent
cefd6f8df0
commit
a26162dbca
|
@ -12,3 +12,9 @@ key = "./certs/xmpp.key"
|
|||
|
||||
[storage]
|
||||
db_path = "db.sqlite"
|
||||
|
||||
[clustering]
|
||||
self_id = 1
|
||||
listen_on = "0.0.0.0:23732"
|
||||
advertised_address = "127.0.0.1:23732"
|
||||
bootstrap_via = ["0.0.0.0:23733"]
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
use std::net::SocketAddr;
|
||||
|
||||
use anyhow::Result;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct ClusteringConfig {
|
||||
/// The unique identifier of the node in the cluster, needed to distinguish it form other nodes.
|
||||
pub self_id: u32,
|
||||
/// The local address where this node listens incoming for node-to-node communication.
|
||||
pub listen_on: SocketAddr,
|
||||
/// This address is advertised via a gossip mechanism and used by other nodes in the cluster to communicate with this node.
|
||||
///
|
||||
/// This is useful when a node is behind a NAT or a proxy, where the publicly accessible IP
|
||||
/// address can differ from the local IP address.
|
||||
pub advertised_address: SocketAddr,
|
||||
/// A list of network addresses with the node's initial set of peers in the cluster.
|
||||
/// These nodes will be contacted first in order to discover additional nodes and to initialize the local state.
|
||||
pub bootstrap_via: Box<[SocketAddr]>,
|
||||
}
|
||||
|
||||
/// Cluster registry is a service which handles all connections to other nodes of the cluster.
|
||||
///
|
||||
/// It maintains the local view of the cluster state, including the set of nodes,
|
||||
/// the status of each node and the shard allocation metadata.
|
||||
struct ClusterRegistry {}
|
||||
|
||||
impl ClusterRegistry {
|
||||
/// Creates a new cluster registry and launches all necessary daemon fibers.
|
||||
pub async fn launch(config: ClusteringConfig) -> Result<ClusterRegistry> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
@ -4,5 +4,6 @@ pub mod prelude;
|
|||
pub mod repo;
|
||||
pub mod room;
|
||||
pub mod terminator;
|
||||
pub mod clustering;
|
||||
|
||||
mod table;
|
||||
|
|
|
@ -20,6 +20,7 @@ struct ServerConfig {
|
|||
irc: projection_irc::ServerConfig,
|
||||
xmpp: projection_xmpp::ServerConfig,
|
||||
storage: lavina_core::repo::StorageConfig,
|
||||
clustering: lavina_core::clustering::ClusteringConfig,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
|
@ -48,6 +49,7 @@ async fn main() -> Result<()> {
|
|||
irc: irc_config,
|
||||
xmpp: xmpp_config,
|
||||
storage: storage_config,
|
||||
clustering: clustering_config,
|
||||
} = config;
|
||||
let mut metrics = MetricsRegistry::new();
|
||||
let storage = Storage::open(storage_config).await?;
|
||||
|
|
Loading…
Reference in New Issue