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
6 changes: 3 additions & 3 deletions pkgs/fleet/crates/fleet-queue/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,12 @@ mod tests {
assert_eq!(batch_count_flag(Some(1)), Ok(1));
assert_eq!(batch_count_flag(Some(2)), Ok(2));
assert_eq!(
batch_count_flag(Some(crate::turso_queue::BATCH_CLAIM_MAX)),
Ok(crate::turso_queue::BATCH_CLAIM_MAX)
batch_count_flag(Some(crate::BATCH_CLAIM_MAX)),
Ok(crate::BATCH_CLAIM_MAX)
);
assert!(batch_count_flag(Some(0)).is_err());
assert!(batch_count_flag(Some(-3)).is_err());
assert!(batch_count_flag(Some(crate::turso_queue::BATCH_CLAIM_MAX + 1)).is_err());
assert!(batch_count_flag(Some(crate::BATCH_CLAIM_MAX + 1)).is_err());
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ pub(super) fn batch_count_flag(n: Option<i64>) -> Result<i64, String> {
match n {
None => Ok(1),
Some(n) if n == 1 => Ok(1),
Some(n) if (2..=crate::turso_queue::BATCH_CLAIM_MAX).contains(&n) => Ok(n),
Some(n) if (2..=crate::BATCH_CLAIM_MAX).contains(&n) => Ok(n),
Some(n) => Err(format!(
"claim --count {n} is out of range: a batch claim takes \
1..={} items (#8217)",
crate::turso_queue::BATCH_CLAIM_MAX
crate::BATCH_CLAIM_MAX
)),
}
}
Expand Down
22 changes: 21 additions & 1 deletion pkgs/fleet/crates/fleet-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@
//! binaries under their historical names (src/bin/) — the
//! migration's standing rollback inventory (design note §7).

/// The most tasks one batch claim may take (#8217). A batch is
/// only legitimate paired with immediate per-item dispatch, and
/// the dispatcher must launch + verify-bind every item inside one
/// touch before leases age: five dedicated launches fit that
/// window with margin, and a bigger batch would recreate the
/// claimed-and-idle pile the single-session design forbids.
///
/// The bound lives at the crate root because both surfaces share
/// it: the client validates `--count` locally so a bad value
/// fails instantly, and the broker enforces the same bound on
/// the wire request (`turso_queue` re-exports it from here).
/// Before #13078 the definition sat inside the broker-gated
/// `turso_queue` tree, so a client-only build could not compile.
pub const BATCH_CLAIM_MAX: i64 = 5;

pub mod backoff;
pub mod bin_args;
pub mod creation_outbox;
Expand Down Expand Up @@ -48,5 +63,10 @@ pub mod secrets_broker;
pub mod turso_queue;
#[cfg(any(feature = "queue-broker", feature = "secrets-broker"))]
pub mod uds_http;
#[cfg(feature = "queue-broker")]
// The validation library is shared by both surfaces: the broker
// validates whole packets, and the client validates individual
// flag values (e.g. `--not-before`) against the same rules, so
// the module compiles for either surface (#13078). It depends
// only on serde_json, never on a broker-only dependency.
#[cfg(any(feature = "client", feature = "queue-broker"))]
pub mod validate;
12 changes: 5 additions & 7 deletions pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,11 @@ pub(crate) fn claim_pick_once(
/// the quarantine rechecker's releases.
pub const MAX_CLAIM_QUARANTINES_PER_CALL: usize = 512;

/// The most tasks one batch claim may take (#8217). A batch is
/// only legitimate paired with immediate per-item dispatch, and
/// the dispatcher must launch + verify-bind every item inside one
/// touch before leases age: five dedicated launches fit that
/// window with margin, and a bigger batch would recreate the
/// claimed-and-idle pile the single-session design forbids.
pub const BATCH_CLAIM_MAX: i64 = 5;
/// The batch-claim bound (#8217) is defined at the crate root so
/// the client surface validates `--count` against the same value
/// the broker enforces here; re-exported so this module's parse
/// path and the `turso_queue::BATCH_CLAIM_MAX` path keep working.
pub use crate::BATCH_CLAIM_MAX;

/// Parse a claim request's batch count (#8217): absent means the
/// single claim (1); anything outside 1..=BATCH_CLAIM_MAX is a
Expand Down