From a2a8c3cfbce83c4680fa8cb632927f380089dd2e Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Thu, 11 Sep 2025 14:32:36 -0700 Subject: [PATCH] chore: cleanup, move ee changes --- frontend/packages/components/src/lib/config.ts | 2 ++ frontend/src/components/lib/config.ts | 2 ++ packages/common/universaldb/src/error.rs | 2 -- packages/core/bootstrap/src/lib.rs | 2 +- .../services/epoxy/src/ops/explicit_prepare.rs | 5 ++++- packages/services/epoxy/src/ops/kv/get_local.rs | 2 +- .../services/epoxy/src/ops/kv/get_optimistic.rs | 2 +- packages/services/epoxy/src/ops/propose.rs | 2 +- .../services/epoxy/src/ops/read_cluster_config.rs | 2 +- .../services/epoxy/src/replica/message_request.rs | 4 ++-- .../epoxy/src/workflows/coordinator/mod.rs | 14 +++++++------- .../workflows/coordinator/replica_status_change.rs | 2 +- .../services/epoxy/src/workflows/replica/mod.rs | 10 +++++----- .../services/epoxy/src/workflows/replica/setup.rs | 14 +++++++------- packages/services/epoxy/tests/common/mod.rs | 2 +- packages/services/epoxy/tests/reconfigure.rs | 2 +- sdks/typescript/test-runner/src/main.ts | 10 ++++++---- 17 files changed, 43 insertions(+), 36 deletions(-) diff --git a/frontend/packages/components/src/lib/config.ts b/frontend/packages/components/src/lib/config.ts index 91b9537457..2131a0d0fc 100644 --- a/frontend/packages/components/src/lib/config.ts +++ b/frontend/packages/components/src/lib/config.ts @@ -31,6 +31,8 @@ const getApiEndpoint = (apiEndpoint: string) => { } // Default to staging servers for all other endpoints return "https://api.staging2.gameinc.io"; + } else if (apiEndpoint === "__SAME__") { + return location.origin; } return apiEndpoint; }; diff --git a/frontend/src/components/lib/config.ts b/frontend/src/components/lib/config.ts index 91b9537457..2131a0d0fc 100644 --- a/frontend/src/components/lib/config.ts +++ b/frontend/src/components/lib/config.ts @@ -31,6 +31,8 @@ const getApiEndpoint = (apiEndpoint: string) => { } // Default to staging servers for all other endpoints return "https://api.staging2.gameinc.io"; + } else if (apiEndpoint === "__SAME__") { + return location.origin; } return apiEndpoint; }; diff --git a/packages/common/universaldb/src/error.rs b/packages/common/universaldb/src/error.rs index 04451239e5..f4b0ccd963 100644 --- a/packages/common/universaldb/src/error.rs +++ b/packages/common/universaldb/src/error.rs @@ -12,8 +12,6 @@ pub enum DatabaseError { #[error("operation issued while a commit was outstanding")] UsedDuringCommit, - // #[error(transparent)] - // Custom(Box), } impl DatabaseError { diff --git a/packages/core/bootstrap/src/lib.rs b/packages/core/bootstrap/src/lib.rs index 304ccafbee..f2684557b6 100644 --- a/packages/core/bootstrap/src/lib.rs +++ b/packages/core/bootstrap/src/lib.rs @@ -42,7 +42,7 @@ async fn setup_epoxy_coordinator(ctx: &StandaloneCtx) -> Result<()> { // // This does not guarantee the config will change immediately since we can't guarantee that the // coordinator workflow is running on a node with the newest version of the config. - ctx.signal(epoxy::workflows::coordinator::ReconfigureSignal {}) + ctx.signal(epoxy::workflows::coordinator::Reconfigure {}) .to_workflow_id(workflow_id) .send() .await?; diff --git a/packages/services/epoxy/src/ops/explicit_prepare.rs b/packages/services/epoxy/src/ops/explicit_prepare.rs index 9fef6278be..14ca28852a 100644 --- a/packages/services/epoxy/src/ops/explicit_prepare.rs +++ b/packages/services/epoxy/src/ops/explicit_prepare.rs @@ -20,7 +20,10 @@ pub enum ExplicitPrepareResult { } #[operation] -pub async fn explicit_prepare(ctx: &OperationCtx, input: &Input) -> Result { +pub async fn epoxy_explicit_prepare( + ctx: &OperationCtx, + input: &Input, +) -> Result { let replica_id = ctx.config().epoxy_replica_id(); let instance = &input.instance; diff --git a/packages/services/epoxy/src/ops/kv/get_local.rs b/packages/services/epoxy/src/ops/kv/get_local.rs index 74636d9d04..ef314689a3 100644 --- a/packages/services/epoxy/src/ops/kv/get_local.rs +++ b/packages/services/epoxy/src/ops/kv/get_local.rs @@ -18,7 +18,7 @@ pub struct Output { } #[operation] -pub async fn get_local(ctx: &OperationCtx, input: &Input) -> Result { +pub async fn epoxy_kv_get_local(ctx: &OperationCtx, input: &Input) -> Result { // Read from local KV store only let kv_key = keys::keys::KvValueKey::new(input.key.clone()); let subspace = keys::subspace(input.replica_id); diff --git a/packages/services/epoxy/src/ops/kv/get_optimistic.rs b/packages/services/epoxy/src/ops/kv/get_optimistic.rs index 1f9802e68a..6335cbbb90 100644 --- a/packages/services/epoxy/src/ops/kv/get_optimistic.rs +++ b/packages/services/epoxy/src/ops/kv/get_optimistic.rs @@ -35,7 +35,7 @@ pub struct Output { /// /// We cannot use quorum reads for the fanout read because of the constraints of Epaxos. #[operation] -pub async fn get_optimistic(ctx: &OperationCtx, input: &Input) -> Result { +pub async fn epoxy_kv_get_optimistic(ctx: &OperationCtx, input: &Input) -> Result { // Try to read locally let kv_key = keys::keys::KvValueKey::new(input.key.clone()); let cache_key = keys::keys::KvOptimisticCacheKey::new(input.key.clone()); diff --git a/packages/services/epoxy/src/ops/propose.rs b/packages/services/epoxy/src/ops/propose.rs index 6f9b05f7dc..8c42747036 100644 --- a/packages/services/epoxy/src/ops/propose.rs +++ b/packages/services/epoxy/src/ops/propose.rs @@ -27,7 +27,7 @@ pub struct Input { } #[operation] -pub async fn propose(ctx: &OperationCtx, input: &Input) -> Result { +pub async fn epoxy_propose(ctx: &OperationCtx, input: &Input) -> Result { let replica_id = ctx.config().epoxy_replica_id(); // Read config diff --git a/packages/services/epoxy/src/ops/read_cluster_config.rs b/packages/services/epoxy/src/ops/read_cluster_config.rs index 859f687aa0..ef4dc2d85c 100644 --- a/packages/services/epoxy/src/ops/read_cluster_config.rs +++ b/packages/services/epoxy/src/ops/read_cluster_config.rs @@ -15,7 +15,7 @@ pub struct Output { } #[operation] -pub async fn read_config(ctx: &OperationCtx, input: &Input) -> Result { +pub async fn epoxy_read_cluster_config(ctx: &OperationCtx, input: &Input) -> Result { let config = ctx .udb()? .run(|tx| { diff --git a/packages/services/epoxy/src/replica/message_request.rs b/packages/services/epoxy/src/replica/message_request.rs index 9dd0a3655d..44ec707be1 100644 --- a/packages/services/epoxy/src/replica/message_request.rs +++ b/packages/services/epoxy/src/replica/message_request.rs @@ -100,7 +100,7 @@ pub async fn message_request( "received coordinator update replica status request" ); - ctx.signal(crate::workflows::coordinator::ReplicaStatusChangeSignal { + ctx.signal(crate::workflows::coordinator::ReplicaStatusChange { replica_id: req.replica_id, status: req.status.into(), }) @@ -118,7 +118,7 @@ pub async fn message_request( "received begin learning request" ); - ctx.signal(crate::workflows::replica::BeginLearningSignal { + ctx.signal(crate::workflows::replica::BeginLearning { config: req.config.clone().into(), }) .to_workflow::() diff --git a/packages/services/epoxy/src/workflows/coordinator/mod.rs b/packages/services/epoxy/src/workflows/coordinator/mod.rs index 8c86d913e4..e5afb33f26 100644 --- a/packages/services/epoxy/src/workflows/coordinator/mod.rs +++ b/packages/services/epoxy/src/workflows/coordinator/mod.rs @@ -25,16 +25,16 @@ pub struct ReplicaState { } #[workflow] -pub async fn coordinator(ctx: &mut WorkflowCtx, _input: &Input) -> Result<()> { +pub async fn epoxy_coordinator(ctx: &mut WorkflowCtx, _input: &Input) -> Result<()> { ctx.activity(InitInput {}).await?; ctx.repeat(|ctx| { async move { match ctx.listen::
().await? { - Main::ReconfigureSignal(_) => { + Main::Reconfigure(_) => { reconfigure::reconfigure(ctx).await?; } - Main::ReplicaStatusChangeSignal(sig) => { + Main::ReplicaStatusChange(sig) => { replica_status_change::replica_status_change(ctx, sig).await?; } } @@ -73,15 +73,15 @@ pub struct ConfigChangeMessage { /// /// This gets called any time an engine node starts. #[signal("epoxy_coordinator_reconfigure")] -pub struct ReconfigureSignal {} +pub struct Reconfigure {} #[signal("epoxy_coordinator_replica_status_change")] -pub struct ReplicaStatusChangeSignal { +pub struct ReplicaStatusChange { pub replica_id: protocol::ReplicaId, pub status: types::ReplicaStatus, } join_signal!(Main { - ReconfigureSignal, - ReplicaStatusChangeSignal, + Reconfigure, + ReplicaStatusChange, }); diff --git a/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs b/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs index 2c92745cab..41da43f595 100644 --- a/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs +++ b/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs @@ -8,7 +8,7 @@ use crate::types; pub async fn replica_status_change( ctx: &mut WorkflowCtx, - signal: super::ReplicaStatusChangeSignal, + signal: super::ReplicaStatusChange, ) -> Result<()> { // Update replica status let should_increment_epoch = ctx diff --git a/packages/services/epoxy/src/workflows/replica/mod.rs b/packages/services/epoxy/src/workflows/replica/mod.rs index 85583b4619..36a29cfbde 100644 --- a/packages/services/epoxy/src/workflows/replica/mod.rs +++ b/packages/services/epoxy/src/workflows/replica/mod.rs @@ -14,14 +14,14 @@ pub use setup::*; pub struct Input {} #[workflow] -pub async fn replica(ctx: &mut WorkflowCtx, input: &Input) -> Result<()> { +pub async fn epoxy_replica(ctx: &mut WorkflowCtx, input: &Input) -> Result<()> { setup_replica(ctx, input).await?; // Main loop ctx.repeat(|ctx| { async move { // Noop for now - ctx.listen::().await?; + ctx.listen::
().await?; Ok(Loop::<()>::Continue) } .boxed() @@ -32,9 +32,9 @@ pub async fn replica(ctx: &mut WorkflowCtx, input: &Input) -> Result<()> { } #[signal("epoxy_replica_begin_learning")] -pub struct BeginLearningSignal { +pub struct BeginLearning { pub config: types::ClusterConfig, } -#[signal("main")] -pub struct MainSignal {} +#[signal("epoxy_replica_main")] +pub struct Main {} diff --git a/packages/services/epoxy/src/workflows/replica/setup.rs b/packages/services/epoxy/src/workflows/replica/setup.rs index 278c77269d..31671b7341 100644 --- a/packages/services/epoxy/src/workflows/replica/setup.rs +++ b/packages/services/epoxy/src/workflows/replica/setup.rs @@ -10,14 +10,14 @@ use universaldb::{KeySelector, RangeOption, options::StreamingMode}; use crate::types; // IMPORTANT: Do not use `read_cluster_config`. Instead, use the config provided by -// `BeginLearningSignal`. This is because the value of `read_cluster_config` may change between +// `BeginLearning`. This is because the value of `read_cluster_config` may change between // activities which can cause the learning process to enter an invalid state. pub async fn setup_replica(ctx: &mut WorkflowCtx, _input: &super::Input) -> Result<()> { - // Wait for cooridinator to send begin learning signal - let begin_learning = ctx.listen::().await?; + // Wait for coordiinator to send begin learning signal + let begin_learning = ctx.listen::().await?; - // TODO: Paralellize replicas + // TODO: Parallelize replicas let total_replicas = begin_learning.config.replicas.len(); let mut replica_index = 0; @@ -134,7 +134,7 @@ pub async fn setup_replica(ctx: &mut WorkflowCtx, _input: &super::Input) -> Resu #[derive(Debug, Clone, Serialize, Deserialize, Hash)] pub struct DownloadInstancesChunkInput { - /// Config received from BeginLearningSignal + /// Config received from BeginLearning pub learning_config: types::ClusterConfig, pub from_replica_id: protocol::ReplicaId, pub after_instance: Option, @@ -312,7 +312,7 @@ async fn apply_log_entry( #[derive(Debug, Clone, Serialize, Deserialize, Hash)] pub struct RecoverKeysChunkInput { - /// Config received from BeginLearningSignal + /// Config received from BeginLearning pub learning_config: types::ClusterConfig, /// The last key value from the previous chunk, used for pagination pub after_key: Option>, @@ -728,7 +728,7 @@ struct CommittedEntry { #[derive(Debug, Clone, Serialize, Deserialize, Hash)] pub struct NotifyActiveInput { - /// Config received from BeginLearningSignal + /// Config received from BeginLearning pub learning_config: types::ClusterConfig, } diff --git a/packages/services/epoxy/tests/common/mod.rs b/packages/services/epoxy/tests/common/mod.rs index 2a108a3b63..5f60c2aa44 100644 --- a/packages/services/epoxy/tests/common/mod.rs +++ b/packages/services/epoxy/tests/common/mod.rs @@ -284,7 +284,7 @@ async fn setup_epoxy_coordinator_wf( ) .await?; leader_ctx - .signal(epoxy::workflows::coordinator::ReconfigureSignal {}) + .signal(epoxy::workflows::coordinator::Reconfigure {}) .to_workflow_id(workflow_id) .send() .await?; diff --git a/packages/services/epoxy/tests/reconfigure.rs b/packages/services/epoxy/tests/reconfigure.rs index 948e358b29..80369255b1 100644 --- a/packages/services/epoxy/tests/reconfigure.rs +++ b/packages/services/epoxy/tests/reconfigure.rs @@ -321,7 +321,7 @@ async fn test_inner(config: TestConfig) { .await .unwrap(); leader_ctx - .signal(epoxy::workflows::coordinator::ReconfigureSignal {}) + .signal(epoxy::workflows::coordinator::Reconfigure {}) .to_workflow_id(test_ctx.coordinator_workflow_id) .send() .await diff --git a/sdks/typescript/test-runner/src/main.ts b/sdks/typescript/test-runner/src/main.ts index fbe681326d..12e13fe7c7 100644 --- a/sdks/typescript/test-runner/src/main.ts +++ b/sdks/typescript/test-runner/src/main.ts @@ -61,8 +61,6 @@ app.get('/start', async (c) => { }); }); -app.get('*', (c) => c.text('ok')); - serve({ fetch: app.fetch, port: INTERNAL_SERVER_PORT, @@ -72,6 +70,8 @@ console.log(`Internal HTTP server listening on port ${INTERNAL_SERVER_PORT}`); if (AUTOSTART) runner = await startRunner(); async function startRunner(): Promise { + console.log("Starting runner"); + const config: RunnerConfig = { version: RIVET_RUNNER_VERSION, endpoint: RIVET_ENDPOINT, @@ -154,7 +154,7 @@ async function startRunner(): Promise { }, }; - runner = new Runner(config); + let runner = new Runner(config); // Start runner await runner.start(); @@ -163,5 +163,7 @@ async function startRunner(): Promise { console.log("Waiting runner start..."); await runnerStarted.promise; + console.log("Runner started"); + return runner; -} \ No newline at end of file +}