Skip to content

Commit

Permalink
Merge pull request #46 from Avanade/v2.4.0
Browse files Browse the repository at this point in the history
v2.4.0
  • Loading branch information
chullybun authored Jan 16, 2024
2 parents 51224ed + 7b0470c commit 386c768
Show file tree
Hide file tree
Showing 44 changed files with 145 additions and 193 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Represents the **NuGet** versions.

## v2.4.0
- *Fixed:* Updated `DbEx` (`v2.4.0`) and`CoreEx` (`v3.9.0`) and other dependencies.
- *Enhancement:* Updated the `dotnet new ntangle` template to target `net8.0` and [isolated](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide) functions.

## v2.3.6
- *Fixed:* Updated `DbEx` (`v2.3.15`) and`CoreEx` (`v3.8.1`) and other dependencies.
- *Fixed*: Updated `OnRamp` (`2.0.0`) which necessitated internal change from `Newtonsoft.Json` (now deprecated) to `System.Text.Json`.
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.3.6</Version>
<Version>2.4.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>NTangle Developers</Authors>
<Company>Avanade</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DbEx.SqlServer" Version="2.3.15" />
<PackageReference Include="DbEx.SqlServer" Version="2.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> <ItemGroup>
<PackageReference Include="CoreEx.Azure" Version="3.8.1" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.8.1" />
<PackageReference Include="CoreEx.Validation" Version="3.8.1" />
<PackageReference Include="CoreEx.Azure" Version="3.9.0" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.9.0" />
<PackageReference Include="CoreEx.Validation" Version="3.9.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.13.5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class SubscriberFunction
{
private readonly ServiceBusOrchestratedSubscriber _subscriber;

public SubscriberFunction(ServiceBusOrchestratedSubscriber subscriber) => _subscriber = subscriber ?? throw new ArgumentNullException(nameof(subscriber));
public SubscriberFunction(ServiceBusOrchestratedSubscriber subscriber) => _subscriber = subscriber.ThrowIfNull(nameof(subscriber));

[Singleton(Mode = SingletonMode.Function)]
[FunctionName("SubscriberFunction")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DbEx.SqlServer" Version="2.3.15" />
<PackageReference Include="DbEx.SqlServer" Version="2.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<!-- Following needed as per: https://github.com/Azure/azure-functions-core-tools/issues/2872 -->
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Update="appsettings.json">
Expand All @@ -22,7 +23,7 @@
<Folder Include="Entities\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx.Azure" Version="3.8.1" />
<PackageReference Include="CoreEx.Azure" Version="3.9.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.13.5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class ContactCdcEnvelope : ContactCdc, IEntityEnvelope

/// <inheritdoc/>
[JsonIgnore]
public byte[] DatabaseLsn { get; set; } = Array.Empty<byte>();
public byte[] DatabaseLsn { get; set; } = [];

/// <inheritdoc/>
[JsonIgnore]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DbEx.SqlServer" Version="2.3.15" />
<PackageReference Include="DbEx.SqlServer" Version="2.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class ContactCdcEnvelope : ContactCdc, IEntityEnvelope

/// <inheritdoc/>
[JsonIgnore]
public byte[] DatabaseLsn { get; set; } = Array.Empty<byte>();
public byte[] DatabaseLsn { get; set; } = [];

/// <inheritdoc/>
[JsonIgnore]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class CustomerCdcEnvelope : CustomerCdc, IEntityEnvelope

/// <inheritdoc/>
[JsonIgnore]
public byte[] DatabaseLsn { get; set; } = Array.Empty<byte>();
public byte[] DatabaseLsn { get; set; } = [];

/// <inheritdoc/>
[JsonIgnore]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override async Task<EntityOrchestratorResult<PostCdcEnvelopeCollection
{
foreach (var c in __result.GroupBy(x => new { x.Posts_PostsId }).Select(g => new { g.Key.Posts_PostsId, Coll = g.ToList() }))
{
var pItem = pColl.First(x => x.PostsId == c.Posts_PostsId).Comments ?? new();
var pItem = pColl.First(x => x.PostsId == c.Posts_PostsId).Comments ?? [];
foreach (var ct in c.Coll.GroupBy(x => new { x.ParentId }).Select(g => new { g.Key.ParentId, Coll = g.ToCollection<PostCdc.CommentsTagsCdcCollection, PostCdc.CommentsTagsCdc>() }))
{
pItem.Where(x => x.CommentsId == ct.ParentId).ForEach(x => x.Tags = ct.Coll);
Expand Down Expand Up @@ -105,7 +105,7 @@ public class PostCdcEnvelope : PostCdc, IEntityEnvelope

/// <inheritdoc/>
[JsonIgnore]
public byte[] DatabaseLsn { get; set; } = Array.Empty<byte>();
public byte[] DatabaseLsn { get; set; } = [];

/// <inheritdoc/>
[JsonIgnore]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ namespace SqlServerDemo.Publisher.Services;
/// <summary>
/// Provides the Change Data Capture (CDC) <see cref="ContactCdc"/> entity (aggregate root) <see cref="HostedService{T}"/> capabilities (database table '[Legacy].[Contact]').
/// </summary>
public partial class ContactHostedService : CdcHostedService<IContactOrchestrator, ContactCdc>
{
/// <summary>
/// Initializes a new instance of the <see cref="ContactHostedService"/> class.
/// </summary>
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="synchronizer"> The <see cref="IServiceSynchronizer"/>.</param>
public ContactHostedService(IServiceProvider serviceProvider, ILogger<ContactHostedService> logger, SettingsBase settings, IServiceSynchronizer synchronizer) : base(serviceProvider, logger, settings, synchronizer) { }
}
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="synchronizer"> The <see cref="IServiceSynchronizer"/>.</param>
public partial class ContactHostedService(IServiceProvider serviceProvider, ILogger<ContactHostedService> logger, SettingsBase settings, IServiceSynchronizer synchronizer)
: CdcHostedService<IContactOrchestrator, ContactCdc>(serviceProvider, logger, settings, synchronizer) { }
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ namespace SqlServerDemo.Publisher.Services;
/// <summary>
/// Provides the Change Data Capture (CDC) <see cref="CustomerCdc"/> entity (aggregate root) <see cref="HostedService{T}"/> capabilities (database table '[Legacy].[Customer]').
/// </summary>
public partial class CustomerHostedService : CdcHostedService<ICustomerOrchestrator, CustomerCdc>
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomerHostedService"/> class.
/// </summary>
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="synchronizer"> The <see cref="IServiceSynchronizer"/>.</param>
public CustomerHostedService(IServiceProvider serviceProvider, ILogger<CustomerHostedService> logger, SettingsBase settings, IServiceSynchronizer synchronizer) : base(serviceProvider, logger, settings, synchronizer) { }
}
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="synchronizer"> The <see cref="IServiceSynchronizer"/>.</param>
public partial class CustomerHostedService(IServiceProvider serviceProvider, ILogger<CustomerHostedService> logger, SettingsBase settings, IServiceSynchronizer synchronizer)
: CdcHostedService<ICustomerOrchestrator, CustomerCdc>(serviceProvider, logger, settings, synchronizer) { }
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ namespace SqlServerDemo.Publisher.Services;
/// <summary>
/// Provides the Change Data Capture (CDC) <see cref="PostCdc"/> entity (aggregate root) <see cref="HostedService{T}"/> capabilities (database table '[Legacy].[Posts]').
/// </summary>
public partial class PostHostedService : CdcHostedService<IPostOrchestrator, PostCdc>
{
/// <summary>
/// Initializes a new instance of the <see cref="PostHostedService"/> class.
/// </summary>
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="synchronizer"> The <see cref="IServiceSynchronizer"/>.</param>
public PostHostedService(IServiceProvider serviceProvider, ILogger<PostHostedService> logger, SettingsBase settings, IServiceSynchronizer synchronizer) : base(serviceProvider, logger, settings, synchronizer) { }
}
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="synchronizer"> The <see cref="IServiceSynchronizer"/>.</param>
public partial class PostHostedService(IServiceProvider serviceProvider, ILogger<PostHostedService> logger, SettingsBase settings, IServiceSynchronizer synchronizer)
: CdcHostedService<IPostOrchestrator, PostCdc>(serviceProvider, logger, settings, synchronizer) { }
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.Azure" Version="3.8.1" />
<PackageReference Include="CoreEx.Azure" Version="3.9.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
/// <summary>
/// Provides the <b>SqlServerDemo</b> settings.
/// </summary>
public class SqlServerDemoSettings : SettingsBase
/// <param name="configuration">The <see cref="IConfiguration"/>.</param>
public class SqlServerDemoSettings(IConfiguration configuration) : SettingsBase(configuration, "SqlServerDemo")
{
/// <summary>
/// Initializes a new instance of the <see cref="SqlServerDemoSettings"/> class.
/// </summary>
/// <param name="configuration">The <see cref="IConfiguration"/>.</param>
public SqlServerDemoSettings(IConfiguration configuration) : base(configuration, "SqlServerDemo") { }

/// <summary>
/// Gets the SQL Server database connection string.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DbEx.SqlServer" Version="2.3.15" />
<PackageReference Include="DbEx.SqlServer" Version="2.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
Expand Down
24 changes: 9 additions & 15 deletions src/NTangle/Cdc/EntityOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@ namespace NTangle.Cdc
/// <typeparam name="TEntityEnvelopeColl">The <typeparamref name="TEntityEnvelope"/> collection <see cref="Type"/>.</typeparam>
/// <typeparam name="TEntityEnvelope">The <typeparamref name="TEntity"/> envelope <see cref="Type"/>.</typeparam>
/// <typeparam name="TVersionTrackerMapper">The <see cref="VersionTracker"/> database and table-valued parameter mapper <see cref="Type"/>.</typeparam>
public abstract class EntityOrchestrator<TEntity, TEntityEnvelopeColl, TEntityEnvelope, TVersionTrackerMapper> : EntityOrchestratorBase<TEntity, TEntityEnvelopeColl, TEntityEnvelope, TVersionTrackerMapper>, IEntityOrchestrator<TEntity>
/// <param name="db">The <see cref="IDatabase"/>.</param>
/// <param name="executeStoredProcedureName">The name of the batch execute stored procedure.</param>
/// <param name="completeStoredProcedureName">The name of the batch complete stored procedure.</param>
/// <param name="eventPublisher">The <see cref="IEventPublisher"/>.</param>
/// <param name="jsonSerializer">The <see cref="IJsonSerializer"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
public abstract class EntityOrchestrator<TEntity, TEntityEnvelopeColl, TEntityEnvelope, TVersionTrackerMapper>(IDatabase db, string executeStoredProcedureName, string completeStoredProcedureName, IEventPublisher eventPublisher, IJsonSerializer jsonSerializer, SettingsBase settings, ILogger logger) : EntityOrchestratorBase<TEntity, TEntityEnvelopeColl, TEntityEnvelope, TVersionTrackerMapper>(db, executeStoredProcedureName, completeStoredProcedureName, eventPublisher, jsonSerializer, settings, logger), IEntityOrchestrator<TEntity>
where TEntity : class, IEntity, new()
where TEntityEnvelopeColl : List<TEntityEnvelope>, new()
where TEntityEnvelope : class, TEntity, IEntityEnvelope, new()
where TVersionTrackerMapper : IDatabaseMapper<VersionTracker>, IDatabaseTvp<VersionTracker>, new()
{
/// <summary>
/// Initializes a new instance of the <see cref="EntityOrchestrator{TEntity, TEntityEnvelopeColl, TEntityEnvelope, TVersionTrackerMapper}"/> class with no identifier mapping support.
/// </summary>
/// <param name="db">The <see cref="IDatabase"/>.</param>
/// <param name="executeStoredProcedureName">The name of the batch execute stored procedure.</param>
/// <param name="completeStoredProcedureName">The name of the batch complete stored procedure.</param>
/// <param name="eventPublisher">The <see cref="IEventPublisher"/>.</param>
/// <param name="jsonSerializer">The <see cref="IJsonSerializer"/>.</param>
/// <param name="settings">The <see cref="SettingsBase"/>.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
protected EntityOrchestrator(IDatabase db, string executeStoredProcedureName, string completeStoredProcedureName, IEventPublisher eventPublisher, IJsonSerializer jsonSerializer, SettingsBase settings, ILogger logger)
: base(db, executeStoredProcedureName, completeStoredProcedureName, eventPublisher, jsonSerializer, settings, logger) { }
}
{ }
}
16 changes: 8 additions & 8 deletions src/NTangle/Cdc/EntityOrchestratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public abstract class EntityOrchestratorBase<TEntity, TEntityEnvelopeColl, TEnti
/// <param name="logger">The <see cref="ILogger"/>.</param>
internal EntityOrchestratorBase(IDatabase db, string executeStoredProcedureName, string completeStoredProcedureName, IEventPublisher eventPublisher, IJsonSerializer jsonSerializer, SettingsBase settings, ILogger logger)
{
Db = db ?? throw new ArgumentNullException(nameof(db));
ExecuteStoredProcedureName = executeStoredProcedureName ?? throw new ArgumentNullException(nameof(executeStoredProcedureName));
CompleteStoredProcedureName = completeStoredProcedureName ?? throw new ArgumentNullException(nameof(completeStoredProcedureName));
EventPublisher = eventPublisher ?? throw new ArgumentNullException(nameof(eventPublisher));
JsonSerializer = jsonSerializer ?? throw new ArgumentNullException(nameof(jsonSerializer));
Settings = settings ?? throw new ArgumentNullException(nameof(settings));
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
Db = db.ThrowIfNull(nameof(db));
ExecuteStoredProcedureName = executeStoredProcedureName.ThrowIfNull(nameof(executeStoredProcedureName));
CompleteStoredProcedureName = completeStoredProcedureName.ThrowIfNull(nameof(completeStoredProcedureName));
EventPublisher = eventPublisher.ThrowIfNull(nameof(eventPublisher));
JsonSerializer = jsonSerializer.ThrowIfNull(nameof(jsonSerializer));
Settings = settings.ThrowIfNull(nameof(settings));
Logger = logger.ThrowIfNull(nameof(logger));

MaxQuerySize = Settings.GetCdcValue<int?>(ServiceName, MaxQuerySizeParamName) ?? 100;
ContinueWithDataLoss = Settings.GetCdcValue<bool?>(ServiceName, ContinueWithDataLossParamName) ?? false;
Expand Down Expand Up @@ -450,7 +450,7 @@ await Db.StoredProcedure(ExecuteStoredProcedureName).Params(p =>
/// The <see cref="IEventPublisher.SendAsync(CancellationToken)"/> must <b>not</b> be performed as this will result in data publishing inconsistencies; this is managed internally by the <see cref="ExecuteAsync(CancellationToken)"/>.</remarks>
protected virtual async Task CreateEventsAsync(IEventPublisher eventPublisher, TEntityEnvelopeColl coll, string? correlationId, CancellationToken cancellationToken = default)
{
foreach (var item in coll ?? throw new ArgumentNullException(nameof(coll)))
foreach (var item in coll.ThrowIfNull(nameof(coll)))
{
await CreateEventAsync(eventPublisher, item, item.DatabaseOperationType, correlationId, cancellationToken).ConfigureAwait(false);
}
Expand Down
7 changes: 4 additions & 3 deletions src/NTangle/Cdc/EntityOrchestratorT.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/NTangle

using CoreEx;
using CoreEx.Configuration;
using CoreEx.Database;
using CoreEx.Database.SqlServer;
Expand Down Expand Up @@ -48,9 +49,9 @@ public abstract class EntityOrchestrator<TEntity, TEntityEnvelopeColl, TEntityEn
public EntityOrchestrator(IDatabase db, string executeStoredProcedureName, string completeStoredProcedureName, IEventPublisher eventPublisher, IJsonSerializer jsonSerializer, SettingsBase settings, ILogger logger, string identifierMappingStoredProcedureName, IIdentifierGenerator<TGlobalIdentifer> identifierGenerator, IdentifierMappingMapperBase<TGlobalIdentifer> identifierMappingMapper)
: base(db, executeStoredProcedureName, completeStoredProcedureName, eventPublisher, jsonSerializer, settings, logger)
{
IdentifierMappingStoredProcedureName = identifierMappingStoredProcedureName ?? throw new ArgumentNullException(nameof(identifierMappingStoredProcedureName));
IdentifierGenerator = identifierGenerator ?? throw new ArgumentNullException(nameof(identifierGenerator));
IdentifierMappingMapper = identifierMappingMapper ?? throw new ArgumentNullException(nameof(identifierMappingMapper));
IdentifierMappingStoredProcedureName = identifierMappingStoredProcedureName.ThrowIfNull(nameof(identifierMappingStoredProcedureName));
IdentifierGenerator = identifierGenerator.ThrowIfNull(nameof(identifierGenerator));
IdentifierMappingMapper = identifierMappingMapper.ThrowIfNull(nameof(identifierMappingMapper));
AdditionalEnvelopeProcessingAsync = AssignIdentityMappingAsync;
}

Expand Down
Loading

0 comments on commit 386c768

Please sign in to comment.