Skip to content
Closed
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
17 changes: 17 additions & 0 deletions engine/packages/gasoline/src/ctx/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ impl StandaloneCtx {
})
}

#[tracing::instrument(skip_all)]
pub fn with_ray(&self, ray_id: Id, req_id: Id) -> WorkflowResult<Self> {
let mut ctx = StandaloneCtx::new(
self.db.clone(),
self.config.clone(),
self.pools.clone(),
self.cache.clone(),
&self.name,
ray_id,
req_id,
)?;

ctx.from_workflow = self.from_workflow;

Ok(ctx)
}

#[tracing::instrument(skip_all)]
pub fn new_from_activity(ctx: &ActivityCtx, req_id: Id) -> WorkflowResult<Self> {
let mut ctx = StandaloneCtx::new(
Expand Down
14 changes: 9 additions & 5 deletions engine/packages/guard-core/src/custom_serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use bytes::Bytes;
use http_body_util::Full;
use hyper::{Request, Response};
use rivet_runner_protocol as protocol;
use rivet_util::Id;
use tokio_tungstenite::tungstenite::protocol::frame::CloseFrame;

use crate::WebSocketHandle;
use crate::proxy_service::ResponseBody;
use crate::request_context::RequestContext;

pub enum HibernationResult {
Continue,
Expand All @@ -22,7 +22,8 @@ pub trait CustomServeTrait: Send + Sync {
async fn handle_request(
&self,
req: Request<Full<Bytes>>,
request_context: &mut RequestContext,
ray_id: Id,
req_id: Id,
request_id: protocol::RequestId,
) -> Result<Response<ResponseBody>>;

Expand All @@ -32,9 +33,10 @@ pub trait CustomServeTrait: Send + Sync {
_websocket: WebSocketHandle,
_headers: &hyper::HeaderMap,
_path: &str,
_request_context: &mut RequestContext,
_ray_id: Id,
_req_id: Id,
// Identifies the websocket across retries.
_unique_request_id: protocol::RequestId,
_request_id: protocol::RequestId,
// True if this websocket is reconnecting after hibernation.
_after_hibernation: bool,
) -> Result<Option<CloseFrame>> {
Expand All @@ -45,7 +47,9 @@ pub trait CustomServeTrait: Send + Sync {
async fn handle_websocket_hibernation(
&self,
_websocket: WebSocketHandle,
_unique_request_id: protocol::RequestId,
_ray_id: Id,
_req_id: Id,
_request_id: protocol::RequestId,
) -> Result<HibernationResult> {
bail!("service does not support websocket hibernation");
}
Expand Down
4 changes: 1 addition & 3 deletions engine/packages/guard-core/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use rivet_error::*;
use rivet_util::Id;
use serde::{Deserialize, Serialize};

#[derive(RivetError, Serialize, Deserialize)]
#[error(
"guard",
"rate_limit",
"Too many requests. Try again later.",
"Too many requests to '{method} {path}' (actor_id: {actor_id:?}) from IP {ip}."
"Too many requests to '{method} {path}' from IP {ip}."
)]
pub struct RateLimit {
pub actor_id: Option<Id>,
pub method: String,
pub path: String,
pub ip: String,
Expand Down
1 change: 0 additions & 1 deletion engine/packages/guard-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub mod custom_serve;
pub mod errors;
pub mod metrics;
pub mod proxy_service;
pub mod request_context;
mod server;
mod task_group;
pub mod types;
Expand Down
Loading
Loading