Repository navigation
v7: Host the bus through dependency injection (AddObvs) - #107
Merged
Merged
Conversation
services.AddObvs(obvs => obvs.AddService<TServiceMessage>(name, service => service.UseEndpointProvider(...))) registers one singleton bus, resolvable as both IServiceBus and IServiceBusClient. A hosted service creates it when the host starts, so configuration errors stop startup; the container disposes it. Repeated AddObvs calls add to the same bus, AsClient/AsServer choose which endpoints are created, AddObvs(key, ...) registers a separate keyed bus, and an invalid configuration fails with one ObvsConfigurationException listing every problem and its fix. UseEndpointProvider bridges every existing transport until each gets its own Use<Transport>() method. ServiceBus.Dispose is now safe to call twice: the container tracks the bus behind both of its registrations. Part of #84. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First v7 increment, part of #84 (design, section 1). Targets the long-running
v7branch.API
Behaviour
IServiceBusandIServiceBusClient.AddObvscalled more than once adds to the same bus.AsClient()andAsServer()control which endpoints are created.AddObvs(key, ...)registers a bus resolved with[FromKeyedServices(key)]. Each container gets its own bus, so two hosts in one process don't share one.ObvsConfigurationExceptionlisting every problem with its fix. For example, a service with no transport, or a service name used twice.ServiceBus.Dispose()is now safe to call twice. The container tracks the bus behind both of its registrations, so it was being disposed twice, and real transports may not tolerate that.UseEndpointProviderlets every existing v6 transport work straight away. Each transport's ownUse<Transport>()method, with options from configuration, comes in a later increment.Dependencies
The core
Obvspackage now referencesMicrosoft.Extensions.DependencyInjection.AbstractionsandMicrosoft.Extensions.Hosting.Abstractions10.0.13. Both supportnet462+ andnetstandard2.0, so no targets are dropped.Tests (written first)
Obvs.Tests/Hosting/TestAddObvs.cs: 13 tests. 12 were agreed before implementation and all failed withNotImplementedException.ShouldDisposeTheBusOnlyOncewas added during implementation and failed with "Expected 1, Actual 2".TestServiceBus.ShouldDisposeEndpointsOnlyOnceWhenDisposedTwice: failed before theDisposeguard.net472,netstandard2.0andnet10.0, and all 143 unit tests pass.Not in this increment
Use<Transport>()methods and binding options fromIConfiguration.ILoggerand OpenTelemetry (v7: OpenTelemetry tracing and metrics, Microsoft.Extensions.Logging #90).ObvsBus.StartAsyncbuilder.🤖 Generated with Claude Code