Skip to content

Refactor mocha middleware to use unified Use method with optional positioning parameters#9419

Merged
PascalSenn merged 2 commits intomainfrom
pse/align-mocha-middlewares-with-hc
Mar 23, 2026
Merged

Refactor mocha middleware to use unified Use method with optional positioning parameters#9419
PascalSenn merged 2 commits intomainfrom
pse/align-mocha-middlewares-with-hc

Conversation

@PascalSenn
Copy link
Copy Markdown
Member

@PascalSenn PascalSenn commented Mar 23, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 23, 2026 00:52
@github-actions github-actions Bot added the 📚 documentation This issue is about working on our documentation. label Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors Mocha (message bus + transports + mediator) middleware registration APIs to use a unified Use* method with optional before / after positioning, and updates docs + tests to reflect the new API surface.

Changes:

  • Replace Append* / Prepend* middleware registration APIs with Use*(..., before:/after:) across bus, transport, and endpoint descriptors.
  • Update Mocha.Mediator builder/host-builder middleware positioning to use Use(..., before:/after:).
  • Update docs and tests to use the new unified API.

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
website/src/docs/mocha/v1/transports/index.md Updates transport middleware ordering examples to UseReceive/UseDispatch with before/after.
website/src/docs/mocha/v1/reliability.md Updates consumer middleware positioning example to UseConsume(..., before: "Inbox").
website/src/docs/mocha/v1/middleware-and-pipelines.md Rewrites ordering docs to describe the unified Use* API and positioning rules.
website/src/docs/mocha/v1/mediator/pipeline-and-middleware.md Updates mediator middleware positioning docs and examples to Use(..., before:/after:).
src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/Behaviors/TransportMiddlewareTests.cs Renames/updates transport-level middleware ordering tests to the new Use* API.
src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/Behaviors/InboxTests.cs Updates inbox-related tests to use UseDispatch/UseConsume with before.
src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/Behaviors/EndpointMiddlewareTests.cs Updates endpoint-scoped middleware ordering tests to the new Use* API.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/TransportMiddlewareTests.cs Renames/updates transport-level middleware ordering tests to the new Use* API.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/EndpointMiddlewareTests.cs Updates endpoint-scoped middleware ordering tests to the new Use* API.
src/Mocha/test/Mocha.Transport.InMemory.Tests/Behaviors/InboxTests.cs Updates in-memory inbox tests to use UseDispatch/UseConsume with before.
src/Mocha/test/Mocha.Tests/Outbox/OutboxIntegrationTests.cs Updates outbox integration test middleware positioning to UseDispatch(..., before: "Outbox").
src/Mocha/test/Mocha.Tests/Inbox/InboxIntegrationTests.cs Updates inbox integration test middleware positioning to UseConsume(..., before: "Inbox").
src/Mocha/src/Mocha/Transport/MessagingTransportDescriptor.cs Consolidates transport middleware APIs into UseDispatch/UseReceive with optional before/after.
src/Mocha/src/Mocha/Endpoints/Descriptors/ReceiveEndpointDescriptor.cs Consolidates endpoint receive middleware APIs into UseReceive with optional before/after.
src/Mocha/src/Mocha/Endpoints/Descriptors/IReceiveEndpointDescriptor.cs Updates endpoint receive middleware interface to the unified UseReceive signature.
src/Mocha/src/Mocha/Endpoints/Descriptors/IDispatchEndpointDescriptor.cs Updates endpoint dispatch middleware interface to the unified UseDispatch signature.
src/Mocha/src/Mocha/Endpoints/Descriptors/DispatchEndpointDescriptor.cs Consolidates endpoint dispatch middleware APIs into UseDispatch with optional before/after.
src/Mocha/src/Mocha/Consumers/Descriptors/IConsumerDescriptor.cs Consolidates consumer middleware APIs into UseConsumer with optional before/after.
src/Mocha/src/Mocha/Consumers/Descriptors/ConsumerDescriptor.cs Implements unified UseConsumer behavior with positional insertion rules.
src/Mocha/src/Mocha/Builder/MessageBusBuilder.Middlewares.cs Consolidates bus-level middleware registration into unified UseConsume/UseReceive/UseDispatch.
src/Mocha/src/Mocha/Abstractions/IMessageBusBuilder.cs Replaces append/prepend methods with unified Use* signatures at the public abstraction level.
src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/Extensions/RabbitMQTransportDescriptorExtensions.cs Updates RabbitMQ default middleware registration to use UseReceive(..., after: ...).
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/RabbitMQReceiveEndpointDescriptor.cs Updates RabbitMQ receive endpoint descriptor to forward unified UseReceive.
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/RabbitMQMessagingTransportDescriptor.cs Updates RabbitMQ transport descriptor to forward unified UseDispatch/UseReceive.
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/RabbitMQDispatchEndpointDescriptor.cs Updates RabbitMQ dispatch endpoint descriptor to forward unified UseDispatch.
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/IRabbitMQReceiveEndpointDescriptor.cs Updates RabbitMQ receive endpoint interface to unified UseReceive signature.
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/IRabbitMQMessagingTransportDescriptor.cs Updates RabbitMQ transport interface to unified UseDispatch/UseReceive signatures.
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/IRabbitMQDispatchEndpointDescriptor.cs Updates RabbitMQ dispatch endpoint interface to unified UseDispatch signature.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Extensions/PostgresTransportDescriptorExtensions.cs Updates Postgres default middleware registration to use UseReceive(..., after: ...).
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/PostgresReceiveEndpointDescriptor.cs Updates Postgres receive endpoint descriptor to forward unified UseReceive.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/PostgresMessagingTransportDescriptor.cs Updates Postgres transport descriptor to forward unified UseDispatch/UseReceive.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/PostgresDispatchEndpointDescriptor.cs Updates Postgres dispatch endpoint descriptor to forward unified UseDispatch.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/IPostgresReceiveEndpointDescriptor.cs Updates Postgres receive endpoint interface to unified UseReceive signature.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/IPostgresMessagingTransportDescriptor.cs Updates Postgres transport interface to unified UseDispatch/UseReceive signatures.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/IPostgresDispatchEndpointDescriptor.cs Updates Postgres dispatch endpoint interface to unified UseDispatch signature.
src/Mocha/src/Mocha.Transport.InMemory/Descriptors/InMemoryReceiveEndpointDescriptor.cs Updates in-memory receive endpoint descriptor to forward unified UseReceive.
src/Mocha/src/Mocha.Transport.InMemory/Descriptors/InMemoryMessagingTransportDescriptor.cs Updates in-memory transport descriptor to forward unified UseDispatch/UseReceive.
src/Mocha/src/Mocha.Transport.InMemory/Descriptors/InMemoryDispatchEndpointDescriptor.cs Updates in-memory dispatch endpoint descriptor to forward unified UseDispatch.
src/Mocha/src/Mocha.Transport.InMemory/Descriptors/IInMemoryReceiveEndpointDescriptor.cs Updates in-memory receive endpoint interface to unified UseReceive signature.
src/Mocha/src/Mocha.Transport.InMemory/Descriptors/IInMemoryMessagingTransportDescriptor.cs Updates in-memory transport interface to unified UseDispatch/UseReceive signatures.
src/Mocha/src/Mocha.Transport.InMemory/Descriptors/IInMemoryDispatchEndpointDescriptor.cs Updates in-memory dispatch endpoint interface to unified UseDispatch signature.
src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorHostBuilderExtensions.cs Collapses mediator host-builder middleware methods into Use(..., before:/after:).
src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorBuilder.cs Implements Use(..., before:/after:) and changes missing-key behavior to throw.
src/Mocha/src/Mocha.Mediator/DependencyInjection/IMediatorBuilder.cs Updates mediator builder interface to unified Use signature with before/after.
src/Mocha/src/Mocha.Inbox/InboxCoreServiceCollectionExtensions.cs Changes inbox core middleware registration from append-style to UseConsume.
src/Mocha/src/Examples/Middleware/CustomMiddleware/CustomMiddleware.cs Updates example to the new middleware registration API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Mocha/src/Mocha.Inbox/InboxCoreServiceCollectionExtensions.cs
Comment thread src/Mocha/src/Mocha/Abstractions/IMessageBusBuilder.cs
Copy link
Copy Markdown
Member Author

@PascalSenn PascalSenn left a comment

Choose a reason for hiding this comment

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

LGTM

@PascalSenn PascalSenn merged commit ff9cb02 into main Mar 23, 2026
127 checks passed
@PascalSenn PascalSenn deleted the pse/align-mocha-middlewares-with-hc branch March 23, 2026 01:47
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (6a3b7a3) to head (3ec7b78).
⚠️ Report is 1000 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #9419       +/-   ##
==========================================
- Coverage   74.16%       0   -74.17%     
==========================================
  Files        2677       0     -2677     
  Lines      140790       0   -140790     
  Branches    16371       0    -16371     
==========================================
- Hits       104421       0   -104421     
+ Misses      30774       0    -30774     
+ Partials     5595       0     -5595     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants