|
|
@ -1,6 +1,6 @@ |
|
|
|
# crystal-scatter |
|
|
|
|
|
|
|
Release candidate for v0.1 "John Scott" |
|
|
|
Release candidate for v1.0 "David Robert Jones" |
|
|
|
|
|
|
|
## Installation |
|
|
|
|
|
|
@ -10,7 +10,7 @@ Add this to your application's `shard.yml`: |
|
|
|
dependencies: |
|
|
|
crystal-scatter: |
|
|
|
git: https://git.nekoit.xyz/Archivist/crystal-scatter |
|
|
|
version: ~> 0.1.0-rc2 |
|
|
|
version: ~> 1.0.0-rc1 |
|
|
|
``` |
|
|
|
|
|
|
|
## Usage |
|
|
@ -27,11 +27,11 @@ client_ip = "185.124.235.1" |
|
|
|
ring = Crystal::Scatter::MetaRing.new(3) |
|
|
|
|
|
|
|
ring.add [ |
|
|
|
Crystal::Scatter::Daemon (8 , [0,0,0,0,0,0], "https://api01.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (16, [0,0,0,0,1,0], "https://api02.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (12, [1,0,0,0,0,0], "https://api03.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (12, [1,0,0,0,1,0], "https://api04.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (12, [2,0,0,0,0,0], "https://api05.myservice.com") |
|
|
|
Crystal::Scatter::Daemon (8 , uuid01, [0,0,0,0,0,0], "https://api01.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (16, uuid02, [0,0,0,0,1,0], "https://api02.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (12, uuid03, [1,0,0,0,0,0], "https://api03.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (12, uuid04, [1,0,0,0,1,0], "https://api04.myservice.com"), |
|
|
|
Crystal::Scatter::Daemon (12, uuid05, [2,0,0,0,0,0], "https://api05.myservice.com") |
|
|
|
] |
|
|
|
|
|
|
|
ring.get_slices_for(client_ip) |
|
|
@ -47,16 +47,17 @@ The output will provide you information to contact the service in a balanced way |
|
|
|
### In details |
|
|
|
|
|
|
|
```crystal |
|
|
|
Crystal::Scatter::Daemon (12, [2,0,0,0,0,0], "https://api05.myservice.com") |
|
|
|
^ ^ ^ ^ ^ ^ ^ ^ |
|
|
|
| | | | | | | | |
|
|
|
| | | | | | | L Real target |
|
|
|
| | | | | | L Serving daemon |
|
|
|
| | | | | L Serving server |
|
|
|
| | | | L Serving PSU |
|
|
|
| | | L Serving rack |
|
|
|
| | L Serving room |
|
|
|
| L Serving datacenter |
|
|
|
Crystal::Scatter::Daemon (12, uuid, [2,0,0,0,0], "https://api05.myservice.com") |
|
|
|
^ ^ ^ ^ ^ ^ ^ ^ ^ |
|
|
|
| | | | | | | | | |
|
|
|
| | | | | | | | L Real target |
|
|
|
| | | | | | | L Serving daemon |
|
|
|
| | | | | | L Serving server |
|
|
|
| | | | | L Serving PSU |
|
|
|
| | | | L Serving rack |
|
|
|
| | | L Serving room |
|
|
|
| | L Serving datacenter |
|
|
|
| L UUID provided by the HARP wrapper |
|
|
|
L Weight |
|
|
|
``` |
|
|
|
|
|
|
|