forked from lavina/lavina
1
0
Fork 0
This commit is contained in:
Nikita Vilunov 2024-05-10 15:47:43 +02:00
parent 40b9ffe46a
commit 361946bc35
4 changed files with 6 additions and 13 deletions

View File

@ -23,8 +23,7 @@ addresses = [
[cluster.metadata]
node_id = 0
main_owner = 0
test_owner = 1
test2_owner = 0
rooms = { aaaaa = 1, test = 0 }
[tracing]
endpoint = "http://localhost:4317"

View File

@ -23,8 +23,7 @@ addresses = [
[cluster.metadata]
node_id = 1
main_owner = 0
test_owner = 1
test2_owner = 0
rooms = { aaaaa = 1, test = 0 }
[tracing]
endpoint = "http://localhost:4317"

View File

@ -3,6 +3,7 @@ use reqwest::Client;
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_tracing::{DefaultSpanBackend, TracingMiddleware};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::Arc;
@ -22,10 +23,7 @@ pub struct ClusterMetadata {
pub node_id: u32,
/// Owns all rooms and players in the cluster.
pub main_owner: u32,
/// Owns the room `test`.
pub test_owner: u32,
/// Owns the room `test2`.
pub test2_owner: u32,
pub rooms: HashMap<String, u32>,
}
#[derive(Clone)]

View File

@ -446,11 +446,8 @@ impl Player {
}
fn room_location(&self, room_id: &RoomId) -> Option<u32> {
let node = match &**room_id.as_inner() {
"aaaaa" => self.cluster_metadata.test_owner,
"test" => self.cluster_metadata.test2_owner,
_ => self.cluster_metadata.main_owner,
};
let res = self.cluster_metadata.rooms.get(room_id.as_inner().as_ref()).copied();
let node = res.unwrap_or(self.cluster_metadata.main_owner);
if node == self.cluster_metadata.node_id {
None
} else {