Skip to content

Commit

Permalink
Add a server unavailable endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation committed Dec 14, 2024
1 parent 2dd96b0 commit 38f3544
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/rpc/src/bin/metric_exporter/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async fn main() -> Result<()> {
routes![
metrics_endpoint,
start_server,
server_unavailable,
start_game,
end_game,
player_joined,
Expand Down Expand Up @@ -133,6 +134,11 @@ fn start_server(state: &State<LocalState>) {
state.metrics.start_server();
}

#[post("/server_unavailable")]
fn server_unavailable(state: &State<LocalState>) {
state.metrics.server_unavailable();
}

#[post("/start_game")]
fn start_game(state: &State<LocalState>) {
state.metrics.start_game();
Expand Down
6 changes: 6 additions & 0 deletions crates/rpc/src/bin/metric_exporter/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ impl Metrics {
self.game_state.set(GameState::Waiting.into());
self.players_current.set(0);
}

pub fn server_unavailable(&self) {
self.game_state.set(GameState::Done.into());
self.games_current.set(0);
self.players_current.set(0);
}

pub fn start_game(&self) {
self.games_current.set(1);
Expand Down

0 comments on commit 38f3544

Please sign in to comment.