Skip to content
Closed
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
31 changes: 29 additions & 2 deletions packages/core/pegboard-serverless/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ use universaldb::utils::IsolationLevel::*;
use vbare::OwnedVersionedData;

const X_RIVET_TOKEN: HeaderName = HeaderName::from_static("x-rivet-token");
const X_RIVETKIT_TOTAL_SLOTS: HeaderName = HeaderName::from_static("x-rivetkit-total-slots");
const X_RIVET_TOTAL_SLOTS: HeaderName = HeaderName::from_static("x-rivet-total-slots");
const X_RIVET_RUNNER_NAME: HeaderName = HeaderName::from_static("x-rivet-runner-name");
const X_RIVET_NAMESPACE_ID: HeaderName = HeaderName::from_static("x-rivet-namespace-id");

struct OutboundConnection {
handle: JoinHandle<()>,
Expand Down Expand Up @@ -107,6 +109,15 @@ async fn tick(
.find(|rc| rc.namespace_id == *ns_id)
.context("runner config not found")?;

let namespace = ctx
.op(namespace::ops::get_global::Input {
namespace_ids: vec![ns_id.clone()],
})
.await
.context("runner namespace not found")?;
let namespace = namespace.first().context("runner namespace not found")?;
let namespace_name = &namespace.name;

let RunnerConfig::Serverless {
url,
headers,
Expand Down Expand Up @@ -160,6 +171,8 @@ async fn tick(
headers.clone(),
Duration::from_secs(*request_lifespan as u64),
*slots_per_runner,
runner_name.clone(),
namespace_name.clone(),
Comment on lines +174 to +175
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be a parameter name/value mismatch in this function call. The function signature expects a parameter named namespace_id_string, but you're passing namespace_name.clone().

For consistency, either:

  1. Change the parameter name in the function signature from namespace_id_string to namespace_name, or
  2. Pass the namespace ID as a string instead of the namespace name: ns_id.to_string()

This will ensure the parameter name accurately reflects the data being passed.

Suggested change
runner_name.clone(),
namespace_name.clone(),
runner_name.clone(),
ns_id.to_string(),

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

)
})
.take(start_count);
Expand All @@ -186,6 +199,8 @@ fn spawn_connection(
headers: HashMap<String, String>,
request_lifespan: Duration,
slots_per_runner: u32,
runner_name: String,
namespace_name: String,
) -> OutboundConnection {
let (shutdown_tx, shutdown_rx) = oneshot::channel::<()>();
let draining = Arc::new(AtomicBool::new(false));
Expand All @@ -198,6 +213,8 @@ fn spawn_connection(
headers,
request_lifespan,
slots_per_runner,
runner_name,
namespace_name,
shutdown_rx,
draining2,
)
Expand Down Expand Up @@ -229,6 +246,8 @@ async fn outbound_handler(
headers: HashMap<String, String>,
request_lifespan: Duration,
slots_per_runner: u32,
runner_name: String,
namespace_name: String,
shutdown_rx: oneshot::Receiver<()>,
draining: Arc<AtomicBool>,
) -> Result<()> {
Expand All @@ -243,9 +262,17 @@ async fn outbound_handler(
))
})
.chain(std::iter::once((
X_RIVETKIT_TOTAL_SLOTS,
X_RIVET_TOTAL_SLOTS,
HeaderValue::try_from(slots_per_runner)?,
)))
.chain(std::iter::once((
X_RIVET_RUNNER_NAME,
HeaderValue::try_from(runner_name)?,
)))
.chain(std::iter::once((
X_RIVET_NAMESPACE_ID,
HeaderValue::try_from(namespace_name)?,
)))
// Add token if auth is enabled
.chain(
ctx.config()
Expand Down
Loading