Skip to content

Adds PostgreSQL transport to Mocha#9383

Merged
PascalSenn merged 12 commits intomainfrom
pse/adds-postgres-transport-to-mocha
Mar 20, 2026
Merged

Adds PostgreSQL transport to Mocha#9383
PascalSenn merged 12 commits intomainfrom
pse/adds-postgres-transport-to-mocha

Conversation

@PascalSenn
Copy link
Copy Markdown
Member

@PascalSenn PascalSenn commented Mar 17, 2026

No description provided.

@github-actions github-actions Bot added 📚 documentation This issue is about working on our documentation. 🌶️ website labels Mar 17, 2026
@PascalSenn PascalSenn changed the title Add PostgreSQL transport support with comprehensive tests and documentation Add PostgreSQL transport to Mocha Mar 17, 2026
@PascalSenn PascalSenn marked this pull request as ready for review March 17, 2026 20:41
Copilot AI review requested due to automatic review settings March 17, 2026 20:41
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

Adds a new PostgreSQL-based transport implementation for Mocha (including schema/migrations, topology resources, middleware, and background tasks) plus a comprehensive test suite, while also adjusting core receive-endpoint concurrency configuration and a few RabbitMQ internals.

Changes:

  • Introduces Mocha.Transport.Postgres transport (topology, descriptors, conventions, schema migrator, background tasks, envelope parsing, etc.).
  • Adds Mocha.Transport.Postgres.Tests with integration tests (using Squadron PostgreSQL) covering topology, send/publish, request/reply, batching, concurrency, headers, fault/error-queue behavior.
  • Updates shared endpoint configuration (MaxConcurrency now nullable + new Defaults) and aligns some RabbitMQ code with the new semantics; updates docs nav.

Reviewed changes

Copilot reviewed 123 out of 123 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
website/src/docs/docs.json Adds PostgreSQL docs entry to website navigation.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Topology/PostgresTopicTests.cs Unit tests for Postgres topic topology resource behavior.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Topology/PostgresSubscriptionTests.cs Unit tests for Postgres subscription topology resource behavior.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Topology/PostgresQueueTests.cs Unit tests for Postgres queue topology resource behavior.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Topology/PostgresMessageTypeExtensionTests.cs Tests for outbound route URI helpers for Postgres queue/topic.
src/Mocha/test/Mocha.Transport.Postgres.Tests/PostgresTransportConfigurationTests.cs Tests for transport configuration defaults/setters.
src/Mocha/test/Mocha.Transport.Postgres.Tests/PostgresReceiveEndpointTests.cs Tests receive endpoint resolution and addressing.
src/Mocha/test/Mocha.Transport.Postgres.Tests/PostgresDispatchEndpointTests.cs Tests dispatch endpoint destination resolution/addressing.
src/Mocha/test/Mocha.Transport.Postgres.Tests/PostgresDelayedTriggerTests.cs Tests delayed trigger scheduling/disposal behavior.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Mocha.Transport.Postgres.Tests.csproj Adds new test project and dependencies (Squadron.PostgreSql, project refs).
src/Mocha/test/Mocha.Transport.Postgres.Tests/Helpers/TestBus.cs Adds helper to build/start/stop runtime for integration tests.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Helpers/PostgresFixture.cs Adds Squadron-based PostgreSQL fixture and per-test database creation.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Helpers/PostgresBusFixture.cs Adds helpers for building Postgres topology/runtime in tests.
src/Mocha/test/Mocha.Transport.Postgres.Tests/ErrorInfoTests.cs Tests serialization and capture semantics for ErrorInfo.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Descriptors/PostgresTopologyDescriptorTests.cs Tests descriptor APIs for declaring topology and endpoints.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Descriptors/PostgresHandlerBindingTests.cs Tests implicit vs explicit handler binding behavior for Postgres transport.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Descriptors/PostgresDescriptorTests.cs Tests core transport descriptor behaviors (schema/name/routes/endpoints).
src/Mocha/test/Mocha.Transport.Postgres.Tests/Conventions/PostgresDefaultConventionTests.cs Tests default endpoint conventions (error/skipped endpoints behavior).
src/Mocha/test/Mocha.Transport.Postgres.Tests/Connection/PostgresConnectionManagerTests.cs Integration tests for connection manager and migrations.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/SendTests.cs Integration tests for send behavior (routing, keyed DI).
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/RequestReplyTests.cs Integration tests for request/reply and correlation.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/PublishSubscribeTests.cs Integration tests for publish/subscribe fanout and throughput.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/FaultHandlingTests.cs Integration tests for remote error propagation and handler isolation.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/ExplicitTopologyTests.cs Integration tests for explicit topology declarations.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/ErrorQueueTests.cs Integration tests for fault routing to error queues and header preservation.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/CustomHeaderTests.cs Integration tests for custom header propagation.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/ConsumerLifecycleTests.cs Integration tests for consumer registration/heartbeat/cleanup behaviors.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/ConnectionHealthTests.cs Integration tests for health checks and migration idempotence.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/ConcurrencyTests.cs Integration tests for endpoint-level concurrency control.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/ConcurrencyLimiterTests.cs Integration tests for global concurrency limiter feature with Postgres.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/BusDefaultsIntegrationTests.cs Integration tests for transport defaults application and overrides.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/BatchingTests.cs Integration tests for batching (size/time triggers, concurrent fill).
src/Mocha/src/Mocha/Utils/Buffers/PooledBufferAllocator.cs Adds pooled bump allocator used for packing message batch buffers.
src/Mocha/src/Mocha/Endpoints/Configurations/ReceiveEndpointConfiguration.cs Makes MaxConcurrency nullable and introduces global default container.
src/Mocha/src/Mocha/Assembly.cs Grants internals visibility to Postgres transport assembly.
src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/RabbitMQExchange.cs Marks exchange as an IRabbitMQResource.
src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/Extensions/RabbitMQTransportDescriptorExtensions.cs Fixes convention type name used in defaults registration.
src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/Configurations/RabbitMQExchangeConfiguration.cs Makes exchange config generic over RabbitMQMessagingTopology.
src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQReceiveEndpoint.cs Updates MaxConcurrency handling for nullable config.
src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQMessagingTransport.cs Stabilizes Describe() transport type name via nameof.
src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQDispatchEndpoint.cs Minor formatting/comment adjustments in URI parsing logic.
src/Mocha/src/Mocha.Transport.RabbitMQ/Conventions/RabbitMQDefaultReceiveEndpointConvention.cs Renames convention class and keeps default endpoint behaviors.
src/Mocha/src/Mocha.Transport.Postgres/Topology/PostgresTopic.cs Adds Postgres topic topology resource + provisioning logic.
src/Mocha/src/Mocha.Transport.Postgres/Topology/PostgresSubscription.cs Adds Postgres subscription topology resource + provisioning logic.
src/Mocha/src/Mocha.Transport.Postgres/Topology/PostgresQueue.cs Adds Postgres queue topology resource + provisioning logic (incl auto-delete/consumer link).
src/Mocha/src/Mocha.Transport.Postgres/Topology/PostgresMessagingTopology.cs Adds topology manager for topics/queues/subscriptions with thread-safety.
src/Mocha/src/Mocha.Transport.Postgres/Topology/IPostgresResource.cs Introduces provisioning interface for Postgres topology resources.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Extensions/PostgresTransportDescriptorExtensions.cs Registers Postgres default conventions and parsing middleware.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Extensions/PostgresMessageTypeDescriptorExtensions.cs Adds outbound route helpers for queue/topic destinations.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Descriptors/PostgresTopicDescriptor.cs Adds fluent descriptor for topics.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Descriptors/PostgresSubscriptionDescriptor.cs Adds fluent descriptor for subscriptions.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Descriptors/PostgresQueueDescriptor.cs Adds fluent descriptor for queues.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Descriptors/IPostgresTopicDescriptor.cs Adds public topic descriptor interface.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Descriptors/IPostgresSubscriptionDescriptor.cs Adds public subscription descriptor interface.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Descriptors/IPostgresQueueDescriptor.cs Adds public queue descriptor interface.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Configurations/PostgresTopicConfiguration.cs Adds topic configuration model.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Configurations/PostgresSubscriptionConfiguration.cs Adds subscription configuration model.
src/Mocha/src/Mocha.Transport.Postgres/Topology/Configurations/PostgresQueueConfiguration.cs Adds queue configuration model.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/TopicMonitoringTask.cs Adds periodic topic stats logging task.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/QueueOverflowCleanupTask.cs Adds periodic cleanup task enforcing per-queue message limits.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/QueueMonitoringTask.cs Adds periodic queue stats logging task.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/PostgresBackgroundTaskScheduler.cs Adds task scheduler for Postgres background tasks.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/PostgresBackgroundTask.cs Adds base class for periodic Postgres tasks with consistent lifecycle.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/OrphanedMessageCleanupTask.cs Adds orphaned message release + notify task.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/MessageCleanupTask.cs Adds expired message cleanup task.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/ExpiredConsumerCleanupTask.cs Adds expired consumer cleanup task.
src/Mocha/src/Mocha.Transport.Postgres/Tasks/ConsumerHeartbeatTask.cs Adds consumer heartbeat + eviction detection task.
src/Mocha/src/Mocha.Transport.Postgres/PostgresMessageHeaders.cs Defines standard header keys stored in JSON.
src/Mocha/src/Mocha.Transport.Postgres/PostgresMessageEnvelopeParser.cs Parses DB message rows into normalized MessageEnvelope.
src/Mocha/src/Mocha.Transport.Postgres/PostgresDispatchEndpoint.cs Implements dispatch endpoint for sending/publishing into Postgres store.
src/Mocha/src/Mocha.Transport.Postgres/Mocha.Transport.Postgres.csproj Adds Postgres transport project + Npgsql dependency.
src/Mocha/src/Mocha.Transport.Postgres/Middlewares/Receive/PostgresReceiveMiddlewares.cs Exposes Postgres receive middleware configurations.
src/Mocha/src/Mocha.Transport.Postgres/Middlewares/Receive/PostgresParsingMiddleware.cs Adds receive middleware to parse Postgres message item to envelope.
src/Mocha/src/Mocha.Transport.Postgres/MessageBusBuilderExtensions.cs Adds AddPostgres(...) builder extension wiring defaults.
src/Mocha/src/Mocha.Transport.Postgres/JsonHeadersFeature.cs Adds pooled feature for JSON header serialization buffer.
src/Mocha/src/Mocha.Transport.Postgres/Features/PostgresReceiveFeature.cs Adds pooled feature carrying raw Postgres message item through pipeline.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/PostgresReceiveEndpointDescriptor.cs Adds receive endpoint descriptor for Postgres.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/PostgresMessagingTransportDescriptor.cs Adds top-level Postgres transport descriptor collecting endpoints/topology.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/PostgresDispatchEndpointDescriptor.cs Adds dispatch endpoint descriptor for Postgres.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/IPostgresReceiveEndpointDescriptor.cs Adds public receive endpoint descriptor interface.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/IPostgresMessagingTransportDescriptor.cs Adds public transport descriptor interface.
src/Mocha/src/Mocha.Transport.Postgres/Descriptors/IPostgresDispatchEndpointDescriptor.cs Adds public dispatch endpoint descriptor interface.
src/Mocha/src/Mocha.Transport.Postgres/Conventions/PostgresReceiveEndpointTopologyConvention.cs Adds convention to materialize queues/topics/subscriptions from inbound routes.
src/Mocha/src/Mocha.Transport.Postgres/Conventions/PostgresDispatchEndpointTopologyConvention.cs Adds convention to ensure dispatch targets and convention topics exist.
src/Mocha/src/Mocha.Transport.Postgres/Conventions/PostgresDefaultReceiveEndpointConvention.cs Adds convention to default queue name + error/skipped endpoints + apply defaults.
src/Mocha/src/Mocha.Transport.Postgres/Conventions/IPostgresReceiveEndpointTopologyConvention.cs Adds Postgres receive topology convention interface.
src/Mocha/src/Mocha.Transport.Postgres/Conventions/IPostgresReceiveEndpointConfigurationConvention.cs Adds Postgres receive configuration convention interface.
src/Mocha/src/Mocha.Transport.Postgres/Conventions/IPostgresDispatchEndpointTopologyConvention.cs Adds Postgres dispatch topology convention interface.
src/Mocha/src/Mocha.Transport.Postgres/Connection/PostgresSchemaSql.cs Adds SQL for schema/tables/indexes/migrations.
src/Mocha/src/Mocha.Transport.Postgres/Connection/PostgresSchemaMigrator.cs Adds migration runner with advisory lock + migrations table.
src/Mocha/src/Mocha.Transport.Postgres/Connection/PostgresMessageBatch.cs Adds pooled message batch container for DB reads.
src/Mocha/src/Mocha.Transport.Postgres/Connection/PostgresDelayedTrigger.cs Adds scheduled wake-up trigger to avoid busy waits.
src/Mocha/src/Mocha.Transport.Postgres/Connection/PostgresConsumerManager.cs Adds consumer registration/heartbeat/cleanup logic.
src/Mocha/src/Mocha.Transport.Postgres/Connection/PostgresConnectionManager.cs Adds Npgsql data source management, migration, health check.
src/Mocha/src/Mocha.Transport.Postgres/Connection/ErrorInfo.cs Adds error capture record for fault history.
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresTransportConfiguration.cs Adds transport configuration model (connection string, defaults, schema options).
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresSchemaOptions.cs Adds schema/table naming configuration model and read-only interface.
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresReceiveEndpointConfiguration.cs Adds receive endpoint config specialization (QueueName, MaxBatchSize, defaults).
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresDispatchEndpointConfiguration.cs Adds dispatch endpoint config specialization (QueueName/TopicName).
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresDefaultTopicOptions.cs Adds defaults application for topics.
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresDefaultQueueOptions.cs Adds defaults application for queues.
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresDefaultEndpointOptions.cs Adds defaults application for endpoints (batch size/concurrency).
src/Mocha/src/Mocha.Transport.Postgres/Configurations/PostgresBusDefaults.cs Adds container for transport-level defaults.
src/Mocha/src/Mocha.Transport.Postgres/Assembly.cs Adds internals visibility for Postgres transport tests.
src/Mocha/src/Mocha.Transport.InMemory/InMemoryReceiveEndpoint.cs Updates default MaxConcurrency handling for nullable config.
src/Mocha/Mocha.slnx Adds Postgres transport project to the solution.

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

Comment thread src/Mocha/src/Mocha.Transport.Postgres/PostgresDispatchEndpoint.cs
Comment thread src/Mocha/test/Mocha.Transport.Postgres.Tests/Behaviors/ErrorQueueTests.cs Outdated
Comment thread src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQReceiveEndpoint.cs
@PascalSenn PascalSenn force-pushed the pse/adds-postgres-transport-to-mocha branch from 33b6ba9 to a86fb77 Compare March 18, 2026 23:27
…mThroughput and enhance ConcurrencyLimiterMiddlewareTests with ID-based throwing handler
@PascalSenn PascalSenn force-pushed the pse/adds-postgres-transport-to-mocha branch from 42697bc to 3ea143d Compare March 19, 2026 01:11
@PascalSenn PascalSenn changed the title Add PostgreSQL transport to Mocha Adds PostgreSQL transport to Mocha Mar 20, 2026
@PascalSenn PascalSenn merged commit 6abaf3a into main Mar 20, 2026
124 checks passed
@PascalSenn PascalSenn deleted the pse/adds-postgres-transport-to-mocha branch March 20, 2026 08:33
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (8135564) to head (303622c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9383   +/-   ##
============================
============================

☔ 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. 🌶️ website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants