Skip to content

Commit

Permalink
drop net6.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Nov 16, 2023
1 parent 2e4bdca commit 3e7c415
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 238 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Version>12.0.4</Version>
<Version>13.0.0</Version>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Description>Low level .net wrapper for the SQL Server transport.</Description>
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/Shared.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.2" />
<PackageReference Include="ProjectDefaults" Version="1.0.101" PrivateAssets="all" />
<PackageReference Include="ProjectDefaults" Version="1.0.102" PrivateAssets="all" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.2" />
<PackageReference Include="NServiceBus" Version="8.1.6" />
<PackageReference Include="NServiceBus.Newtonsoft.Json" Version="3.0.0" />
<PackageReference Include="NServiceBus.Transport.SqlServer" Version="7.0.2" />
<ProjectReference Include="..\SqlServer.Deduplication\SqlServer.Deduplication.csproj" />
<PackageReference Include="ProjectDefaults" Version="1.0.101" PrivateAssets="all" />
<PackageReference Include="ProjectDefaults" Version="1.0.102" PrivateAssets="all" />
<Using Include="NServiceBus.IMessageHandlerContext" Alias="HandlerContext" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/SqlServer.Deduplication/NServiceBusExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public static bool PurgeOnStartup(this IReadOnlySettings settings)
{
return purgeOnStartup;
}

return false;
}
}
7 changes: 2 additions & 5 deletions src/SqlServer.Deduplication/NeedToInstallSomething.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
using NServiceBus.Settings;
using NServiceBus.Transport.SqlServerDeduplication;

class NeedToInstallSomething :
class NeedToInstallSomething(IReadOnlySettings settings) :
INeedToInstallSomething
{
DedupeSettings? settings;

public NeedToInstallSomething(IReadOnlySettings settings) =>
this.settings = settings.GetOrDefault<DedupeSettings>();
DedupeSettings? settings = settings.GetOrDefault<DedupeSettings>();

public async Task Install(string identity, Cancel cancel = default)
{
Expand Down
15 changes: 3 additions & 12 deletions src/SqlServer.Deduplication/PurgeTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@
using NServiceBus.Features;
using NServiceBus.Transport.SqlServerDeduplication;

class PurgeTask :
FeatureStartupTask
class PurgeTask(Table table, Func<Cancel, Task<SqlConnection>> builder) :
FeatureStartupTask
{
Table table;
Func<Cancel, Task<SqlConnection>> connectionBuilder;

public PurgeTask(Table table, Func<Cancel, Task<SqlConnection>> connectionBuilder)
{
this.table = table;
this.connectionBuilder = connectionBuilder;
}

protected override async Task OnStart(IMessageSession session, Cancel cancel = default)
{
using var connection = await connectionBuilder(Cancel.None);
using var connection = await builder(Cancel.None);
var dedupeManager = new DedupeManager(connection, table);
await dedupeManager.PurgeItems(cancel);
}
Expand Down
14 changes: 3 additions & 11 deletions src/SqlServer.Deduplication/SendBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@
using NServiceBus.Transport;
using NServiceBus.Transport.SqlServerDeduplication;

class SendBehavior :
Behavior<IOutgoingPhysicalMessageContext>
class SendBehavior(Table table, Func<Cancel, Task<SqlConnection>> builder) :
Behavior<IOutgoingPhysicalMessageContext>
{
ILog logger = LogManager.GetLogger("DeduplicationSendBehavior");
Table table;
Func<Cancel, Task<SqlConnection>> connectionBuilder;

public SendBehavior(Table table, Func<Cancel, Task<SqlConnection>> connectionBuilder)
{
this.table = table;
this.connectionBuilder = connectionBuilder;
}

public override async Task Invoke(IOutgoingPhysicalMessageContext context, Func<Task> next)
{
Expand All @@ -25,7 +17,7 @@ public override async Task Invoke(IOutgoingPhysicalMessageContext context, Func<
return;
}

var connectionTask = connectionBuilder(Cancel.None);
var connectionTask = builder(Cancel.None);
if (context.Extensions.TryGet(out TransportTransaction _))
{
throw new NotSupportedException("Deduplication is currently designed to be used from outside the NServiceBus pipeline. For example to dedup messages being sent from inside a web service endpoint.");
Expand Down
13 changes: 3 additions & 10 deletions src/SqlServer.Deduplication/SendRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
using NServiceBus.Pipeline;
using NServiceBus.Transport.SqlServerDeduplication;

class SendRegistration :
RegisterStep
{
public SendRegistration(Table table, Func<Cancel, Task<SqlConnection>> connectionBuilder) :
base(
stepId: $"{AssemblyHelper.Name}Send",
class SendRegistration(Table table, Func<Cancel, Task<SqlConnection>> connectionBuilder) :
RegisterStep(stepId: $"{AssemblyHelper.Name}Send",
behavior: typeof(SendBehavior),
description: "Saves the outgoing message id to a secondary store to allow message deduplication",
factoryMethod: _ => new SendBehavior(table, connectionBuilder))
{
}
}
factoryMethod: _ => new SendBehavior(table, connectionBuilder));
4 changes: 2 additions & 2 deletions src/SqlServer.Deduplication/SqlServer.Deduplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>NServiceBus.SqlServer.Deduplication</AssemblyName>
<PackageName>NServiceBus.SqlServer.Deduplication</PackageName>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<Description>Message deduplication for the SQL Server transport.</Description>
<DefineConstants>$(DefineConstants);SqlServerDedupe</DefineConstants>
</PropertyGroup>
Expand All @@ -20,7 +20,7 @@
<PackageReference Include="NServiceBus" Version="8.1.6" />
<PackageReference Include="Polyfill" Version="1.32.1" PrivateAssets="all" />
<PackageReference Include="NServiceBus.Transport.SqlServer" Version="7.0.2" />
<PackageReference Include="ProjectDefaults" Version="1.0.101" PrivateAssets="all" />
<PackageReference Include="ProjectDefaults" Version="1.0.102" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" Condition="$(Configuration) == 'Release'" />
</ItemGroup>
</Project>
22 changes: 7 additions & 15 deletions src/SqlServer.Deduplication/StartupTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@
using NServiceBus.Features;
using NServiceBus.Transport.SqlServerDeduplication;

class CleanupTask :
FeatureStartupTask
class CleanupTask(
Table table,
CriticalError error,
Func<Cancel, Task<SqlConnection>> builder) :
FeatureStartupTask
{
Table table;
CriticalError criticalError;
Func<Cancel, Task<SqlConnection>> connectionBuilder;
DedupeCleanerJob? job;

public CleanupTask(Table table, CriticalError criticalError,
Func<Cancel, Task<SqlConnection>> connectionBuilder)
{
this.table = table;
this.criticalError = criticalError;
this.connectionBuilder = connectionBuilder;
}

protected override Task OnStart(IMessageSession session, Cancel cancel = default)
{
job = new(table, connectionBuilder, RaiseError);
job = new(table, builder, RaiseError);
job.Start();
return Task.CompletedTask;
}

void RaiseError(Exception exception) =>
criticalError.Raise("Dedup cleanup failed", exception);
error.Raise("Dedup cleanup failed", exception);

protected override Task OnStop(IMessageSession session, Cancel cancel = default) =>
job == null ? Task.CompletedTask : job.Stop();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.2" />
Expand All @@ -10,7 +10,7 @@
<PackageReference Include="NServiceBus.Transport.SqlServer" Version="7.0.2" />
<PackageReference Include="NServiceBus.Attachments.Sql" Version="12.0.6" />
<ProjectReference Include="..\Shared\Shared.csproj" />
<PackageReference Include="ProjectDefaults" Version="1.0.101" PrivateAssets="all" />
<PackageReference Include="ProjectDefaults" Version="1.0.102" PrivateAssets="all" />
<Using Include="NServiceBus.IMessageHandlerContext" Alias="HandlerContext" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="test.html">
Expand All @@ -12,6 +12,6 @@
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\SqlServer.HttpPassthrough\SqlServer.HttpPassthrough.csproj" />
<ProjectReference Include="..\SqlServer.Native\SqlServer.Native.csproj" />
<PackageReference Include="ProjectDefaults" Version="1.0.101" PrivateAssets="all" />
<PackageReference Include="ProjectDefaults" Version="1.0.102" PrivateAssets="all" />
</ItemGroup>
</Project>
16 changes: 3 additions & 13 deletions src/SqlServer.HttpPassthrough/DedupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@
using Microsoft.Extensions.Hosting;
using NServiceBus.Transport.SqlServerNative;

class DedupService :
IHostedService
class DedupService(Table table, Func<Cancel, Task<SqlConnection>> builder, Action<Exception> error) :
IHostedService
{
Table table;
Func<Cancel, Task<SqlConnection>> connectionBuilder;
Action<Exception> criticalError;
DedupeCleanerJob? job;

public DedupService(Table table, Func<Cancel, Task<SqlConnection>> connectionBuilder, Action<Exception> criticalError)
{
this.table = table;
this.connectionBuilder = connectionBuilder;
this.criticalError = criticalError;
}

public Task StartAsync(Cancel cancel)
{
job = new(table, connectionBuilder, criticalError);
job = new(table, builder, error);
job.Start();
return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
using Microsoft.Extensions.Logging;
using NServiceBus.SqlServer.HttpPassthrough;

class BadRequestMiddleware
class BadRequestMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
{
RequestDelegate next;
ILogger<BadRequestMiddleware> logger;

public BadRequestMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
{
this.next = next;
logger = loggerFactory.CreateLogger<BadRequestMiddleware>();
}
ILogger<BadRequestMiddleware> logger = loggerFactory.CreateLogger<BadRequestMiddleware>();

public async Task Invoke(HttpContext context)
{
Expand Down
15 changes: 3 additions & 12 deletions src/SqlServer.HttpPassthrough/Headers/HeadersBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
using NServiceBus.SqlServer.HttpPassthrough;
using NServiceBus.Transport.SqlServerNative;

class HeadersBuilder
class HeadersBuilder(string endpoint, string machine)
{
string originatingEndpoint;
string originatingMachine;

public HeadersBuilder(string originatingEndpoint, string originatingMachine)
{
this.originatingEndpoint = originatingEndpoint;
this.originatingMachine = originatingMachine;
}

public string GetHeadersString(PassthroughMessage message)
{
var messageType = GetMessageName(message);
Expand All @@ -22,8 +13,8 @@ public string GetHeadersString(PassthroughMessage message)
dictionary.Add("NServiceBus.CorrelationId", correlationId);
dictionary.Add("NServiceBus.EnclosedMessageTypes", messageType);
dictionary.Add("NServiceBus.TimeSent", Headers.ToWireFormattedString(DateTime.UtcNow));
dictionary.Add("NServiceBus.OriginatingMachine", originatingMachine);
dictionary.Add("NServiceBus.OriginatingEndpoint", originatingEndpoint);
dictionary.Add("NServiceBus.OriginatingMachine", machine);
dictionary.Add("NServiceBus.OriginatingEndpoint", endpoint);
if (message.ClientUrl != null)
{
dictionary.Add("MessagePassthrough.ClientUrl", message.ClientUrl);
Expand Down
26 changes: 11 additions & 15 deletions src/SqlServer.HttpPassthrough/Headers/IncomingHeaders.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
struct IncomingHeaders
struct IncomingHeaders(
Guid messageId,
string messageType,
string? messageNamespace,
string? destination,
string? referrer)
{
public Guid MessageId { get; }
public string MessageType { get; }
public string? Referrer { get; }
public string? Destination { get; }
public string? MessageNamespace { get; }

public IncomingHeaders(Guid messageId, string messageType, string? messageNamespace, string? destination, string? referrer)
{
MessageId = messageId;
MessageType = messageType;
MessageNamespace = messageNamespace;
Destination = destination;
Referrer = referrer;
}
public Guid MessageId { get; } = messageId;
public string MessageType { get; } = messageType;
public string? Referrer { get; } = referrer;
public string? Destination { get; } = destination;
public string? MessageNamespace { get; } = messageNamespace;
}
Loading

0 comments on commit 3e7c415

Please sign in to comment.