Skip to content

Commit 38f3544

Browse files
Add a server unavailable endpoint
1 parent 2dd96b0 commit 38f3544

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

crates/rpc/src/bin/metric_exporter/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ async fn main() -> Result<()> {
103103
routes![
104104
metrics_endpoint,
105105
start_server,
106+
server_unavailable,
106107
start_game,
107108
end_game,
108109
player_joined,
@@ -133,6 +134,11 @@ fn start_server(state: &State<LocalState>) {
133134
state.metrics.start_server();
134135
}
135136

137+
#[post("/server_unavailable")]
138+
fn server_unavailable(state: &State<LocalState>) {
139+
state.metrics.server_unavailable();
140+
}
141+
136142
#[post("/start_game")]
137143
fn start_game(state: &State<LocalState>) {
138144
state.metrics.start_game();

crates/rpc/src/bin/metric_exporter/metrics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ impl Metrics {
156156
self.game_state.set(GameState::Waiting.into());
157157
self.players_current.set(0);
158158
}
159+
160+
pub fn server_unavailable(&self) {
161+
self.game_state.set(GameState::Done.into());
162+
self.games_current.set(0);
163+
self.players_current.set(0);
164+
}
159165

160166
pub fn start_game(&self) {
161167
self.games_current.set(1);

0 commit comments

Comments
 (0)