From d65ce1f7b29ed5522e49bef520768bdc276ab18b Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Wed, 15 Jan 2025 09:07:51 +0100 Subject: [PATCH] Events cleanup. --- Directory.Build.props | 2 +- .../MongoGridFsAssetStoreTests.cs | 1 - .../AssetsServiceExtensions.cs | 1 - assets/TusTestServer/Utils.cs | 1 - .../Squidex.Events.Tests/EventStoreTests.cs | 1 - .../MariaDbEventStoreFixture.cs | 1 - .../MysqlEventStoreFixture.cs | 1 - .../PostgresEventStoreFixture.cs | 1 - .../SqlServerEventStoreFixture.cs | 1 - .../Squidex.Events/CollectionNameAttribute.cs | 14 ------- events/Squidex.Events/CommonHeaders.cs | 19 --------- events/Squidex.Events/EnvelopeExtensions.cs | 40 ------------------- ...rValueConverter.cs => EventHeaderValue.cs} | 0 .../{Telemetry.cs => EventsTelemetry.cs} | 2 +- events/Squidex.Events/IOnRead.cs | 13 ------ .../InconsistentStateException.cs | 21 ---------- 16 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 events/Squidex.Events/CollectionNameAttribute.cs delete mode 100644 events/Squidex.Events/CommonHeaders.cs rename events/Squidex.Events/{EventHeaderValueConverter.cs => EventHeaderValue.cs} (100%) rename events/Squidex.Events/{Telemetry.cs => EventsTelemetry.cs} (93%) delete mode 100644 events/Squidex.Events/IOnRead.cs delete mode 100644 events/Squidex.Events/InconsistentStateException.cs diff --git a/Directory.Build.props b/Directory.Build.props index 5d0fa18..77b53e6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ https://github.com/squidex/squidex true snupkg - 6.24.0 + 6.25.0 diff --git a/assets/Squidex.Assets.Tests/MongoGridFsAssetStoreTests.cs b/assets/Squidex.Assets.Tests/MongoGridFsAssetStoreTests.cs index cc1b494..e6258f7 100644 --- a/assets/Squidex.Assets.Tests/MongoGridFsAssetStoreTests.cs +++ b/assets/Squidex.Assets.Tests/MongoGridFsAssetStoreTests.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using Squidex.Assets.TusAdapter; using Xunit; namespace Squidex.Assets; diff --git a/assets/Squidex.Assets.TusAdapter/AssetsServiceExtensions.cs b/assets/Squidex.Assets.TusAdapter/AssetsServiceExtensions.cs index 9188b5e..ad4e5bd 100644 --- a/assets/Squidex.Assets.TusAdapter/AssetsServiceExtensions.cs +++ b/assets/Squidex.Assets.TusAdapter/AssetsServiceExtensions.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using Squidex.Assets; using Squidex.Assets.TusAdapter; using Squidex.Assets.TusAdapter.Internal; using tusdotnet.Interfaces; diff --git a/assets/TusTestServer/Utils.cs b/assets/TusTestServer/Utils.cs index 2903cb1..69a2ae4 100644 --- a/assets/TusTestServer/Utils.cs +++ b/assets/TusTestServer/Utils.cs @@ -6,7 +6,6 @@ // ========================================================================== using Squidex.Assets; -using Squidex.Assets.Internal; using Squidex.Assets.TusAdapter; using Squidex.Assets.TusAdapter.Internal; using tusdotnet; diff --git a/events/Squidex.Events.Tests/EventStoreTests.cs b/events/Squidex.Events.Tests/EventStoreTests.cs index ee2b266..0d0ed21 100644 --- a/events/Squidex.Events.Tests/EventStoreTests.cs +++ b/events/Squidex.Events.Tests/EventStoreTests.cs @@ -7,7 +7,6 @@ using System.Globalization; using FluentAssertions; -using Squidex.Events.EntityFramework; using Xunit; #pragma warning disable MA0040 // Forward the CancellationToken parameter to methods that take one diff --git a/events/Squidex.Events.Tests/MariaDbEventStoreFixture.cs b/events/Squidex.Events.Tests/MariaDbEventStoreFixture.cs index 8993e81..191652a 100644 --- a/events/Squidex.Events.Tests/MariaDbEventStoreFixture.cs +++ b/events/Squidex.Events.Tests/MariaDbEventStoreFixture.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Squidex.Hosting; using Testcontainers.MariaDb; diff --git a/events/Squidex.Events.Tests/MysqlEventStoreFixture.cs b/events/Squidex.Events.Tests/MysqlEventStoreFixture.cs index dc150bc..80b42f8 100644 --- a/events/Squidex.Events.Tests/MysqlEventStoreFixture.cs +++ b/events/Squidex.Events.Tests/MysqlEventStoreFixture.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Squidex.Hosting; using Testcontainers.MySql; diff --git a/events/Squidex.Events.Tests/PostgresEventStoreFixture.cs b/events/Squidex.Events.Tests/PostgresEventStoreFixture.cs index 330e328..4ec5906 100644 --- a/events/Squidex.Events.Tests/PostgresEventStoreFixture.cs +++ b/events/Squidex.Events.Tests/PostgresEventStoreFixture.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Squidex.Hosting; using Testcontainers.PostgreSql; diff --git a/events/Squidex.Events.Tests/SqlServerEventStoreFixture.cs b/events/Squidex.Events.Tests/SqlServerEventStoreFixture.cs index 889054f..3237744 100644 --- a/events/Squidex.Events.Tests/SqlServerEventStoreFixture.cs +++ b/events/Squidex.Events.Tests/SqlServerEventStoreFixture.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Squidex.Hosting; using Testcontainers.MsSql; diff --git a/events/Squidex.Events/CollectionNameAttribute.cs b/events/Squidex.Events/CollectionNameAttribute.cs deleted file mode 100644 index 660ad6d..0000000 --- a/events/Squidex.Events/CollectionNameAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -namespace Squidex.Events; - -[AttributeUsage(AttributeTargets.Class)] -public sealed class CollectionNameAttribute(string name) : Attribute -{ - public string Name { get; } = name; -} diff --git a/events/Squidex.Events/CommonHeaders.cs b/events/Squidex.Events/CommonHeaders.cs deleted file mode 100644 index cc43694..0000000 --- a/events/Squidex.Events/CommonHeaders.cs +++ /dev/null @@ -1,19 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -namespace Squidex.Events; - -public static class CommonHeaders -{ - public static readonly string CommitId = nameof(CommitId); - - public static readonly string EventId = nameof(EventId); - - public static readonly string EventStreamNumber = nameof(EventStreamNumber); - - public static readonly string Timestamp = nameof(Timestamp); -} diff --git a/events/Squidex.Events/EnvelopeExtensions.cs b/events/Squidex.Events/EnvelopeExtensions.cs index ad906a1..930f4d4 100644 --- a/events/Squidex.Events/EnvelopeExtensions.cs +++ b/events/Squidex.Events/EnvelopeExtensions.cs @@ -11,26 +11,6 @@ namespace Squidex.Events; public static class EnvelopeExtensions { - public static long EventStreamNumber(this EnvelopeHeaders headers) - { - return headers.GetLong(CommonHeaders.EventStreamNumber); - } - - public static Guid CommitId(this EnvelopeHeaders headers) - { - return headers.GetGuid(CommonHeaders.CommitId); - } - - public static Guid EventId(this EnvelopeHeaders headers) - { - return headers.GetGuid(CommonHeaders.EventId); - } - - public static DateTime Timestamp(this EnvelopeHeaders headers) - { - return headers.GetInstant(CommonHeaders.Timestamp); - } - public static long GetLong(this EnvelopeHeaders obj, string key) { if (obj.TryGetValue(key, out var found)) @@ -48,26 +28,6 @@ public static long GetLong(this EnvelopeHeaders obj, string key) return 0; } - public static Guid GetGuid(this EnvelopeHeaders obj, string key) - { - if (obj.TryGetValue(key, out var found) && found is HeaderStringValue s && Guid.TryParse(s.Value, out var guid)) - { - return guid; - } - - return default; - } - - public static DateTime GetInstant(this EnvelopeHeaders obj, string key) - { - if (obj.TryGetValue(key, out var found) && found is HeaderStringValue s && DateTime.TryParseExact(s.Value, "o", CultureInfo.InvariantCulture, DateTimeStyles.None, out var instant)) - { - return instant; - } - - return default; - } - public static string GetString(this EnvelopeHeaders obj, string key) { if (obj.TryGetValue(key, out var found)) diff --git a/events/Squidex.Events/EventHeaderValueConverter.cs b/events/Squidex.Events/EventHeaderValue.cs similarity index 100% rename from events/Squidex.Events/EventHeaderValueConverter.cs rename to events/Squidex.Events/EventHeaderValue.cs diff --git a/events/Squidex.Events/Telemetry.cs b/events/Squidex.Events/EventsTelemetry.cs similarity index 93% rename from events/Squidex.Events/Telemetry.cs rename to events/Squidex.Events/EventsTelemetry.cs index 4c250da..a952af5 100644 --- a/events/Squidex.Events/Telemetry.cs +++ b/events/Squidex.Events/EventsTelemetry.cs @@ -9,7 +9,7 @@ namespace Squidex.Events; -public static class Telemetry +public static class EventsTelemetry { public static readonly ActivitySource Activities = new ActivitySource("Squidex"); } diff --git a/events/Squidex.Events/IOnRead.cs b/events/Squidex.Events/IOnRead.cs deleted file mode 100644 index 09817c9..0000000 --- a/events/Squidex.Events/IOnRead.cs +++ /dev/null @@ -1,13 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -namespace Squidex.Events; - -public interface IOnRead -{ - ValueTask OnReadAsync(); -} diff --git a/events/Squidex.Events/InconsistentStateException.cs b/events/Squidex.Events/InconsistentStateException.cs deleted file mode 100644 index 4ec9685..0000000 --- a/events/Squidex.Events/InconsistentStateException.cs +++ /dev/null @@ -1,21 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschraenkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -namespace Squidex.Events; - -[Serializable] -public class InconsistentStateException(long current, long expected, Exception? inner = null) : Exception(FormatMessage(current, expected), inner) -{ - public long VersionCurrent { get; } = current; - - public long VersionExpected { get; } = expected; - - private static string FormatMessage(long current, long expected) - { - return $"Requested version {expected}, but found {current}."; - } -}