-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove service discovery as a core default for now (#2388)
- Loading branch information
1 parent
a1359c2
commit 8b09739
Showing
9 changed files
with
185 additions
and
139 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
21 changes: 21 additions & 0 deletions
21
src/Foundation/Conventions/StandardResilienceConvention.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Rocket.Surgery.Conventions; | ||
using Rocket.Surgery.Conventions.DependencyInjection; | ||
|
||
namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; | ||
|
||
/// <summary> | ||
/// Service conventions using service discovery | ||
/// </summary> | ||
[PublicAPI] | ||
[ExportConvention] | ||
[ConventionCategory(ConventionCategory.Application)] | ||
public class StandardResilienceConvention : IServiceConvention | ||
{ | ||
/// <inheritdoc /> | ||
public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) | ||
{ | ||
services.ConfigureHttpClientDefaults(http => http.AddStandardResilienceHandler()); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using Rocket.Surgery.Conventions; | ||
using Rocket.Surgery.LaunchPad.Foundation; | ||
|
||
namespace Extensions.Tests; | ||
|
||
public class AutoRegisterOptions(ITestOutputHelper testOutputHelper) : ConventionFakeTest(testOutputHelper) | ||
{ | ||
[Fact] | ||
public async Task Should_Register_Options() | ||
{ | ||
await Init(x => x.ConfigureConfiguration(builder => builder.AddInMemoryCollection([new("OptionsA:A", "B"), new("OptionsB:B", "A")]))); | ||
ServiceProvider.GetRequiredService<IOptions<OptionsA>>().Value.A.Should().Be("B"); | ||
ServiceProvider.GetRequiredService<IOptions<OptionsB>>().Value.B.Should().Be("A"); | ||
} | ||
|
||
[RegisterOptionsConfiguration("OptionsA")] | ||
[PublicAPI] | ||
private class OptionsA | ||
{ | ||
public required string A { get; set; } | ||
} | ||
|
||
[RegisterOptionsConfiguration("OptionsB")] | ||
[PublicAPI] | ||
private class OptionsB | ||
{ | ||
public required string B { get; set; } | ||
} | ||
} |
This file contains 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
Oops, something went wrong.