Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ members = [
"engine/packages/config",
"engine/packages/config-schema-gen",
"engine/packages/datacenter",
"engine/packages/depot-client",
"engine/packages/depot-client-embedded",
"engine/packages/depot-client-types",
"engine/packages/engine",
"engine/packages/env",
"engine/packages/epoxy",
Expand Down Expand Up @@ -63,8 +66,6 @@ members = [
"rivetkit-rust/packages/actor-persist",
"rivetkit-rust/packages/rivetkit-core",
"rivetkit-rust/packages/shared-types",
"engine/packages/depot-client",
"engine/packages/depot-client-types",
"rivetkit-typescript/packages/rivetkit-napi",
"rivetkit-typescript/packages/rivetkit-wasm"
]
Expand Down Expand Up @@ -561,6 +562,9 @@ members = [
[workspace.dependencies.depot-client]
path = "engine/packages/depot-client"

[workspace.dependencies.depot-client-embedded]
path = "engine/packages/depot-client-embedded"

[workspace.dependencies.depot-client-types]
path = "engine/packages/depot-client-types"

Expand Down
19 changes: 19 additions & 0 deletions engine/packages/depot-client-embedded/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "depot-client-embedded"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
workspace = "../../../"
description = "Embedded Depot transport for depot-client SQLite VFS"

[lib]
crate-type = ["lib"]

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
depot.workspace = true
depot-client.workspace = true
rivet-envoy-protocol.workspace = true
tokio.workspace = true
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
//! SQLite transport adapters.
//! Embedded Depot transport for depot-client.
//!
//! `EmbeddedDepotSqliteTransport` is for deployments where the SQLite VFS runs in the
//! same process or server as the Depot backend. It calls `depot::conveyer::Db`
//! directly instead of routing page operations through an actor Envoy transport.
//! This crate is for deployments where the SQLite VFS runs in the same process
//! as the Depot backend. It keeps engine storage dependencies out of the base
//! `depot-client` crate used by NAPI.

use std::sync::Arc;

use anyhow::Result;
use async_trait::async_trait;
use depot_client::{
database::{NativeDatabaseHandle, open_database_from_transport},
vfs::{SqliteTransport, SqliteVfsMetrics},
};
use rivet_envoy_protocol as protocol;

use crate::vfs::SqliteTransport;
use tokio::runtime::Handle;

pub struct EmbeddedDepotSqliteTransport {
db: Arc<depot::conveyer::Db>,
Expand All @@ -22,6 +25,23 @@ impl EmbeddedDepotSqliteTransport {
}
}

pub async fn open_database_from_embedded_depot(
db: Arc<depot::conveyer::Db>,
actor_id: String,
generation: u64,
rt_handle: Handle,
metrics: Option<Arc<dyn SqliteVfsMetrics>>,
) -> Result<NativeDatabaseHandle> {
open_database_from_transport(
Arc::new(EmbeddedDepotSqliteTransport::new(db)),
actor_id,
generation,
rt_handle,
metrics,
)
.await
}

#[async_trait]
impl SqliteTransport for EmbeddedDepotSqliteTransport {
async fn get_pages(
Expand Down
1 change: 0 additions & 1 deletion engine/packages/depot-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ tracing.workspace = true
getrandom = "0.2"
rivet-envoy-protocol.workspace = true
depot-client-types.workspace = true
depot.workspace = true
moka = { version = "0.12", default-features = false, features = ["sync"] }
parking_lot.workspace = true
scc.workspace = true
Expand Down
18 changes: 0 additions & 18 deletions engine/packages/depot-client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use tokio::runtime::Handle;

use crate::{
query::{BindParam, ExecResult, ExecuteResult, QueryResult},
transport::EmbeddedDepotSqliteTransport,
vfs::{
NativeVfsHandle, SqliteTransportHandle, SqliteVfs, SqliteVfsMetrics,
SqliteVfsMetricsSnapshot, VfsConfig, VfsPreloadHintSnapshot,
Expand Down Expand Up @@ -54,23 +53,6 @@ pub async fn open_database_from_transport(
Ok(native_db)
}

pub async fn open_database_from_embedded_depot(
db: Arc<depot::conveyer::Db>,
actor_id: String,
generation: u64,
rt_handle: Handle,
metrics: Option<Arc<dyn SqliteVfsMetrics>>,
) -> Result<NativeDatabaseHandle> {
open_database_from_transport(
Arc::new(EmbeddedDepotSqliteTransport::new(db)),
actor_id,
generation,
rt_handle,
metrics,
)
.await
}

impl NativeDatabaseHandle {
pub fn new(vfs: NativeVfsHandle, file_name: String) -> Result<Self> {
Self::new_with_metrics(vfs, file_name, None)
Expand Down
3 changes: 0 additions & 3 deletions engine/packages/depot-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ pub mod optimization_flags;
/// SQLite query execution helpers.
pub mod query;

/// SQLite transport adapters for same-process Depot usage.
pub mod transport;

pub use depot_client_types as types;

/// Custom SQLite VFS for actor-side depot transport.
Expand Down
1 change: 1 addition & 0 deletions engine/packages/pegboard-envoy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rivet-metrics.workspace = true
rivet-pools.workspace = true
rivet-envoy-protocol.workspace = true
depot-client.workspace = true
depot-client-embedded.workspace = true
rivet-runtime.workspace = true
rivet-types.workspace = true
scc.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion engine/packages/pegboard-envoy/src/ws_to_tunnel_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use depot::{
},
};
use depot_client::{
database::{NativeDatabaseHandle, open_database_from_embedded_depot},
database::NativeDatabaseHandle,
types::{BindParam, ColumnValue, ExecuteResult, QueryResult},
};
use depot_client_embedded::open_database_from_embedded_depot;
use futures_util::{FutureExt, TryStreamExt};
use gas::prelude::Id;
use gas::prelude::*;
Expand Down
2 changes: 0 additions & 2 deletions rivetkit-rust/packages/rivetkit-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ default = ["native-runtime"]
native-runtime = [
"dep:nix",
"dep:reqwest",
"dep:rivet-pools",
"rivet-envoy-client/native-transport",
]
wasm-runtime = ["rivet-envoy-client/wasm-transport"]
Expand All @@ -32,7 +31,6 @@ parking_lot.workspace = true
prometheus.workspace = true
rand.workspace = true
reqwest = { workspace = true, optional = true }
rivet-pools = { workspace = true, optional = true }
rivet-error.workspace = true
rivet-envoy-client = { workspace = true, default-features = false }
rivetkit-shared-types.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions rivetkit-rust/packages/rivetkit-core/src/engine_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::Stdio;
use std::time::{Duration, Instant};

use anyhow::{Context, Result};
use reqwest::Url;
use reqwest::{Client, Url};
use serde::Deserialize;
use tokio::process::{Child, Command};
use tokio::task::JoinHandle;
Expand Down Expand Up @@ -233,8 +233,8 @@ fn spawn_engine_watcher(mut child: Child, pid: u32) -> JoinHandle<()> {
/// (for example a stale rivetkit) which would conflict with a fresh spawn.
async fn probe_existing_engine(endpoint: &str) -> Result<Option<EngineHealthResponse>> {
let health_url = engine_health_url(endpoint);
let client = rivet_pools::reqwest::client()
.await
let client = Client::builder()
.build()
.context("build reqwest client for engine probe")?;

let response = match client
Expand Down Expand Up @@ -316,8 +316,8 @@ async fn wait_for_engine_health(health_url: &str) -> Result<EngineHealthResponse
const HEALTH_INITIAL_BACKOFF: Duration = Duration::from_millis(100);
const HEALTH_MAX_BACKOFF: Duration = Duration::from_secs(1);

let client = rivet_pools::reqwest::client()
.await
let client = Client::builder()
.build()
.context("build reqwest client for engine health check")?;
let deadline = Instant::now() + HEALTH_MAX_WAIT;
let mut attempt = 0u32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub(super) async fn ensure_local_normal_runner_config(config: &ServeConfig) -> R
return Ok(());
}

let client = rivet_pools::reqwest::client()
.await
let client = Client::builder()
.build()
.context("build reqwest client for runner config")?;
let datacenters = get_datacenters(&client, config).await?;
let mut runner_datacenters = JsonMap::new();
Expand Down
Loading