diff --git a/packages/api/actor/src/route/mod.rs b/packages/api/actor/src/route/mod.rs index 940ce82544..2a195e5d82 100644 --- a/packages/api/actor/src/route/mod.rs +++ b/packages/api/actor/src/route/mod.rs @@ -91,7 +91,7 @@ define_router! { ), }, - "actors" / Uuid / "logs" : { + "actors" / Uuid / "logs": { GET: logs::get_logs( query: logs::GetActorLogsQuery, opt_auth: true, diff --git a/packages/common/chirp-workflow/core/src/db/pg_nats.rs b/packages/common/chirp-workflow/core/src/db/pg_nats.rs index c4db081a67..4919e7d7c6 100644 --- a/packages/common/chirp-workflow/core/src/db/pg_nats.rs +++ b/packages/common/chirp-workflow/core/src/db/pg_nats.rs @@ -715,7 +715,7 @@ impl Database for DatabasePgNats { ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (workflow_id, location2_hash) DO UPDATE - SET output = excluded.output + SET output = EXCLUDED.output ", )) .bind(workflow_id) diff --git a/packages/services/cloud/standalone/default-create/Cargo.toml b/packages/services/cloud/standalone/default-create/Cargo.toml index 5e3579fa17..30213ded7d 100644 --- a/packages/services/cloud/standalone/default-create/Cargo.toml +++ b/packages/services/cloud/standalone/default-create/Cargo.toml @@ -9,27 +9,28 @@ license = "Apache-2.0" chirp-client = { path = "../../../../common/chirp/client" } chirp-workflow = { path = "../../../../common/chirp-workflow/core" } reqwest = "0.11" +rivet-config = { version = "0.1.0", path = "../../../../common/config" } rivet-connection = { path = "../../../../common/connection" } rivet-pools = { path = "../../../../common/pools" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.40", features = ["full"] } tracing = "0.1" -tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "json", "ansi"] } tracing-logfmt = "0.3" +tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "json", "ansi"] } uuid = { version = "1", features = ["v4"] } -rivet-config = { version = "0.1.0", path = "../../../../common/config" } -user = { version = "0.1.0", path = "../../../user" } -game-resolve-name-id = { version = "0.0.1", path = "../../../game/ops/resolve-name-id" } cloud-game-config-create = { version = "0.0.1", path = "../../ops/game-config-create" } -team-resolve-display-name = { version = "0.0.1", path = "../../../team/ops/resolve-display-name" } cloud-namespace-create = { version = "0.0.1", path = "../../ops/namespace-create" } +cloud-version-publish = { version = "0.0.1", path = "../../ops/version-publish" } +ds = { version = "0.0.1", path = "../../../ds" } game-create = { version = "0.0.1", path = "../../../game/ops/create" } -rivet-operation = { version = "0.1.0", path = "../../../../common/operation/core" } -game-namespace-resolve-name-id = { version = "0.0.1", path = "../../../game/ops/namespace-resolve-name-id" } game-namespace-create = { version = "0.0.1", path = "../../../game/ops/namespace-create" } -cloud-version-publish = { version = "0.0.1", path = "../../ops/version-publish" } +game-namespace-resolve-name-id = { version = "0.0.1", path = "../../../game/ops/namespace-resolve-name-id" } +game-resolve-name-id = { version = "0.0.1", path = "../../../game/ops/resolve-name-id" } +rivet-operation = { version = "0.1.0", path = "../../../../common/operation/core" } +team-resolve-display-name = { version = "0.0.1", path = "../../../team/ops/resolve-display-name" } +user = { version = "0.1.0", path = "../../../user" } [dev-dependencies] chirp-worker = { path = "../../../../common/chirp/worker" } diff --git a/packages/services/cloud/standalone/default-create/src/lib.rs b/packages/services/cloud/standalone/default-create/src/lib.rs index 4036b7a8cb..db2e1559db 100644 --- a/packages/services/cloud/standalone/default-create/src/lib.rs +++ b/packages/services/cloud/standalone/default-create/src/lib.rs @@ -1,3 +1,4 @@ +use ::ds; use chirp_workflow::prelude::*; use rivet_operation::prelude::proto::backend::{self, pkg::*}; use util::dev_defaults; @@ -84,7 +85,17 @@ pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> G }) .await?; - unwrap_ref!(create_game_res.game_id).as_uuid() + let game_id = unwrap_ref!(create_game_res.game_id).as_uuid(); + + ctx.op(ds::ops::game_config::upsert::Input { + game_id, + host_networking_enabled: Some(true), + root_user_enabled: Some(true), + ..Default::default() + }) + .await?; + + game_id }; // Create namespace diff --git a/packages/services/ds/src/ops/game_config/mod.rs b/packages/services/ds/src/ops/game_config/mod.rs index 0e93baa52b..796e2aad8c 100644 --- a/packages/services/ds/src/ops/game_config/mod.rs +++ b/packages/services/ds/src/ops/game_config/mod.rs @@ -1,2 +1,2 @@ pub mod get; -pub mod update; +pub mod upsert; diff --git a/packages/services/ds/src/ops/game_config/update.rs b/packages/services/ds/src/ops/game_config/update.rs deleted file mode 100644 index fc32d94d88..0000000000 --- a/packages/services/ds/src/ops/game_config/update.rs +++ /dev/null @@ -1,33 +0,0 @@ -use chirp_workflow::prelude::*; - -use crate::types::ServerRuntime; - -#[derive(Debug, Default)] -pub struct Input { - pub game_id: Uuid, - pub host_networking_enabled: Option, - pub root_user_enabled: Option, - pub runtime: Option, -} - -#[operation] -pub async fn ds_game_config_update(ctx: &OperationCtx, input: &Input) -> GlobalResult<()> { - sql_execute!( - [ctx] - " - UPDATE db_ds.game_config - SET - host_networking_enabled = COALESCE($2, host_networking_enabled), - root_user_enabled = COALESCE($3, root_user_enabled), - runtime = COALESCE($4, runtime) - WHERE game_id = $1 - ", - &input.game_id, - input.host_networking_enabled, - input.root_user_enabled, - input.runtime.map(|x| x as i32), - ) - .await?; - - Ok(()) -} diff --git a/packages/services/ds/src/ops/game_config/upsert.rs b/packages/services/ds/src/ops/game_config/upsert.rs new file mode 100644 index 0000000000..572f1d3061 --- /dev/null +++ b/packages/services/ds/src/ops/game_config/upsert.rs @@ -0,0 +1,34 @@ +use chirp_workflow::prelude::*; + +use crate::types::ServerRuntime; + +#[derive(Debug, Default)] +pub struct Input { + pub game_id: Uuid, + pub host_networking_enabled: Option, + pub root_user_enabled: Option, + pub runtime: Option, +} + +#[operation] +pub async fn ds_game_config_upsert(ctx: &OperationCtx, input: &Input) -> GlobalResult<()> { + sql_execute!( + [ctx] + " + INSERT INTO db_ds.game_config (game_id, host_networking_enabled, root_user_enabled, runtime) + VALUES ($1, $2, $3, $4) + ON CONFLICT (game_id) DO UPDATE + SET + host_networking_enabled = COALESCE($2, EXCLUDED.host_networking_enabled), + root_user_enabled = COALESCE($3, EXCLUDED.root_user_enabled), + runtime = COALESCE($4, EXCLUDED.runtime) + ", + &input.game_id, + input.host_networking_enabled, + input.root_user_enabled, + input.runtime.unwrap_or_default() as i32, + ) + .await?; + + Ok(()) +} diff --git a/packages/services/ds/src/types.rs b/packages/services/ds/src/types.rs index d7a8904d69..c9883a5107 100644 --- a/packages/services/ds/src/types.rs +++ b/packages/services/ds/src/types.rs @@ -88,9 +88,10 @@ pub enum HostProtocol { Udp = 1, } -#[derive(Serialize, Deserialize, Hash, Debug, Clone, Copy, PartialEq, Eq, FromRepr)] +#[derive(Serialize, Deserialize, Hash, Debug, Clone, Copy, PartialEq, Eq, FromRepr, Default)] pub enum ServerRuntime { Nomad = 0, + #[default] Pegboard = 1, } @@ -108,7 +109,7 @@ impl GameConfig { game_id, host_networking_enabled: false, root_user_enabled: false, - runtime: ServerRuntime::Pegboard, + runtime: ServerRuntime::default(), } } }