-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add region list/resolve per game
- Loading branch information
1 parent
c1ef2d5
commit 720a42f
Showing
41 changed files
with
611 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "cluster-get-for-game" | ||
version = "0.0.1" | ||
edition = "2018" | ||
authors = ["Rivet Gaming, LLC <developer@rivet.gg>"] | ||
license = "Apache-2.0" | ||
|
||
[dependencies] | ||
chirp-client = { path = "../../../../../lib/chirp/client" } | ||
prost = "0.10" | ||
rivet-operation = { path = "../../../../../lib/operation/core" } | ||
|
||
[dependencies.sqlx] | ||
version = "0.7" | ||
default-features = false | ||
|
||
[dev-dependencies] | ||
chirp-worker = { path = "../../../../../lib/chirp/worker" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[service] | ||
name = "cluster-get-for-game" | ||
|
||
[runtime] | ||
kind = "rust" | ||
|
||
[operation] | ||
|
||
[databases] | ||
db-cluster = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use proto::backend::pkg::*; | ||
use rivet_operation::prelude::*; | ||
|
||
#[operation(name = "cluster-get-for-game")] | ||
pub async fn handle( | ||
ctx: OperationContext<cluster::get_for_game::Request>, | ||
) -> GlobalResult<cluster::get_for_game::Response> { | ||
let game_ids = ctx | ||
.game_ids | ||
.iter() | ||
.map(common::Uuid::as_uuid) | ||
.collect::<Vec<_>>(); | ||
|
||
let rows = sql_fetch_optional!( | ||
[ctx, (Uuid, Option<Uuid>)] | ||
" | ||
SELECT | ||
g.game_id, gc.cluster_id | ||
FROM unnest($1) AS g(game_id) | ||
LEFT JOIN db_cluster.games AS gc | ||
ON g.game_id = gc.game_id | ||
", | ||
game_ids, | ||
) | ||
.await?; | ||
|
||
Ok(cluster::get_for_game::Response { | ||
games: rows | ||
.into_iter() | ||
.map( | ||
|(game_id, cluster_id)| cluster::get_for_game::response::Game { | ||
game_id: Some(game_id.into()), | ||
cluster_id: Some( | ||
cluster_id | ||
.unwrap_or_else(util::env::default_cluster_id) | ||
.into(), | ||
), | ||
}, | ||
) | ||
.collect::<Vec<_>>(), | ||
}) | ||
} |
Oops, something went wrong.