Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion engine/packages/cache-purge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> R
let ups = pools.ups()?;
let mut sub = ups.subscribe(CACHE_PURGE_TOPIC).await?;

tracing::info!(subject=?CACHE_PURGE_TOPIC, "subscribed to cache purge updates");
tracing::debug!(subject=?CACHE_PURGE_TOPIC, "subscribed to cache purge updates");

// Get cache instance
let cache = rivet_cache::CacheInner::from_env(&config, pools)?;
Expand Down
11 changes: 11 additions & 0 deletions engine/packages/config/src/config/pegboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ pub struct Pegboard {
///
/// **Experimental**
pub runner_lost_threshold: Option<i64>,
/// How long after last ping before considering a hibernating request disconnected.
///
/// Unit is in milliseconds.
///
/// **Experimental**
pub hibernating_request_eligible_threshold: Option<i64>,
}

impl Pegboard {
Expand Down Expand Up @@ -80,4 +86,9 @@ impl Pegboard {
pub fn runner_lost_threshold(&self) -> i64 {
self.runner_lost_threshold.unwrap_or(15_000)
}

pub fn hibernating_request_eligible_threshold(&self) -> i64 {
self.hibernating_request_eligible_threshold
.unwrap_or(90_000)
}
}
4 changes: 1 addition & 3 deletions engine/packages/gasoline/src/db/kv/keys/worker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::result::Result::Ok;

use anyhow::*;
use anyhow::Result;
use rivet_util::Id;
use universaldb::prelude::*;

Expand Down
3 changes: 3 additions & 0 deletions engine/packages/guard-core/src/custom_serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub trait CustomServeTrait: Send + Sync {
_request_context: &mut RequestContext,
// Identifies the websocket across retries.
_unique_request_id: Uuid,
// True if this websocket is reconnecting after hibernation.
_after_hibernation: bool,
) -> Result<Option<CloseFrame>> {
bail!("service does not support websockets");
}
Expand All @@ -42,6 +44,7 @@ pub trait CustomServeTrait: Send + Sync {
async fn handle_websocket_hibernation(
&self,
_websocket: WebSocketHandle,
_unique_request_id: Uuid,
) -> Result<HibernationResult> {
bail!("service does not support websocket hibernation");
}
Expand Down
9 changes: 8 additions & 1 deletion engine/packages/guard-core/src/proxy_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ impl ProxyService {
async move {
let request_id = Uuid::new_v4();
let mut ws_hibernation_close = false;
let mut after_hibernation = false;
let mut attempts = 0u32;

let ws_handle = WebSocketHandle::new(client_ws)
Expand All @@ -1859,6 +1860,7 @@ impl ProxyService {
&req_path,
&mut request_context,
request_id,
after_hibernation,
)
.await
{
Expand Down Expand Up @@ -1926,9 +1928,14 @@ impl ProxyService {
// - the gateway will continue reading messages from the client ws
// (starting with the message that caused the hibernation to end)
let res = handler
.handle_websocket_hibernation(ws_handle.clone())
.handle_websocket_hibernation(
ws_handle.clone(),
request_id,
)
.await?;

after_hibernation = true;

// Despite receiving a close frame from the client during hibernation
// we are going to reconnect to the actor so that it knows the
// connection has closed
Expand Down
2 changes: 2 additions & 0 deletions engine/packages/guard-core/tests/custom_serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl CustomServeTrait for TestCustomServe {
_path: &str,
_request_context: &mut RequestContext,
_unique_request_id: Uuid,
_after_hibernation: bool,
) -> Result<Option<CloseFrame>> {
// Track this WebSocket call
self.tracker
Expand Down Expand Up @@ -115,6 +116,7 @@ impl CustomServeTrait for TestCustomServe {
async fn handle_websocket_hibernation(
&self,
_websocket: WebSocketHandle,
_unique_request_id: Uuid,
) -> Result<HibernationResult> {
// Track this WebSocket call
self.tracker
Expand Down
Loading
Loading