Skip to content

Commit

Permalink
Prepare RTM (#261)
Browse files Browse the repository at this point in the history
* Prepare RTM

* Set serializer

* Tweaks

* Add test for HostApplicatonBuilder

---------

Co-authored-by: Brandon Ording <bording@gmail.com>
  • Loading branch information
andreasohlund and bording authored Mar 6, 2024
1 parent fe47656 commit ab29876
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 38 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Upload packages
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Sign NuGet packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"NServiceBus.Features.SagaAuditFeature",
"NServiceBus.Heartbeat.HeartbeatsFeature",
"NServiceBus.Heartbeat.Queue",
"NServiceBus.Metrics.MetricsFeature",
"NServiceBus.MetricsOptions",
"NServiceBus.SagaAudit.Queue"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
"errorQueue",
"NServiceBus.AuditConfigReader+Result",
"NServiceBus.CustomChecks.CustomChecksFeature",
"NServiceBus.CustomChecks.Queue",
"NServiceBus.Features.SagaAuditFeature",
"NServiceBus.Heartbeat.HeartbeatsFeature",
"NServiceBus.Heartbeat.Queue",
"NServiceBus.MetricsOptions",
"NServiceBus.SagaAudit.Queue"
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[
"NServiceBus.Metrics.MetricsFeature",
"NServiceBus.MetricsOptions"
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"NServiceBus.Features.SagaAuditFeature",
"NServiceBus.Heartbeat.HeartbeatsFeature",
"NServiceBus.Heartbeat.Queue",
"NServiceBus.Metrics.MetricsFeature",
"NServiceBus.MetricsOptions",
"NServiceBus.SagaAudit.Queue"
]
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void HandlesEnableFlag(string scenario, ServicePlatformConnectionConfigur
}

[Test]
public void CanBeDeserializedByMicrosoftConfigurationApi()
public void CanBeDeserializedByMicrosoftConfigurationApiWhenUsingHostBuilder()
{
var builder = new HostBuilder();

Expand All @@ -153,6 +153,8 @@ public void CanBeDeserializedByMicrosoftConfigurationApi()
.UseNServiceBus(c =>
{
var configuration = new EndpointConfiguration("whatever");

configuration.UseSerialization<SystemJsonSerializer>();
configuration.UseTransport<LearningTransport>();

var platformConfiguration = new ServicePlatformConnectionConfiguration();
Expand All @@ -176,6 +178,40 @@ public void CanBeDeserializedByMicrosoftConfigurationApi()
Approver.Verify(settingChanges);
}

[Test]
public void CanBeDeserializedByMicrosoftConfigurationApiWhenUsingHostApplicationBuilder()
{
var builder = Host.CreateApplicationBuilder();

var json = $@"{{""ServicePlatformConfiguration"" : {JsonConfiguration}}}";
var jsonStream = new MemoryStream(Encoding.ASCII.GetBytes(json));

builder.Configuration.AddJsonStream(jsonStream);

var endpointConfiguration = new EndpointConfiguration("whatever");
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
endpointConfiguration.UseTransport<LearningTransport>();

var platformConfiguration = new ServicePlatformConnectionConfiguration();
builder.Configuration.Bind("ServicePlatformConfiguration", platformConfiguration);

var beforeSettings = GetExplicitSettings(endpointConfiguration);

endpointConfiguration.ConnectToServicePlatform(platformConfiguration);

var afterSettings = GetExplicitSettings(endpointConfiguration);

var settingChanges = afterSettings.Except(beforeSettings)
.OrderBy(x => x)
.ToArray();

builder.UseNServiceBus(endpointConfiguration);

builder.Build();

Approver.Verify(settingChanges);
}

static string[] GetExplicitSettings(EndpointConfiguration endpointConfig)
{
var settings = endpointConfig.GetSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="3.0.0-alpha.3" />
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="Particular.Approvals" Version="1.0.0" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
</ItemGroup>

<ItemGroup Label="Transitive references">
<PackageReference Include="NServiceBus" Version="9.0.0-alpha.9" />
<PackageReference Include="NServiceBus.CustomChecks" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.Heartbeat" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.Metrics" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.SagaAudit" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus" Version="9.0.0" />
<PackageReference Include="NServiceBus.CustomChecks" Version="5.0.0" />
<PackageReference Include="NServiceBus.Heartbeat" Version="5.0.0" />
<PackageReference Include="NServiceBus.Metrics" Version="5.0.0" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="5.0.0" />
<PackageReference Include="NServiceBus.SagaAudit" Version="5.0.0" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions src/NServiceBus.ServicePlatform.Connector.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.ServicePlatform
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{368E2CED-3A60-48D1-846B-FD9E6C1638AE}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml
Custom.Build.props = Custom.Build.props
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
EndProjectSection
EndProject
Global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SolutionDir)NServiceBus.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\NServiceBus.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -12,13 +12,12 @@
</PropertyGroup>

<ItemGroup Label="Public dependencies">
<PackageReference Include="NServiceBus" Version="9.0.0-alpha.6" />
<PackageReference Include="NServiceBus.CustomChecks" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.Heartbeat" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.Metrics" Version="5.0.0-alpha.1" />
<PackageReference Include="NServiceBus.SagaAudit" Version="5.0.0-alpha.1" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
<PackageReference Include="NServiceBus" Version="[9.0.0, 10.0.0)" />
<PackageReference Include="NServiceBus.CustomChecks" Version="[5.0.0, 6.0.0)" />
<PackageReference Include="NServiceBus.Heartbeat" Version="[5.0.0, 6.0.0)" />
<PackageReference Include="NServiceBus.Metrics" Version="[5.0.0, 6.0.0)" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="[5.0.0, 6.0.0)" />
<PackageReference Include="NServiceBus.SagaAudit" Version="[5.0.0, 6.0.0)" />
</ItemGroup>

<ItemGroup Label="Private dependencies">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ internal void ApplyTo(EndpointConfiguration endpointConfiguration)

if (string.IsNullOrWhiteSpace(AuditQueue))
{
throw new Exception(
@"Message auditing is enabled but no audit queue has been configured.
Configure an audit queue or disable message auditing");
throw new Exception("Message auditing is enabled but no audit queue has been configured. Configure an audit queue or disable message auditing.");
}

endpointConfiguration.AuditProcessedMessagesTo(AuditQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal void ApplyTo(EndpointConfiguration endpointConfiguration)
}

/// <summary>
/// Creates a new <see cref="ServicePlatformConnectionConfiguration"/> from json produced by the Particular Service Platform.
/// Creates a new <see cref="ServicePlatformConnectionConfiguration"/> from JSON produced by the Particular Service Platform.
/// </summary>
public static ServicePlatformConnectionConfiguration Parse(string jsonConfiguration)
{
Expand All @@ -61,7 +61,7 @@ public static ServicePlatformConnectionConfiguration Parse(string jsonConfigurat
PropertyNameCaseInsensitive = true
};
options.Converters.Add(new JsonTimeSpanConverterFactory());
return System.Text.Json.JsonSerializer.Deserialize<ServicePlatformConnectionConfiguration>(jsonConfiguration, options);
return JsonSerializer.Deserialize<ServicePlatformConnectionConfiguration>(jsonConfiguration, options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ internal void ApplyTo(EndpointConfiguration endpointConfiguration)

if (string.IsNullOrWhiteSpace(CustomChecksQueue))
{
throw new Exception(
@"Sending custom checks results is enabled but no custom check queue has been configured.
Configure a custom check queue or disable sending custom checks to the Particular Service Platform");
throw new Exception("Sending custom checks results is enabled but no custom check queue has been configured. Configure a custom check queue or disable sending custom checks to the Particular Service Platform.");
}

endpointConfiguration.ReportCustomChecksTo(CustomChecksQueue, TimeToLive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ internal void ApplyTo(EndpointConfiguration endpointConfiguration)

if (string.IsNullOrWhiteSpace(HeartbeatsQueue))
{
throw new Exception(
@"Sending heartbeats is enabled but no heartbeat queue has been configured.
Configure a heartbeat queue or disable sending heartbeats to the Particular Service Platform");
throw new Exception("Sending heartbeats is enabled but no heartbeat queue has been configured. Configure a heartbeat queue or disable sending heartbeats to the Particular Service Platform.");
}

endpointConfiguration.SendHeartbeatTo(HeartbeatsQueue, Frequency, TimeToLive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ internal void ApplyTo(EndpointConfiguration endpointConfiguration)

if (string.IsNullOrWhiteSpace(MetricsQueue))
{
throw new Exception(
@"Sending metric data is enabled but no metrics queue has been configured.
Configure a metrics queue or disable sending metric data to the Particular Service Platform");
throw new Exception("Sending metric data is enabled but no metrics queue has been configured. Configure a metrics queue or disable sending metric data to the Particular Service Platform.");
}

var metrics = endpointConfiguration.EnableMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ internal void ApplyTo(EndpointConfiguration endpointConfiguration)

if (string.IsNullOrWhiteSpace(SagaAuditQueue))
{
throw new Exception(
@"Sending saga audit information is enabled but no saga audit queue has been configured.
Configure a saga audit queue or disable sending saga audit information to the Particular Service Platform");
throw new Exception("Sending saga audit information is enabled but no saga audit queue has been configured. Configure a saga audit queue or disable sending saga audit information to the Particular Service Platform.");

}

Expand Down

0 comments on commit ab29876

Please sign in to comment.