Skip to content

Make AddBitBrouterServices method idempotent (#12729)#12730

Merged
msynk merged 1 commit into
bitfoundation:developfrom
msynk:12729-brouter-addservice-idempotent
Jul 21, 2026
Merged

Make AddBitBrouterServices method idempotent (#12729)#12730
msynk merged 1 commit into
bitfoundation:developfrom
msynk:12729-brouter-addservice-idempotent

Conversation

@msynk

@msynk msynk commented Jul 20, 2026

Copy link
Copy Markdown
Member

closes #12729

Summary by CodeRabbit

  • Improvements
    • Service registration can now be safely called multiple times without creating duplicate registrations.
    • Existing custom IBrouter and BrouterService registrations are preserved.
    • Multiple configuration callbacks are supported, applied in call order, with later settings taking precedence.
    • Service lifetimes and null-argument validation remain unchanged.

@msynk
msynk requested a review from yasmoradi July 20, 2026 18:53
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 973702f6-df66-4bab-b2d9-813799077d1c

📥 Commits

Reviewing files that changed from the base of the PR and between c45ae26 and 08c76fd.

📒 Files selected for processing (2)
  • src/Brouter/Bit.Brouter/BitBrouter.cs
  • src/Brouter/Tests/Bit.Brouter.Tests/ServiceRegistrationTests.cs

Walkthrough

AddBitBrouterServices is now idempotent, preserves existing IBrouter registrations, and accumulates options configuration across calls. New tests verify repeated registration, scoped lifetimes, configuration ordering, and service preservation.

Changes

Brouter registration behavior

Layer / File(s) Summary
Idempotent registration and validation
src/Brouter/Bit.Brouter/BitBrouter.cs, src/Brouter/Tests/Bit.Brouter.Tests/ServiceRegistrationTests.cs
Repeated service registration no longer throws, TryAdd behavior preserves existing services, options callbacks apply in call order, and tests verify scoped lifetimes and registration outcomes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: yasmoradi

Poem

A rabbit hopped through DI’s bright hall,
Calling Brouter twice—no clash at all.
Options gathered, values aligned,
Existing services stayed assigned.
“Scoped and steady!” the bunny cried,
Then nibbled tests from side to side.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: making AddBitBrouterServices idempotent.
Linked Issues check ✅ Passed The changes implement and test idempotent service registration as requested in issue #12729.
Out of Scope Changes check ✅ Passed The added tests and documentation updates are directly tied to the idempotency fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@msynk
msynk merged commit c73166d into bitfoundation:develop Jul 21, 2026
3 checks passed
@msynk
msynk deleted the 12729-brouter-addservice-idempotent branch July 21, 2026 06:09
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.

The AddBitBrouterServices extension method is not idempotent

1 participant