feat(core): add UsageLimiter::acquire_concurrency_only (PSA-42) #11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/psa-42-acquire-concurrency-only"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
UsageLimiter::acquireatomically bumps the in-process concurrency map AND the durable daily counter; there was no way to take a concurrency slot without counting toward the daily cap. bunyip BUNYIP-43 needs to meter only logical pulls (tag-addressed manifest requests) while still concurrency-bounding the digest-addressed follow-up fetches. Because the only API coupled both, bunyip gated the wholeacquirebehind "is this a tag request", so digest-addressed manifest fetches took no concurrency slot at all - and a multi-archdocker pull(one tag request, then N by-digest platform-manifest fetches) left those N unbounded, defeatingconcurrent_manifests_per_userfor the request type a multi-arch pull emits most of.Change
Add
acquire_concurrency_only(user_id) -> Result<UsageGuard, LimitDenial>:AppError. The only denial isLimitDenial::Concurrency.acquire, so a consumer can hold a slot for every request but count daily only for the ones representing a logical operation.The coupled
acquireis unchanged (additive API). Both now take the slot through a sharedtry_take_concurrency_slothelper;acquire's rollback paths release via guard drop, preserving the existing "release the slot before any store call" ordering.Acceptance criteria
acquirecallers are unaffected (additive; signature unchanged).Tests
acquire_concurrency_only_does_not_count_daily: 10 concurrency-only acquisitions leave the daily counter at 0 and never hit the cap; a later coupledacquirestill succeeds.acquire_concurrency_only_enforces_concurrency: per-user cap enforced; slot freed on drop.concurrency_only_slot_shares_budget_with_coupled_acquire: a held concurrency-only slot makes a coupledacquirefor the same user returnConcurrency, without counting daily.fmt + clippy -D warnings clean; full
cargo test --workspacegreen. The method is inherited by the vertical re-exports (OciLimiter,DownloadLimiter) automatically.Follow-up (separate)
bunyip switches its digest-addressed manifest fetches to
acquire_concurrency_only; depends on a dunite-core release + bunyip dep bump.#PSA-42