Skip to content

event_processing_permits is an identity pass-through with #[must_use], a doc block, and two tests — a dead abstraction that reads as if it enforces an invariant it does not #326

Description

@erskingardner

Summary

event_processing_permits returns its argument unchanged, yet carries #[must_use], a doc block implying it "preserves the operator's configured cap," and two dedicated tests. It applies no clamping, flooring, or transformation, so it reads as if it enforces an invariant it does not — a refactor/clarity opportunity.

Location

src/app.rs:89-92 (definition), called at src/app.rs:624. Tests at src/app.rs:965 and src/app.rs:973.

#[must_use]
fn event_processing_permits(max_concurrent_event_processing: usize) -> usize {
    max_concurrent_event_processing
}

Root cause

Load-time validation already rejects max_concurrent_event_processing == 0 (and enforces the upper bound MAX_CONCURRENT_EVENT_PROCESSING), so by the time this helper runs the value is already valid. The function neither clamps nor derives anything — it's a pass-through that adds indirection and reads as meaningful validation.

Suggested fix

Inline Semaphore::new(config.server.max_concurrent_event_processing) at the call site and drop the wrapper plus its two tests — or, if a floor is ever intended, make the helper actually clamp so its name is true.

Why this is not a duplicate

No filed issue references this helper. #179 / #247 concern the config-time validation of max_concurrent_event_processing, not this pass-through wrapper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions