Skip to content

Commit a268f50

Browse files
committed
Refactor settings handling to use IOptions pattern and integrate ServiceControl-specific configurations.
1 parent 27198ac commit a268f50

File tree

93 files changed

+609
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+609
-486
lines changed

src/ServiceControl.AcceptanceTests.RavenDB/Recoverability/MessageFailures/When_a_message_fails_to_import.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public async Task It_can_be_reimported()
3434

3535
SetSettings = settings =>
3636
{
37-
settings.ForwardErrorMessages = true;
38-
settings.ErrorLogQueue = Conventions.EndpointNamingConvention(typeof(ErrorLogSpy));
37+
settings.ServiceControl.ForwardErrorMessages = true;
38+
settings.ServiceBus.ErrorLogQueue = Conventions.EndpointNamingConvention(typeof(ErrorLogSpy));
3939
};
4040

4141
var runResult = await Define<MyContext>()

src/ServiceControl.AcceptanceTests.RavenDB/StartupModeTests.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ public async Task InitializeSettings()
2626

2727
settings = new Settings
2828
{
29-
TransportType = transportIntegration.TypeName,
30-
ErrorRetentionPeriod = TimeSpan.FromDays(1),
31-
PersistenceType = "RavenDB",
32-
TransportConnectionString = transportIntegration.ConnectionString,
33-
AssemblyLoadContextResolver = static _ => AssemblyLoadContext.Default
29+
ServiceControl =
30+
{
31+
TransportType = transportIntegration.TypeName,
32+
ErrorRetentionPeriod = TimeSpan.FromDays(1),
33+
PersistenceType = "RavenDB",
34+
ConnectionString = transportIntegration.ConnectionString,
35+
AssemblyLoadContextResolver = static _ => AssemblyLoadContext.Default
36+
}
3437
};
3538

3639
configuration = new AcceptanceTestStorageConfiguration();
@@ -46,7 +49,8 @@ public async Task CanRunMaintenanceMode()
4649
// ideally we'd be using the MaintenanceModeCommand here but that indefinitely blocks due to the RunAsync
4750
// not terminating.
4851
var hostBuilder = Host.CreateApplicationBuilder();
49-
hostBuilder.Services.AddPersistence(settings, maintenanceMode: true);
52+
settings.ServiceControl.MaintenanceMode = true;
53+
hostBuilder.Services.AddPersistence(hostBuilder.Configuration, settings); // TODO: Configuration needs to be initialized
5054

5155
using var host = hostBuilder.Build();
5256
await host.StartAsync();
@@ -55,7 +59,7 @@ public async Task CanRunMaintenanceMode()
5559

5660
[Test]
5761
public async Task CanRunImportFailedMessagesMode()
58-
=> await new TestableImportFailedErrorsCommand().Execute(new HostArguments([], settings), settings);
62+
=> await new TestableImportFailedErrorsCommand().Execute(new HostArguments([], maintenanceMode: false));
5963

