From aabc77e6b619878ddedca32044e3408aa692ceec Mon Sep 17 00:00:00 2001 From: lqlive Date: Tue, 24 Feb 2026 18:05:35 +0800 Subject: [PATCH] Refactor updaters, auth policy, and DbSet watch methods Refactored UseCompassUpdaters to remove discard assignments when resolving services. Updated AuthenticationPolicy by removing JwtBearer and CreatedAt properties. Changed WatchAsync in DbSetExtensions to private and kept only the async enumerable as public. Added a stub ResourceSelector class in a new Sail.Kubernetes.Controller.Client namespace. --- .../Management/ServiceCollectionExtensions.cs | 10 +++--- .../Entities/AuthenticationPolicy.cs | 2 -- .../Extensions/DbSetExtensions.cs | 32 +++++++++---------- .../Client/ResourceSelector.cs | 6 ++++ 4 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 src/Sail.Kubernetes.Controller/Client/ResourceSelector.cs diff --git a/src/Sail.Compass/Management/ServiceCollectionExtensions.cs b/src/Sail.Compass/Management/ServiceCollectionExtensions.cs index d888aaa..8a531bd 100644 --- a/src/Sail.Compass/Management/ServiceCollectionExtensions.cs +++ b/src/Sail.Compass/Management/ServiceCollectionExtensions.cs @@ -151,10 +151,10 @@ public static IServiceCollection AddRetryPolicyUpdater( public static void UseCompassUpdaters(this IServiceProvider serviceProvider) { - _ = serviceProvider.GetService(); - _ = serviceProvider.GetService(); - _ = serviceProvider.GetService(); - _ = serviceProvider.GetService(); - _ = serviceProvider.GetService(); + serviceProvider.GetService(); + serviceProvider.GetService(); + serviceProvider.GetService(); + serviceProvider.GetService(); + serviceProvider.GetService(); } } diff --git a/src/Sail.Core/Entities/AuthenticationPolicy.cs b/src/Sail.Core/Entities/AuthenticationPolicy.cs index 118e40e..f42d91f 100644 --- a/src/Sail.Core/Entities/AuthenticationPolicy.cs +++ b/src/Sail.Core/Entities/AuthenticationPolicy.cs @@ -7,10 +7,8 @@ public class AuthenticationPolicy public AuthenticationSchemeType Type { get; set; } public bool Enabled { get; set; } = true; public string? Description { get; set; } - public JwtBearerConfig? JwtBearer { get; set; } public OpenIdConnectConfig? OpenIdConnect { get; set; } - public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow; public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow; } diff --git a/src/Sail.Database.MongoDB/Extensions/DbSetExtensions.cs b/src/Sail.Database.MongoDB/Extensions/DbSetExtensions.cs index 9b06e85..2aa46b7 100644 --- a/src/Sail.Database.MongoDB/Extensions/DbSetExtensions.cs +++ b/src/Sail.Database.MongoDB/Extensions/DbSetExtensions.cs @@ -10,22 +10,6 @@ namespace Sail.Database.MongoDB.Extensions; public static class DbSetExtensions { - public static Task>> WatchAsync( - this DbSet dbSet, - ChangeStreamOptions? options = null, - CancellationToken cancellationToken = default) - where T : class - { - var context = dbSet.GetService().Context; - var mongoClientWrapper = context.GetService(); - - var entityType = context.Model.FindEntityType(typeof(T))!; - var collectionName = entityType.GetCollectionName(); - var collection = mongoClientWrapper.GetCollection(collectionName); - - return collection.WatchAsync(options, cancellationToken); - } - public static async IAsyncEnumerable> WatchAsync( this DbSet dbSet, [EnumeratorCancellation] CancellationToken cancellationToken = default) @@ -67,4 +51,20 @@ public static async IAsyncEnumerable> WatchAsync( } } } + + private static Task>> WatchAsync( + this DbSet dbSet, + ChangeStreamOptions? options = null, + CancellationToken cancellationToken = default) + where T : class + { + var context = dbSet.GetService().Context; + var mongoClientWrapper = context.GetService(); + + var entityType = context.Model.FindEntityType(typeof(T))!; + var collectionName = entityType.GetCollectionName(); + var collection = mongoClientWrapper.GetCollection(collectionName); + + return collection.WatchAsync(options, cancellationToken); + } } \ No newline at end of file diff --git a/src/Sail.Kubernetes.Controller/Client/ResourceSelector.cs b/src/Sail.Kubernetes.Controller/Client/ResourceSelector.cs new file mode 100644 index 0000000..03bc70e --- /dev/null +++ b/src/Sail.Kubernetes.Controller/Client/ResourceSelector.cs @@ -0,0 +1,6 @@ +namespace Sail.Kubernetes.Controller.Client; + +public class ResourceSelector +{ + +}