-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster.toml
54 lines (43 loc) · 1.92 KB
/
cluster.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Example cluster setup
[cluster]
default_ip = "127.0.0.1" # String
proxy_ip = "127.0.0.1"
proxy_port = 8080
# Masters
[[cluster.master_nodes]]
port = 9001
name = "master1"
[[cluster.master_nodes]]
ip = "localhost" # can be specified for each
port = 9002
name = "master2"
[[cluster.replica_nodes]]
master_node = "master1" # belongs to
# Parsing: example
# use std::fs;
# use toml::Value;
# fn main() {
# // Read the TOML file
# let toml_content = fs::read_to_string("cluster.toml").expect("Failed to read file");
# // Parse the TOML content
# let parsed_toml: Value = toml::from_str(&toml_content).expect("Failed to parse TOML");
# // Access the cluster configuration
# let cluster_config = parsed_toml.get("cluster").expect("Missing 'cluster' section");
# // Access the proxy configuration
# let proxy_port = cluster_config.get("proxy_port").expect("Missing 'proxy' port").as_integer().unwrap();
# println!("Proxy Port: {}", proxy_port);
# // Access the master nodes
# let master_nodes = cluster_config.get("master_nodes").expect("Missing 'master_nodes' section").as_array().unwrap();
# for node in master_nodes {
# let port = node.get("port").expect("Missing 'port' in master node").as_integer().unwrap();
# let name = node.get("name").expect("Missing 'name' in master node").as_str().unwrap();
# println!("Master Node: Name={}, Port={}", name, port);
# }
# // Access the replica nodes
# let replica_nodes = cluster_config.get("replica_nodes").expect("Missing 'replica_nodes' section").as_array().unwrap();
# for node in replica_nodes {
# let master_node_id = node.get("master_node").expect("Missing 'master_node_id' in replica node").as_integer().unwrap();
# let port = node.get("port").expect("Missing 'port' in replica node").as_integer().unwrap();
# println!("Replica Node: Master Node ID={}, Port={}", master_node_id, port);
# }
}