This commit is contained in:
Cadey Ratio 2020-02-15 13:14:21 +00:00
parent 97d8ec4ee8
commit e1e4040c15
3 changed files with 54 additions and 1 deletions

49
Cargo.lock generated
View File

@ -128,6 +128,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "fnv"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
[[package]] [[package]]
name = "fsevent" name = "fsevent"
version = "0.4.0" version = "0.4.0"
@ -478,6 +484,7 @@ dependencies = [
"pathfinding", "pathfinding",
"rocket", "rocket",
"rocket_contrib", "rocket_contrib",
"rocket_prometheus",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json", "serde_json",
@ -501,6 +508,32 @@ dependencies = [
"unicode-xid 0.2.0", "unicode-xid 0.2.0",
] ]
[[package]]
name = "prometheus"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5567486d5778e2c6455b1b90ff1c558f29e751fc018130fa182e15828e728af1"
dependencies = [
"cfg-if",
"fnv",
"lazy_static",
"protobuf",
"quick-error",
"spin",
]
[[package]]
name = "protobuf"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6686ddd96a8dbe2687b5f2a687b2cfb520854010ec480f2d74c32e7c9873d3c5"
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "0.6.13" version = "0.6.13"
@ -602,6 +635,16 @@ dependencies = [
"unicode-xid 0.1.0", "unicode-xid 0.1.0",
] ]
[[package]]
name = "rocket_prometheus"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e4954e976f59c2ef8766aaa65352c8e6776f86cf99943f5f45785dab4160f8"
dependencies = [
"prometheus",
"rocket",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.2" version = "1.0.2"
@ -672,6 +715,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]] [[package]]
name = "state" name = "state"
version = "0.4.1" version = "0.4.1"

View File

@ -9,6 +9,7 @@ edition = "2018"
[dependencies] [dependencies]
rocket = "0" rocket = "0"
rocket_contrib = "0" rocket_contrib = "0"
rocket_prometheus = "0.3"
serde = "1.0" serde = "1.0"
serde_json = "1.0" serde_json = "1.0"
serde_derive = "1.0" serde_derive = "1.0"

View File

@ -68,7 +68,7 @@ fn find_path(
match path { match path {
None => return None, None => return None,
Some(x) => { Some(x) => {
return Some(x.0); return Some(x.0.iter().rev().cloned().collect());
} }
} }
} }
@ -154,7 +154,10 @@ fn find_target<'a>(gs: &'a battlesnake::SnakeRequest) -> &'a battlesnake::Coord
fn main() { fn main() {
let map = HashMap::<String, GameState>::new(); let map = HashMap::<String, GameState>::new();
let mutex_map = Mutex::from(map); let mutex_map = Mutex::from(map);
let prometheus = rocket_prometheus::PrometheusMetrics::new();
rocket::ignite() rocket::ignite()
.attach(prometheus.clone())
.mount("/metrics", prometheus)
.mount("/", routes![index, start, ping, make_move, end,]) .mount("/", routes![index, start, ping, make_move, end,])
.manage(mutex_map) .manage(mutex_map)
.launch(); .launch();