Skip to content

Commit

Permalink
make it simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
giangndm committed Nov 18, 2024
1 parent 4d7b0d0 commit ec6b19c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct NodeConfig {
}

pub async fn fetch_node_addr_from_api(url: &str) -> Result<NodeAddr, String> {
let resp = reqwest::get(url).await.map_err(|e| e.to_string())?;
let resp = reqwest::get(format!("{}/api/node/address", url)).await.map_err(|e| e.to_string())?;
let node_addr = resp
.json::<http::Response<String>>()
.await
Expand Down
1 change: 0 additions & 1 deletion bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct Args {
seeds: Vec<NodeAddr>,

/// Seeds from API, this is used for auto-discovery of seeds.
/// It is very useful for cloud deployment.
/// Currently all of nodes expose /api/node/address endpoint, so we can get seeds from there.
#[arg(env, long)]
seeds_from_node_api: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion bin/z0_connector_n4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ RUST_BACKTRACE=1 \
cargo run -- \
--sdn-zone-id 0 \
--sdn-zone-node-id 4 \
--seeds-from-node-api "http://localhost:3000/api/node/address" \
--seeds-from-node-api "http://localhost:3000" \
connector \
--s3-uri "http://minioadmin:[email protected]:9000/record"
2 changes: 1 addition & 1 deletion bin/z0_gate_n1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cargo run -- \
--sdn-port 10001 \
--sdn-zone-id 0 \
--sdn-zone-node-id 1 \
--seeds-from-node-api "http://localhost:8080/api/node/address" \
--seeds-from-node-api "http://localhost:8080" \
--workers 2 \
gateway \
--lat 10 \
Expand Down
2 changes: 1 addition & 1 deletion bin/z0_media_n2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ cargo run -- \
--enable-private-ip \
--sdn-zone-id 0 \
--sdn-zone-node-id 2 \
--seeds-from-node-api "http://localhost:3000/api/node/address" \
--seeds-from-node-api "http://localhost:3000" \
--workers 2 \
media
2 changes: 1 addition & 1 deletion bin/z0_media_n3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ cargo run -- \
--enable-private-ip \
--sdn-zone-id 0 \
--sdn-zone-node-id 3 \
--seeds-from-node-api "http://localhost:3000/api/node/address" \
--seeds-from-node-api "http://localhost:3000" \
--workers 2 \
media
24 changes: 9 additions & 15 deletions docs/getting-started/installation/network-discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This way is simple and easy to understand, but it's not flexible and is inconven
We can use the node API to get the addresses of other nodes and then start the node with those addresses.

```
cargo run -- --sdn-zone-id 0 --sdn-zone-node-id 1 --seeds-from-node-api "http://localhost:3000/api/node/address" media
cargo run -- --sdn-zone-id 0 --sdn-zone-node-id 1 --seeds-from-node-api "http://localhost:3000" media
```

This way is flexible and convenient to manage, and we can also use it to dynamically get the addresses of other nodes.
Expand All @@ -35,20 +35,14 @@ For example, we might have a loadbalancer config like this:
| 1 | Gateway | http://gateway.zone1.atm0s.cloud |
| 2 | Gateway | http://gateway.zone2.atm0s.cloud |

```
http://console.atm0s.cloud/api/node/address
http://gateway.zone1.atm0s.cloud/api/node/address
http://gateway.zone2.atm0s.cloud/api/node/address
```

Then we can start nodes with config like this:

| Zone | Node Type | Seeds From API |
| ---- | --------- | ------------------------------------------------- |
| 0 | Gateway | http://console.atm0s.cloud/api/node/address |
| 0 | Media | http://gateway.zone0.atm0s.cloud/api/node/address |
| 1 | Gateway | http://console.atm0s.cloud/api/node/address |
| 1 | Media | http://gateway.zone1.atm0s.cloud/api/node/address |
| 2 | Gateway | http://console.atm0s.cloud/api/node/address |
| 2 | Media | http://gateway.zone2.atm0s.cloud/api/node/address |
| Zone | Node Type | Seeds From API |
| ---- | --------- | -------------------------------- |
| 0 | Gateway | http://console.atm0s.cloud |
| 0 | Media | http://gateway.zone0.atm0s.cloud |
| 1 | Gateway | http://console.atm0s.cloud |
| 1 | Media | http://gateway.zone1.atm0s.cloud |
| 2 | Gateway | http://console.atm0s.cloud |
| 2 | Media | http://gateway.zone2.atm0s.cloud |

0 comments on commit ec6b19c

Please sign in to comment.