6064
class TestableImportFailedErrorsCommand() : ImportFailedErrorsCommand()
6165
{
@@ -64,7 +68,10 @@ protected override EndpointConfiguration CreateEndpointConfiguration(Settings se
6468
var configuration = base.CreateEndpointConfiguration(settings);
6569

6670
//HINT: we want to exclude this assembly to prevent loading features that are part of the acceptance testing framework
67-
var thisAssembly = new[] { typeof(StartupModeTests).Assembly.GetName().Name };
71+
var thisAssembly = new[]
72+
{
73+
typeof(StartupModeTests).Assembly.GetName().Name
74+
};
6875

6976
configuration.AssemblyScanner().ExcludeAssemblies(thisAssembly);
7077

src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_custom_check_fails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class MyContext : ScenarioContext;
4444

4545
public class EndpointWithFailingCustomCheck : EndpointConfigurationBuilder
4646
{
47-
public EndpointWithFailingCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
47+
public EndpointWithFailingCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(PrimaryOptions.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
4848

4949
class FailingCustomCheck() : CustomCheck("MyCustomCheckId", "MyCategory")
5050
{

src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_periodic_custom_check_fails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected override async Task OnStart(IMessageSession session, CancellationToken
124124

125125
public class WithCustomCheck : EndpointConfigurationBuilder
126126
{
127-
public WithCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
127+
public WithCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(PrimaryOptions.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
128128

129129
class FailingCustomCheck(MyContext context)
130130
: NServiceBus.CustomChecks.CustomCheck("MyCustomCheckId", "MyCategory", TimeSpan.FromSeconds(5))

src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_critical_storage_threshold_reached.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public void SetupIngestion()
2020
{
2121
SetSettings = s =>
2222
{
23-
s.TimeToRestartErrorIngestionAfterFailure = TimeSpan.FromSeconds(1);
24-
s.DisableHealthChecks = false;
23+
s.ServiceControl.TimeToRestartErrorIngestionAfterFailure = TimeSpan.FromSeconds(1);
24+
s.ServiceControl.DisableHealthChecks = false;
2525
};
2626
}
2727

@@ -97,7 +97,7 @@ public class Sender : EndpointConfigurationBuilder
9797
public Sender() =>
9898
EndpointSetup<DefaultServerWithoutAudit>(c =>
9999
{
100-
c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1));
100+
c.ReportCustomChecksTo(PrimaryOptions.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1));
101101
c.NoRetries();
102102
});
103103

src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_custom_check_events_are_triggered.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class MyContext : ScenarioContext
4444

4545
public class EndpointWithCustomCheck : EndpointConfigurationBuilder
4646
{
47-
public EndpointWithCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)));
47+
public EndpointWithCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => c.ReportCustomChecksTo(PrimaryOptions.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)));
4848

4949
public class EventuallyFailingCustomCheck()
5050
: CustomCheck("EventuallyFailingCustomCheck", "Testing", TimeSpan.FromSeconds(1))

src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_email_notifications_are_enabled.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public async Task Should_send_custom_check_status_change_emails()
2828

2929
SetSettings = settings =>
3030
{
31-
settings.NotificationsFilter = "MyCustomCheckId#Other custom check";
32-
settings.EmailDropFolder = emailDropPath;
31+
settings.ServiceControl.NotificationsFilter = "MyCustomCheckId#Other custom check";
32+
settings.ServiceControl.EmailDropFolder = emailDropPath;
3333
};
3434

3535
CustomizeHostBuilder = hostBuilder => hostBuilder.Services.AddHostedService<SetupNotificationSettings>();
@@ -87,7 +87,7 @@ public class MyContext : ScenarioContext
8787

8888
public class EndpointWithFailingCustomCheck : EndpointConfigurationBuilder
8989
{
90-
public EndpointWithFailingCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
90+
public EndpointWithFailingCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(PrimaryOptions.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
9191

9292
class FailingCustomCheck() : CustomCheck("MyCustomCheckId", "MyCategory")
9393
{

src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_reporting_custom_check_with_signalr.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected override Task OnStart(IMessageSession session, CancellationToken cance
9393

9494
class EndpointWithCustomCheck : EndpointConfigurationBuilder
9595
{
96-
public EndpointWithCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
96+
public EndpointWithCustomCheck() => EndpointSetup<DefaultServerWithoutAudit>(c => { c.ReportCustomChecksTo(PrimaryOptions.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); });
9797

9898
public class EventuallyFailingCustomCheck()
9999
: CustomCheck("EventuallyFailingCustomCheck", "Testing", TimeSpan.FromSeconds(1))

src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_fails.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public ExternalProcessor() =>
6969
EndpointSetup<DefaultServerWithoutAudit>(c =>
7070
{
7171
var routing = c.ConfigureRouting();
72-
routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME);
72+
routing.RouteToEndpoint(typeof(MessageFailed).Assembly, PrimaryOptions.DEFAULT_INSTANCE_NAME);
7373
}, publisherMetadata =>
7474
{
75-
publisherMetadata.RegisterPublisherFor<CustomCheckFailed>(Settings.DEFAULT_INSTANCE_NAME);
75+
publisherMetadata.RegisterPublisherFor<CustomCheckFailed>(PrimaryOptions.DEFAULT_INSTANCE_NAME);
7676
});
7777

7878
public class CustomCheckFailedHandler(MyContext testContext) : IHandleMessages<CustomCheckFailed>

src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_succeeds.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public ExternalProcessor() =>
6464
EndpointSetup<DefaultServerWithoutAudit>(c =>
6565
{
6666
var routing = c.ConfigureRouting();
67-
routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME);
67+
routing.RouteToEndpoint(typeof(MessageFailed).Assembly, PrimaryOptions.DEFAULT_INSTANCE_NAME);
6868
}, publisherMetadata =>
6969
{
70-
publisherMetadata.RegisterPublisherFor<CustomCheckSucceeded>(Settings.DEFAULT_INSTANCE_NAME);
70+
publisherMetadata.RegisterPublisherFor<CustomCheckSucceeded>(PrimaryOptions.DEFAULT_INSTANCE_NAME);
7171
});
7272

7373
public class CustomCheckSucceededHandler(MyContext testContext) : IHandleMessages<CustomCheckSucceeded>

0 commit comments

Comments
 (0)