forked from lavina/lavina
Compare commits
No commits in common. "1969901436ac5286716d5c6d150576b469833266" and "b9853ca74d2bfe1c662512efa33d8888ff9a7838" have entirely different histories.
1969901436
...
b9853ca74d
|
@ -18,30 +18,6 @@ use crate::prelude::Str;
|
||||||
use crate::table::{AnonTable};
|
use crate::table::{AnonTable};
|
||||||
use crate::terminator::Terminator;
|
use crate::terminator::Terminator;
|
||||||
|
|
||||||
/*
|
|
||||||
сценарии:
|
|
||||||
- бутстрап нового кластера
|
|
||||||
- подключение новой ноды к кластеру
|
|
||||||
- вывод существующей ноды из кластера
|
|
||||||
|
|
||||||
имплементация:
|
|
||||||
- etcd для выбора лидера
|
|
||||||
- определение модели данных
|
|
||||||
- определение протокола общения между нодами
|
|
||||||
- модель верификации поведения нод
|
|
||||||
|
|
||||||
Лидер кластера
|
|
||||||
- выбирается из нод, которые уже в кластере
|
|
||||||
- не больше одного
|
|
||||||
- занимается аллокацией шардов на ноды
|
|
||||||
|
|
||||||
Лидер шарда
|
|
||||||
- выбирается лидером кластера из реплик шарда
|
|
||||||
- принимает команды на изменение сущностей в шарде
|
|
||||||
- посылает изменения репликам
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct ClusteringConfig {
|
pub struct ClusteringConfig {
|
||||||
/// The name of the cluster used for prefixing the data in etcd and to prevent accidental communication between different clusters.
|
/// The name of the cluster used for prefixing the data in etcd and to prevent accidental communication between different clusters.
|
||||||
|
@ -85,10 +61,12 @@ impl ClusterRegistry {
|
||||||
let listener = TcpListener::bind(config.listen_on).await?;
|
let listener = TcpListener::bind(config.listen_on).await?;
|
||||||
let listener_task = start_connection_listener(listener, inner.clone()).await;
|
let listener_task = start_connection_listener(listener, inner.clone()).await;
|
||||||
let mut client = EtcdClient::connect(&[config.etcd_address], None).await?;
|
let mut client = EtcdClient::connect(&[config.etcd_address], None).await?;
|
||||||
let campaign_response = client.election_client().campaign(b"kek", b"my name", 0).await?;
|
dbg!(client.maintenance_client().status().await?);
|
||||||
dbg!(campaign_response);
|
dbg!(client.leader(b"kek").await);
|
||||||
let leader = client.leader("kek").await?;
|
dbg!(client.kv_client().get(b"kek", None).await?);
|
||||||
dbg!(leader);
|
let a = dbg!(client.election_client().campaign(b"kek", b"my name", 0).await?);
|
||||||
|
dbg!(client.leader(b"kek").await?);
|
||||||
|
dbg!(client.election_client().resign(Some(ResignOptions::new().with_leader(a.leader().unwrap().clone()))).await);
|
||||||
|
|
||||||
|
|
||||||
Ok(ClusterRegistry {
|
Ok(ClusterRegistry {
|
||||||
|
|
23
docs/flow.md
23
docs/flow.md
|
@ -65,26 +65,3 @@ C4Context
|
||||||
BiRel(BobPC, BobConn1, "IRC")
|
BiRel(BobPC, BobConn1, "IRC")
|
||||||
UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")
|
UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Cluster
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
C4Context
|
|
||||||
System_Ext(Alice, "Alice IRC")
|
|
||||||
System_Ext(Bob, "Bob XMPP")
|
|
||||||
Boundary(Lavina, "Lavina", "Cluster of nodes") {
|
|
||||||
System(Node1, "Node 1", "Single server process")
|
|
||||||
System(Node2, "Node 2", "Single server process")
|
|
||||||
System(Node3, "Node 3", "Single server process")
|
|
||||||
Rel(Node1, etcd, "")
|
|
||||||
Rel(Node2, etcd, "")
|
|
||||||
Rel(Node3, etcd, "")
|
|
||||||
BiRel(Node1, Node2, "")
|
|
||||||
BiRel(Node2, Node3, "")
|
|
||||||
BiRel(Node1, Node3, "")
|
|
||||||
System(etcd, "etcd", "Key-value store")
|
|
||||||
UpdateLayoutConfig($c4ShapeInRow="2", $c4BoundaryInRow="1")
|
|
||||||
}
|
|
||||||
Rel(Alice, Node1, "")
|
|
||||||
Rel(Bob, Node2, "")
|
|
||||||
```
|
|
Loading…
Reference in New Issue