Adds PostgreSQL transport to Mocha#9383
Conversation
There was a problem hiding this comment.
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.Postgrestransport (topology, descriptors, conventions, schema migrator, background tasks, envelope parsing, etc.). - Adds
Mocha.Transport.Postgres.Testswith integration tests (using Squadron PostgreSQL) covering topology, send/publish, request/reply, batching, concurrency, headers, fault/error-queue behavior. - Updates shared endpoint configuration (
MaxConcurrencynow 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.
33b6ba9 to
a86fb77
Compare
…mThroughput and enhance ConcurrencyLimiterMiddlewareTests with ID-based throwing handler
42697bc to
3ea143d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9383 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.