Skip to content

Move FairnessConfig to fairness module and re-export#437

Merged
leynos merged 2 commits intomainfrom
refactor-fairnessconfig-location-pjw78u
Feb 3, 2026
Merged

Move FairnessConfig to fairness module and re-export#437
leynos merged 2 commits intomainfrom
refactor-fairnessconfig-location-pjw78u

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Feb 2, 2026

Summary

  • Move FairnessConfig from the connection module to the fairness module
  • Centralize the Default implementation in the fairness module
  • Preserve API compatibility by re-exporting FairnessConfig through the connection module

Changes

Core

  • Remove FairnessConfig struct and its Default impl from src/connection/mod.rs.
  • Add FairnessConfig struct and Default implementation to src/fairness.rs (in the fairness module).
  • Update imports in the fairness module to use tokio::time::Duration (as part of the struct).
  • Ensure src/connection/mod.rs re-exports FairnessConfig via pub use crate::fairness::FairnessConfig; so downstream code can still access it as crate::connection::FairnessConfig.

API/Usage

  • No breaking API changes for consumers; the type remains accessible as crate::connection::FairnessConfig, now defined in the fairness module.

Migration notes

  • None required beyond the relocation; the public path remains the same due to the re-export.

Test plan

  • Build succeeds with the relocated FairnessConfig.
  • crate::connection::FairnessConfig is still accessible from downstream code.
  • Default values are preserved: max_high_before_low = 8, time_slice = None.
  • No regressions in fairness-related behavior due to the relocation.

◳ Generated by DevBoxer


ℹ️ Tag @devboxerhub to ask questions and address PR feedback

📎 Task: https://www.devboxer.com/task/c7e7d12e-5368-4e4d-9ad2-0cbbc425a5a5

📝 Closes #429

Summary by Sourcery

Enhancements:

  • Centralize the FairnessConfig struct and its Default implementation in the fairness module, updating it to use tokio::time::Duration.

Resolve a layering violation where FairnessConfig was defined in the
connection module but consumed by the lower-level fairness module.
The configuration type now lives in src/fairness.rs where it logically
belongs, with a pub use re-export from src/connection/mod.rs preserving
the existing public API surface.

Closes #429

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Feb 2, 2026

Reviewer's Guide

Relocates FairnessConfig and its Default implementation from the connection module into the fairness module, updating fairness to depend directly on tokio::time::Duration while preserving the public API via a re-export from the connection module.

Class diagram for relocated FairnessConfig in fairness module

classDiagram
    class FairnessConfig {
        +usize max_high_before_low
        +Option_Duration_ time_slice
        +FairnessConfig default()
    }
Loading

File-Level Changes

Change Details Files
Move FairnessConfig definition and Default implementation from the connection module into the fairness module and update fairness to import Duration directly.
  • Add FairnessConfig struct and its Default implementation to the fairness module alongside the existing fairness logic.
  • Update fairness module imports to use tokio::time::{Duration, Instant} instead of only Instant.
  • Remove the FairnessConfig struct and its Default implementation from the connection module to avoid duplication.
src/fairness.rs
src/connection/mod.rs
Preserve API compatibility for downstream users by re-exporting FairnessConfig from the connection module.
  • Ensure FairnessConfig remains accessible under the crate::connection namespace through a pub use of the fairness module’s FairnessConfig.
  • Confirm that existing Default values (max_high_before_low = 8, time_slice = None) and behavior are unchanged despite the relocation.
src/connection/mod.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#429 Define FairnessConfig (including its Default implementation) in the fairness module instead of the connection module, so that the fairness logic owns its configuration.
#429 Re-export FairnessConfig from the connection module (e.g., pub use crate::fairness::FairnessConfig;) so that the public API crate::connection::FairnessConfig remains available and non-breaking.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 2, 2026

Summary by CodeRabbit

  • Refactor
    • Fairness configuration has been consolidated into the fairness module and is now exposed from the connection area via a public re-export. Default configuration values and behaviour remain unchanged, preserving existing fairness tracking semantics while simplifying code organisation.

Walkthrough

Move the FairnessConfig definition from src/connection/mod.rs into src/fairness.rs and re-export it from the connection module to preserve the public API surface.

Changes

Cohort / File(s) Summary
Connection re-export
src/connection/mod.rs
Remove local FairnessConfig struct and its Default impl; add pub use crate::fairness::FairnessConfig.
Fairness module authoritative config
src/fairness.rs
Add public FairnessConfig with max_high_before_low: usize and time_slice: Option<Duration>; provide impl Default returning { max_high_before_low: 8, time_slice: None }; update imports to include tokio::time::Duration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

From connection's lofty ledge it flew,
To fairness where the rules accrue,
Re-export the map, keep surface neat,
Layers tidy, no defeat 🌿✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately and concisely summarises the main change: moving FairnessConfig to the fairness module and re-exporting it from the connection module.
Description check ✅ Passed The pull request description provides clear and comprehensive details directly aligned with the changeset, including the summary, core changes, API compatibility considerations, and test plan.
Linked Issues check ✅ Passed The code changes fully satisfy the primary objectives outlined in issue #429: moving FairnessConfig to src/fairness.rs and maintaining the public API through re-export from the connection module.
Out of Scope Changes check ✅ Passed All changes directly address the layering restructuring objective. The addition of PartialEq and Eq derives mentioned in commit messages aligns with typical test/consumer requirements for the relocated struct.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-fairnessconfig-location-pjw78u

Comment @coderabbitai help to get the list of available commands and usage tips.

@leynos leynos marked this pull request as ready for review February 2, 2026 13:47
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/fairness.rs`:
- Around line 10-23: The FairnessConfig struct lacks equality derivations,
making comparisons in tests and consumers harder; update the struct declaration
for FairnessConfig to also derive PartialEq and Eq (in addition to Clone, Copy,
Debug) so that FairnessConfig (and its fields max_high_before_low and
time_slice) can be compared for equality.

Comment thread src/fairness.rs
Add equality derivations to FairnessConfig to enable comparisons in
tests and consumers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@leynos leynos merged commit 36c2e64 into main Feb 3, 2026
6 checks passed
@leynos leynos deleted the refactor-fairnessconfig-location-pjw78u branch February 3, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Untangle layering: move FairnessConfig from connection to fairness module

1 participant