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
3 changes: 2 additions & 1 deletion .github/workflows/mirror-swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ name: Mirror rivetkit-swift
on:
push:
branches:
- "**"
- main
tags:
- "**"

jobs:
mirror:
if: github.repository == 'rivet-dev/actors'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
cache-shared-key: rust-ci
cache-on-failure: true

- name: Set up repository-specific Rust dependencies
if: ${{ hashFiles('scripts/ci/pre-rust-check.sh') != '' }}
run: scripts/ci/pre-rust-check.sh

- name: Check event-driven drain invariants
run: rivetkit-rust/packages/rivetkit-core/scripts/check-event-driven-drains.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ fn embedded_bundle_serves_index_when_required() {
!text.contains("ui_asset_not_found"),
"embedded inspector bundle is empty: GET /inspector/ui/ served ui_asset_not_found",
);
assert_eq!(resp.status, 200, "expected 200 for index.html, got {}", resp.status);
assert_eq!(
resp.status, 200,
"expected 200 for index.html, got {}",
resp.status
);

let lower = text.to_ascii_lowercase();
assert!(
Expand Down
5 changes: 2 additions & 3 deletions rivetkit-rust/packages/rivetkit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ pub use rivetkit_core::{
HTTP_BODY_STREAM_CHANNEL_CAPACITY, KeepAwakeRegion, ListOpts, QueueMessage as CoreQueueMessage,
QueueNextBatchOpts, QueueNextOpts, QueueTryNextBatchOpts, QueueTryNextOpts, QueueWaitOpts,
Request, RequestSaveOpts, Response, ResponseChunk, RuntimeMode, SaveStateOpts,
SerializeStateReason,
ServeConfig, SqliteBatchStatement, SqliteDb, SqliteTransaction, StateDelta, StreamingResponse,
WebSocket, WsMessage,
SerializeStateReason, ServeConfig, SqliteBatchStatement, SqliteDb, SqliteTransaction,
StateDelta, StreamingResponse, WebSocket, WsMessage,
sqlite::{BindParam, ColumnValue, ExecResult, QueryResult},
};
27 changes: 15 additions & 12 deletions rivetkit-rust/packages/rivetkit/src/serverless_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ use std::io;
use std::net::{Ipv4Addr, SocketAddr};

use anyhow::{Context, Result};
use axum::Router;
use axum::body::{Body, to_bytes};
use axum::extract::{Request, State};
use axum::response::Response;
use axum::Router;
use bytes::Bytes;
use futures::StreamExt;
use http::StatusCode;
use rivetkit_core::serverless::{
CoreServerlessRuntime, ServerlessRequest, ServerlessResponse,
};
use rivetkit_core::serverless::{CoreServerlessRuntime, ServerlessRequest, ServerlessResponse};
use tokio_stream::wrappers::UnboundedReceiverStream;
use tokio_util::sync::CancellationToken;

Expand Down Expand Up @@ -125,7 +123,10 @@ fn into_response_with_guard(
/// Builds an axum response that streams the runtime's response chunks. `guard`,
/// when present, is held for the lifetime of the stream so dropping the body
/// cancels the in-flight request.
fn build_response(response: ServerlessResponse, guard: Option<tokio_util::sync::DropGuard>) -> Response {
fn build_response(
response: ServerlessResponse,
guard: Option<tokio_util::sync::DropGuard>,
) -> Response {
let ServerlessResponse {
status,
headers,
Expand All @@ -145,11 +146,13 @@ fn build_response(response: ServerlessResponse, guard: Option<tokio_util::sync::
builder = builder.header(name, value);
}

builder.body(Body::from_stream(stream)).unwrap_or_else(|error| {
tracing::error!(?error, "failed to build serverless response");
Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
.expect("static error response is valid")
})
builder
.body(Body::from_stream(stream))
.unwrap_or_else(|error| {
tracing::error!(?error, "failed to build serverless response");
Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
.expect("static error response is valid")
})
}
Loading