From 89559c72fadcf3fc90c18bf1e07c033a0c40ea46 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Mon, 26 Aug 2024 11:35:14 +0200 Subject: [PATCH] fix(Solution): Updated solution packages --- deployments/docker-compose/docker-compose.yml | 9 ++++--- .../CloudStreams.Broker.Api.csproj | 12 ++++----- src/broker/CloudStreams.Broker.Api/Dockerfile | 6 ++--- .../CloudStreams.Broker.Application.csproj | 8 +++--- .../Services/SubscriptionHandler.cs | 12 ++++----- .../Services/SubscriptionManager.cs | 2 +- .../CloudStreams.Core.Api.Client.csproj | 4 +-- .../CloudStreams.Core.Api.csproj | 26 +++++++++---------- .../Services/BrokerHealthMonitor.cs | 18 ++++++------- .../Services/BrokerResourceController.cs | 2 +- .../CloudStreamsApplicationBuilder.cs | 2 +- .../Services/GatewayHealthMonitor.cs | 18 ++++++------- .../Services/GatewayResourceController.cs | 2 +- .../ResourceWatchEventHubController.cs | 4 +-- .../CloudStreams.Core.Application.csproj | 6 ++--- .../Resources/CreateResourceCommand.cs | 2 +- .../Resources/DeleteResourceCommand.cs | 2 +- .../Generic/CreateResourceCommand.cs | 2 +- .../Generic/DeleteResourceCommand.cs | 2 +- .../Resources/Generic/PatchResourceCommand.cs | 4 +-- .../Generic/ReplaceResourceCommand.cs | 2 +- .../Resources/PatchResourceCommand.cs | 4 +-- .../Resources/ReplaceResourceCommand.cs | 2 +- .../Gateways/CheckGatewayHealthQuery.cs | 2 +- .../Generic/GetResourceDefinitionQuery.cs | 2 +- .../Resources/Generic/GetResourceQuery.cs | 2 +- .../Resources/Generic/GetResourcesQuery.cs | 2 +- .../Resources/Generic/ListResourcesQuery.cs | 2 +- .../Resources/Generic/WatchResourcesQuery.cs | 2 +- .../Queries/Resources/GetResourceQuery.cs | 2 +- .../Queries/Resources/GetResourcesQuery.cs | 2 +- .../Queries/Resources/ListResourcesQuery.cs | 2 +- .../Queries/Resources/WatchResourcesQuery.cs | 2 +- .../CloudStreams.Core.csproj | 6 ++--- .../CloudStreams.Dashboard.csproj | 10 +++---- .../Components/Timeline/Timeline.razor | 4 +-- .../CloudStreams.Dashboard/Program.cs | 6 ----- .../Services/EventDropsInterop.cs | 24 +++++++---------- .../CloudStreams.Gateway.Api.csproj | 12 ++++----- .../CloudStreams.Gateway.Application.csproj | 4 +-- .../Services/CloudEventAdmissionControl.cs | 2 +- 41 files changed, 115 insertions(+), 124 deletions(-) diff --git a/deployments/docker-compose/docker-compose.yml b/deployments/docker-compose/docker-compose.yml index 2227c0d7..16dfd866 100644 --- a/deployments/docker-compose/docker-compose.yml +++ b/deployments/docker-compose/docker-compose.yml @@ -18,10 +18,11 @@ services: image: redis:latest gateway: - image: ${DOCKER_REGISTRY-}gateway - build: - context: ../../ - dockerfile: ./src/gateway/CloudStreams.Gateway.Api/Dockerfile + image: cloud-streams/gateway + # image: ${DOCKER_REGISTRY-}gateway + # build: + # context: ../../ + # dockerfile: ./src/gateway/CloudStreams.Gateway.Api/Dockerfile environment: ASPNETCORE_ENVIRONMENT: Development ASPNETCORE_HTTP_PORTS: 80 diff --git a/src/broker/CloudStreams.Broker.Api/CloudStreams.Broker.Api.csproj b/src/broker/CloudStreams.Broker.Api/CloudStreams.Broker.Api.csproj index ab0c66e4..5cc2982c 100644 --- a/src/broker/CloudStreams.Broker.Api/CloudStreams.Broker.Api.csproj +++ b/src/broker/CloudStreams.Broker.Api/CloudStreams.Broker.Api.csproj @@ -26,12 +26,12 @@ - - - - - - + + + + + + diff --git a/src/broker/CloudStreams.Broker.Api/Dockerfile b/src/broker/CloudStreams.Broker.Api/Dockerfile index e492b4d4..ea8f105f 100644 --- a/src/broker/CloudStreams.Broker.Api/Dockerfile +++ b/src/broker/CloudStreams.Broker.Api/Dockerfile @@ -1,10 +1,10 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base -USER app -WORKDIR /app -EXPOSE 80 USER root RUN apt-get update RUN apt-get install -y jq +USER app +WORKDIR /app +EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release diff --git a/src/broker/CloudStreams.Broker.Application/CloudStreams.Broker.Application.csproj b/src/broker/CloudStreams.Broker.Application/CloudStreams.Broker.Application.csproj index d2a646c3..432cd38b 100644 --- a/src/broker/CloudStreams.Broker.Application/CloudStreams.Broker.Application.csproj +++ b/src/broker/CloudStreams.Broker.Application/CloudStreams.Broker.Application.csproj @@ -19,10 +19,10 @@ - - - - + + + + diff --git a/src/broker/CloudStreams.Broker.Application/Services/SubscriptionHandler.cs b/src/broker/CloudStreams.Broker.Application/Services/SubscriptionHandler.cs index c78d5e2a..d7e0b0d4 100644 --- a/src/broker/CloudStreams.Broker.Application/Services/SubscriptionHandler.cs +++ b/src/broker/CloudStreams.Broker.Application/Services/SubscriptionHandler.cs @@ -44,7 +44,7 @@ public class SubscriptionHandler /// An containing registered s /// The service used to perform HTTP requests /// The to dispatch s to - public SubscriptionHandler(ILoggerFactory loggerFactory, IHostApplicationLifetime hostApplicationLifetime, IJsonSerializer serializer, ICloudEventStore cloudEventStore, IRepository resourceRepository, IResourceController subscriptionController, + public SubscriptionHandler(ILoggerFactory loggerFactory, IHostApplicationLifetime hostApplicationLifetime, IJsonSerializer serializer, ICloudEventStore cloudEventStore, IResourceRepository resourceRepository, IResourceController subscriptionController, IResourceMonitor broker, IExpressionEvaluator expressionEvaluator, IEnumerable> cloudEventValidators, HttpClient httpClient, Subscription subscription) { this.Logger = loggerFactory.CreateLogger(this.GetType()); @@ -85,7 +85,7 @@ public SubscriptionHandler(ILoggerFactory loggerFactory, IHostApplicationLifetim /// /// Gets the service used to manage s /// - protected IRepository ResourceRepository { get; } + protected IResourceRepository ResourceRepository { get; } /// /// Gets the service used to control resources @@ -530,7 +530,7 @@ protected virtual async Task CommitOffsetAsync(ulong? offset) resource.Status.ObservedGeneration = this.Subscription.Metadata.Generation; var patch = JsonPatchUtility.CreateJsonPatchFromDiff(this.Subscription, resource); if (!patch.Operations.Any()) return; - await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false); + await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false); } /// @@ -546,7 +546,7 @@ protected virtual async Task SetStatusPhaseAsync(SubscriptionStatusPhase phase) resource.Status.Phase = phase; var patch = JsonPatchUtility.CreateJsonPatchFromDiff(this.Subscription, resource); if (!patch.Operations.Any()) return; - await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false); + await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false); } /// @@ -586,7 +586,7 @@ protected virtual async Task OnSubscriptionOffsetChangedAsync(long? offset) if (resource.Status.Stream == null) resource.Status.Stream = new(); resource.Status.Stream.Fault = null; var patch = JsonPatchUtility.CreateJsonPatchFromDiff(this.Subscription, resource); - await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false); + await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false); return; } await this.CancelSynchronizationLoopAsync().ConfigureAwait(false); @@ -650,7 +650,7 @@ protected virtual async Task OnSubscriptionErrorAsync(Exception ex) if (resource.Status.Stream == null) resource.Status.Stream = new(); resource.Status.Stream.Fault = ex.ToProblemDetails(); var patch = JsonPatchUtility.CreateJsonPatchFromDiff(this.Subscription, resource); - await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false); + await this.ResourceRepository.PatchStatusAsync(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false); } /// diff --git a/src/broker/CloudStreams.Broker.Application/Services/SubscriptionManager.cs b/src/broker/CloudStreams.Broker.Application/Services/SubscriptionManager.cs index 604e02b3..c3984dad 100644 --- a/src/broker/CloudStreams.Broker.Application/Services/SubscriptionManager.cs +++ b/src/broker/CloudStreams.Broker.Application/Services/SubscriptionManager.cs @@ -30,7 +30,7 @@ namespace CloudStreams.Broker.Application.Services; /// The service used to access the current /// The service used to manage s /// The service used to access the current -public class SubscriptionManager(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions> controllerOptions, IRepository repository, IOptions brokerOptions) +public class SubscriptionManager(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions> controllerOptions, IResourceRepository repository, IOptions brokerOptions) : ResourceController(loggerFactory, controllerOptions, repository) { diff --git a/src/core/CloudStreams.Core.Api.Client/CloudStreams.Core.Api.Client.csproj b/src/core/CloudStreams.Core.Api.Client/CloudStreams.Core.Api.Client.csproj index 464f9ecd..f33d54dd 100644 --- a/src/core/CloudStreams.Core.Api.Client/CloudStreams.Core.Api.Client.csproj +++ b/src/core/CloudStreams.Core.Api.Client/CloudStreams.Core.Api.Client.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/core/CloudStreams.Core.Api/CloudStreams.Core.Api.csproj b/src/core/CloudStreams.Core.Api/CloudStreams.Core.Api.csproj index e611dd05..980dd8cb 100644 --- a/src/core/CloudStreams.Core.Api/CloudStreams.Core.Api.csproj +++ b/src/core/CloudStreams.Core.Api/CloudStreams.Core.Api.csproj @@ -25,19 +25,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/core/CloudStreams.Core.Api/Services/BrokerHealthMonitor.cs b/src/core/CloudStreams.Core.Api/Services/BrokerHealthMonitor.cs index ab5acc4b..c56e3422 100644 --- a/src/core/CloudStreams.Core.Api/Services/BrokerHealthMonitor.cs +++ b/src/core/CloudStreams.Core.Api/Services/BrokerHealthMonitor.cs @@ -27,7 +27,7 @@ namespace CloudStreams.Core.Api.Services; /// The service used to manage resources /// The service used to monitor the handled /// The service used to perform HTTP requests -public class BrokerHealthMonitor(ILogger logger, IJsonSerializer serializer, IRepository repository, IResourceMonitor monitor, HttpClient httpClient) +public class BrokerHealthMonitor(ILogger logger, IJsonSerializer serializer, IResourceRepository repository, IResourceMonitor monitor, HttpClient httpClient) : IHostedService, IDisposable, IAsyncDisposable { @@ -47,7 +47,7 @@ public class BrokerHealthMonitor(ILogger logger, IJsonSeria /// /// Gets the service used to manage resources /// - protected IRepository Repository { get; } = repository; + protected IResourceRepository Repository { get; } = repository; /// /// Gets the service used to monitor the handled @@ -80,7 +80,7 @@ public virtual Task StartAsync(CancellationToken cancellationToken) this.CancellationTokenSource = new(); if (this.Broker.Spec.Service == null || this.Broker.Spec.Service.HealthChecks == null) return Task.CompletedTask; this.Monitor.Select(e => e.Resource.Spec.Service?.HealthChecks).DistinctUntilChanged().SubscribeAsync(this.OnHealthChecksConfigurationChangedAsync, this.CancellationTokenSource.Token); - this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalEllapsedAsync, null, TimeSpan.Zero, Timeout.InfiniteTimeSpan); + this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalElapsedAsync, null, TimeSpan.Zero, Timeout.InfiniteTimeSpan); return Task.CompletedTask; } @@ -105,14 +105,14 @@ protected virtual async Task OnHealthChecksConfigurationChangedAsync(ServiceHeal var delay = this.Broker.Status?.LastHealthCheckAt.HasValue == true ? DateTimeOffset.Now - this.Broker.Status.LastHealthCheckAt : TimeSpan.Zero; if (delay < TimeSpan.Zero) delay = TimeSpan.Zero; if (this.Broker.Spec.Service.HealthChecks.Interval != null && this.Broker.Spec.Service.HealthChecks.Interval > delay) delay = this.Broker.Spec.Service.HealthChecks.Interval; - this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalEllapsedAsync, null, this.Broker.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); + this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalElapsedAsync, null, this.Broker.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); } /// /// Handles ticks of the /// /// The timer's async state - protected virtual async void OnHealthCheckIntervalEllapsedAsync(object? state) + protected virtual async void OnHealthCheckIntervalElapsedAsync(object? state) { try { @@ -157,7 +157,7 @@ protected virtual async void OnHealthCheckIntervalEllapsedAsync(object? state) } catch (Exception ex) { - this.Logger.LogWarning("An error occured while performing health check of gateway '{gateway}': {ex}", this.Broker.GetQualifiedName(), ex); + this.Logger.LogWarning("An error occurred while performing health check of gateway '{gateway}': {ex}", this.Broker.GetQualifiedName(), ex); healthCheckResponse = new(HealthStatus.Unhealthy); } if (healthCheckResponse.Status != this.Broker.Status?.HealthStatus) @@ -168,18 +168,18 @@ protected virtual async void OnHealthCheckIntervalEllapsedAsync(object? state) patchTarget.Status.HealthStatus = healthCheckResponse.Status; patchTarget.Status.LastHealthCheckAt = DateTimeOffset.Now; var patch = new Patch(PatchType.JsonPatch, JsonPatchUtility.CreateJsonPatchFromDiff(patchSource, patchTarget)); - await this.Repository.PatchStatusAsync(patch, this.Broker.GetName(), this.Broker.GetNamespace(), false, this.CancellationTokenSource!.Token).ConfigureAwait(false); + await this.Repository.PatchStatusAsync(patch, this.Broker.GetName(), this.Broker.GetNamespace(), null, false, this.CancellationTokenSource!.Token).ConfigureAwait(false); } } catch(Exception ex) { - this.Logger.LogError("An error occured while checking health of gateway '{gateway}': {ex}", this.Broker.GetQualifiedName(), ex); + this.Logger.LogError("An error occurred while checking health of gateway '{gateway}': {ex}", this.Broker.GetQualifiedName(), ex); } finally { if (this.Broker.Spec.Service != null && this.Broker.Spec.Service.HealthChecks != null) { - this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalEllapsedAsync, null, this.Broker.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); + this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalElapsedAsync, null, this.Broker.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); } } } diff --git a/src/core/CloudStreams.Core.Api/Services/BrokerResourceController.cs b/src/core/CloudStreams.Core.Api/Services/BrokerResourceController.cs index fc0d0bdb..4838b41e 100644 --- a/src/core/CloudStreams.Core.Api/Services/BrokerResourceController.cs +++ b/src/core/CloudStreams.Core.Api/Services/BrokerResourceController.cs @@ -21,7 +21,7 @@ namespace CloudStreams.Core.Api.Services; /// Represents a used to control s /// /// -public class BrokerResourceController(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions> controllerOptions, IRepository repository) +public class BrokerResourceController(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions> controllerOptions, IResourceRepository repository) : ResourceController(loggerFactory, controllerOptions, repository) { diff --git a/src/core/CloudStreams.Core.Api/Services/CloudStreamsApplicationBuilder.cs b/src/core/CloudStreams.Core.Api/Services/CloudStreamsApplicationBuilder.cs index a044b996..b290f266 100644 --- a/src/core/CloudStreams.Core.Api/Services/CloudStreamsApplicationBuilder.cs +++ b/src/core/CloudStreams.Core.Api/Services/CloudStreamsApplicationBuilder.cs @@ -81,7 +81,7 @@ public CloudStreamsApplicationBuilder(ConfigurationManager configuration, IHostE this.Services.AddHostedService(); this.Services.AddSingleton(); this.Services.AddSingleton(); - this.Services.AddSingleton(); + this.Services.AddSingleton(); this.Services.AddSingleton(); this.Services.AddSingleton(); this.Services.AddSingleton(); diff --git a/src/core/CloudStreams.Core.Api/Services/GatewayHealthMonitor.cs b/src/core/CloudStreams.Core.Api/Services/GatewayHealthMonitor.cs index 15f8928c..3cb3fd24 100644 --- a/src/core/CloudStreams.Core.Api/Services/GatewayHealthMonitor.cs +++ b/src/core/CloudStreams.Core.Api/Services/GatewayHealthMonitor.cs @@ -33,7 +33,7 @@ namespace CloudStreams.Core.Api.Services; /// The service used to manage resources /// The service used to monitor the handled /// The service used to perform HTTP requests -public class GatewayHealthMonitor(ILogger logger, IJsonSerializer serializer, IRepository repository, IResourceMonitor monitor, HttpClient httpClient) +public class GatewayHealthMonitor(ILogger logger, IJsonSerializer serializer, IResourceRepository repository, IResourceMonitor monitor, HttpClient httpClient) : IHostedService, IDisposable, IAsyncDisposable { @@ -53,7 +53,7 @@ public class GatewayHealthMonitor(ILogger logger, IJsonSer /// /// Gets the service used to manage resources /// - protected IRepository Repository { get; } = repository; + protected IResourceRepository Repository { get; } = repository; /// /// Gets the service used to monitor the handled @@ -86,7 +86,7 @@ public virtual Task StartAsync(CancellationToken cancellationToken) this.CancellationTokenSource = new(); if (this.Gateway.Spec.Service == null || this.Gateway.Spec.Service.HealthChecks == null) return Task.CompletedTask; this.Monitor.Select(e => e.Resource.Spec.Service?.HealthChecks).DistinctUntilChanged().SubscribeAsync(this.OnHealthChecksConfigurationChangedAsync, this.CancellationTokenSource.Token); - this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalEllapsedAsync, null, TimeSpan.Zero, Timeout.InfiniteTimeSpan); + this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalElapsedAsync, null, TimeSpan.Zero, Timeout.InfiniteTimeSpan); return Task.CompletedTask; } @@ -111,14 +111,14 @@ protected virtual async Task OnHealthChecksConfigurationChangedAsync(ServiceHeal var delay = this.Gateway.Status?.LastHealthCheckAt.HasValue == true ? DateTimeOffset.Now - this.Gateway.Status.LastHealthCheckAt : TimeSpan.Zero; if (delay < TimeSpan.Zero) delay = TimeSpan.Zero; if (this.Gateway.Spec.Service.HealthChecks.Interval != null && this.Gateway.Spec.Service.HealthChecks.Interval > delay) delay = this.Gateway.Spec.Service.HealthChecks.Interval; - this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalEllapsedAsync, null, this.Gateway.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); + this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalElapsedAsync, null, this.Gateway.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); } /// /// Handles ticks of the /// /// The timer's async state - protected virtual async void OnHealthCheckIntervalEllapsedAsync(object? state) + protected virtual async void OnHealthCheckIntervalElapsedAsync(object? state) { try { @@ -163,7 +163,7 @@ protected virtual async void OnHealthCheckIntervalEllapsedAsync(object? state) } catch (Exception ex) { - this.Logger.LogWarning("An error occured while performing health check of gateway '{gateway}': {ex}", this.Gateway.GetQualifiedName(), ex); + this.Logger.LogWarning("An error occurred while performing health check of gateway '{gateway}': {ex}", this.Gateway.GetQualifiedName(), ex); healthCheckResponse = new(HealthStatus.Unhealthy); } if (healthCheckResponse.Status != this.Gateway.Status?.HealthStatus) @@ -174,18 +174,18 @@ protected virtual async void OnHealthCheckIntervalEllapsedAsync(object? state) patchTarget.Status.HealthStatus = healthCheckResponse.Status; patchTarget.Status.LastHealthCheckAt = DateTimeOffset.Now; var patch = new Patch(PatchType.JsonPatch, JsonPatchUtility.CreateJsonPatchFromDiff(patchSource, patchTarget)); - await this.Repository.PatchStatusAsync(patch, this.Gateway.GetName(), this.Gateway.GetNamespace(), false, this.CancellationTokenSource!.Token).ConfigureAwait(false); + await this.Repository.PatchStatusAsync(patch, this.Gateway.GetName(), this.Gateway.GetNamespace(), null, false, this.CancellationTokenSource!.Token).ConfigureAwait(false); } } catch(Exception ex) { - this.Logger.LogError("An error occured while checking health of gateway '{gateway}': {ex}", this.Gateway.GetQualifiedName(), ex); + this.Logger.LogError("An error occurred while checking health of gateway '{gateway}': {ex}", this.Gateway.GetQualifiedName(), ex); } finally { if (this.Gateway.Spec.Service != null && this.Gateway.Spec.Service.HealthChecks != null) { - this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalEllapsedAsync, null, this.Gateway.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); + this.HealthCheckTimer = new Timer(this.OnHealthCheckIntervalElapsedAsync, null, this.Gateway.Spec.Service.HealthChecks.Interval?.ToTimeSpan() ?? TimeSpan.FromSeconds(DefaultInterval), Timeout.InfiniteTimeSpan); } } } diff --git a/src/core/CloudStreams.Core.Api/Services/GatewayResourceController.cs b/src/core/CloudStreams.Core.Api/Services/GatewayResourceController.cs index 90ba77b8..622a9c41 100644 --- a/src/core/CloudStreams.Core.Api/Services/GatewayResourceController.cs +++ b/src/core/CloudStreams.Core.Api/Services/GatewayResourceController.cs @@ -21,7 +21,7 @@ namespace CloudStreams.Core.Api.Services; /// Represents a used to control s /// /// -public class GatewayResourceController(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions> controllerOptions, IRepository repository) +public class GatewayResourceController(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions> controllerOptions, IResourceRepository repository) : ResourceController(loggerFactory, controllerOptions, repository) { diff --git a/src/core/CloudStreams.Core.Api/Services/ResourceWatchEventHubController.cs b/src/core/CloudStreams.Core.Api/Services/ResourceWatchEventHubController.cs index 390f6861..30e0f81e 100644 --- a/src/core/CloudStreams.Core.Api/Services/ResourceWatchEventHubController.cs +++ b/src/core/CloudStreams.Core.Api/Services/ResourceWatchEventHubController.cs @@ -26,14 +26,14 @@ namespace CloudStreams.Core.Api.Services; /// /// The service used to manage s /// The current 's -public class ResourceWatchEventHubController(IRepository resources, IHubContext hubContext) +public class ResourceWatchEventHubController(IResourceRepository resources, IHubContext hubContext) : BackgroundService { /// /// Gets the service used to manage s /// - protected IRepository Resources { get; } = resources; + protected IResourceRepository Resources { get; } = resources; /// /// Gets the current 's diff --git a/src/core/CloudStreams.Core.Application/CloudStreams.Core.Application.csproj b/src/core/CloudStreams.Core.Application/CloudStreams.Core.Application.csproj index 98aa46ea..8b9d7d0b 100644 --- a/src/core/CloudStreams.Core.Application/CloudStreams.Core.Application.csproj +++ b/src/core/CloudStreams.Core.Application/CloudStreams.Core.Application.csproj @@ -19,9 +19,9 @@ - - - + + + diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/CreateResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/CreateResourceCommand.cs index 2a93c4f5..7e8ba3ef 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/CreateResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/CreateResourceCommand.cs @@ -71,7 +71,7 @@ public CreateResourceCommand(IResource resource, string group, string version, s /// Represents the service used to handle s /// /// The service used to manage s -public class CreateResourceCommandHandler(IRepository repository) +public class CreateResourceCommandHandler(IResourceRepository repository) : ICommandHandler { diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/DeleteResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/DeleteResourceCommand.cs index 866197b0..ebc9066a 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/DeleteResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/DeleteResourceCommand.cs @@ -79,7 +79,7 @@ public DeleteResourceCommand(string group, string version, string plural, string /// Represents the service used to handle s /// /// The service used to manage s -public class DeleteResourceCommandHandler(IRepository repository) +public class DeleteResourceCommandHandler(IResourceRepository repository) : ICommandHandler { diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/CreateResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/CreateResourceCommand.cs index a252d5b3..99029a6d 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/CreateResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/CreateResourceCommand.cs @@ -44,7 +44,7 @@ public class CreateResourceCommand(TResource resource, bool dryRun) /// /// The type of to create /// The service used to manage s -public class CreateResourceCommandHandler(IRepository repository) +public class CreateResourceCommandHandler(IResourceRepository repository) : ICommandHandler, TResource> where TResource : class, IResource, new() { diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/DeleteResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/DeleteResourceCommand.cs index 7e018799..3ea87af4 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/DeleteResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/DeleteResourceCommand.cs @@ -58,7 +58,7 @@ public DeleteResourceCommand(string name, string? @namespace, bool dryRun) /// /// The type of to create /// The service used to manage s -public class DeleteResourceCommandHandler(IRepository repository) +public class DeleteResourceCommandHandler(IResourceRepository repository) : ICommandHandler, TResource> where TResource : class, IResource, new() { diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/PatchResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/PatchResourceCommand.cs index 9a9929e4..a0b4746d 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/PatchResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/PatchResourceCommand.cs @@ -72,7 +72,7 @@ public PatchResourceCommand(string name, string? @namespace, Patch patch, bool d /// /// The type of to patch /// The service used to manage s -public class PatchResourceCommandHandler(IRepository repository) +public class PatchResourceCommandHandler(IResourceRepository repository) : ICommandHandler, TResource> where TResource : class, IResource, new() { @@ -80,7 +80,7 @@ public class PatchResourceCommandHandler(IRepository repository) /// public virtual async Task> HandleAsync(PatchResourceCommand command, CancellationToken cancellationToken) { - var resource = await repository.PatchAsync(command.Patch, command.Name, command.Namespace, command.DryRun, cancellationToken).ConfigureAwait(false); + var resource = await repository.PatchAsync(command.Patch, command.Name, command.Namespace, null, command.DryRun, cancellationToken).ConfigureAwait(false); return this.Ok(resource); } diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/ReplaceResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/ReplaceResourceCommand.cs index dca62cd9..6b5a2723 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/ReplaceResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/Generic/ReplaceResourceCommand.cs @@ -45,7 +45,7 @@ public class ReplaceResourceCommand(TResource resource, bool dryRun) /// /// The type of to replace /// The service used to manage s -public class ReplaceResourceCommandHandler(IRepository repository) +public class ReplaceResourceCommandHandler(IResourceRepository repository) : ICommandHandler, TResource> where TResource : class, IResource, new() { diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/PatchResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/PatchResourceCommand.cs index 9a6ccb17..710b295a 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/PatchResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/PatchResourceCommand.cs @@ -91,14 +91,14 @@ public PatchResourceCommand(string group, string version, string plural, string /// Represents the service used to handle s /// /// The service used to manage s -public class PatchResourceCommandHandler(IRepository repository) +public class PatchResourceCommandHandler(IResourceRepository repository) : ICommandHandler { /// public virtual async Task> HandleAsync(PatchResourceCommand command, CancellationToken cancellationToken) { - var resource = await repository.PatchAsync(command.Patch, command.Group, command.Version, command.Plural, command.Name, command.Namespace, command.DryRun, cancellationToken).ConfigureAwait(false); + var resource = await repository.PatchAsync(command.Patch, command.Group, command.Version, command.Plural, command.Name, command.Namespace, null, command.DryRun, cancellationToken).ConfigureAwait(false); return this.Ok(resource); } diff --git a/src/core/CloudStreams.Core.Application/Commands/Resources/ReplaceResourceCommand.cs b/src/core/CloudStreams.Core.Application/Commands/Resources/ReplaceResourceCommand.cs index 073ce0b0..66533a6c 100644 --- a/src/core/CloudStreams.Core.Application/Commands/Resources/ReplaceResourceCommand.cs +++ b/src/core/CloudStreams.Core.Application/Commands/Resources/ReplaceResourceCommand.cs @@ -72,7 +72,7 @@ public ReplaceResourceCommand(string group, string version, string plural, IReso /// Represents the service used to handle s /// /// The service used to manage s -public class ReplaceResourceCommandHandler(IRepository repository) +public class ReplaceResourceCommandHandler(IResourceRepository repository) : ICommandHandler { diff --git a/src/core/CloudStreams.Core.Application/Queries/Gateways/CheckGatewayHealthQuery.cs b/src/core/CloudStreams.Core.Application/Queries/Gateways/CheckGatewayHealthQuery.cs index df304a35..64c0b65d 100644 --- a/src/core/CloudStreams.Core.Application/Queries/Gateways/CheckGatewayHealthQuery.cs +++ b/src/core/CloudStreams.Core.Application/Queries/Gateways/CheckGatewayHealthQuery.cs @@ -50,7 +50,7 @@ public CheckGatewayHealthQuery(string name) /// /// Represents the service used to handle instances /// -public class CheckGatewayHealthQueryHandler(IRepository repository, HttpClient httpClient, IJsonSerializer serializer) +public class CheckGatewayHealthQueryHandler(IResourceRepository repository, HttpClient httpClient, IJsonSerializer serializer) : IQueryHandler { diff --git a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceDefinitionQuery.cs b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceDefinitionQuery.cs index a1ac5fb4..a8634491 100644 --- a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceDefinitionQuery.cs +++ b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceDefinitionQuery.cs @@ -31,7 +31,7 @@ public class GetResourceDefinitionQuery /// /// The type of the to replace /// The service used to manage s -public class GetResourceDefinitionQueryHandler(IRepository repository) +public class GetResourceDefinitionQueryHandler(IResourceRepository repository) : IQueryHandler, IResourceDefinition> where TResource : class, IResource, new() { diff --git a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceQuery.cs b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceQuery.cs index 70feebf8..dbb49d15 100644 --- a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceQuery.cs +++ b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourceQuery.cs @@ -51,7 +51,7 @@ public GetResourceQuery(string name, string? @namespace) /// /// The type of the to replace /// The service used to manage s -public class GetResourceQueryHandler(IRepository repository) +public class GetResourceQueryHandler(IResourceRepository repository) : IQueryHandler, TResource> where TResource : class, IResource, new() { diff --git a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourcesQuery.cs b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourcesQuery.cs index 37594070..533bb837 100644 --- a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourcesQuery.cs +++ b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/GetResourcesQuery.cs @@ -43,7 +43,7 @@ public class GetResourcesQuery(string? @namespace, IEnumerable /// The type of to get /// The service used to manage s -public class GetResourcesQueryHandler(IRepository repository) +public class GetResourcesQueryHandler(IResourceRepository repository) : IQueryHandler, IAsyncEnumerable> where TResource : class, IResource, new() { diff --git a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/ListResourcesQuery.cs b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/ListResourcesQuery.cs index a32745cf..765bca98 100644 --- a/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/ListResourcesQuery.cs +++ b/src/core/CloudStreams.Core.Application/Queries/Resources/Generic/ListResourcesQuery.cs @@ -56,7 +56,7 @@ public class ListResourcesQuery(string? @namespace, IEnumerable - - - + + + diff --git a/src/dashboard/CloudStreams.Dashboard/CloudStreams.Dashboard.csproj b/src/dashboard/CloudStreams.Dashboard/CloudStreams.Dashboard.csproj index ca9f2339..ae8300b8 100644 --- a/src/dashboard/CloudStreams.Dashboard/CloudStreams.Dashboard.csproj +++ b/src/dashboard/CloudStreams.Dashboard/CloudStreams.Dashboard.csproj @@ -19,13 +19,13 @@ - + - - - - + + + + diff --git a/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Timeline.razor b/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Timeline.razor index 95cfb861..2d5f3e1e 100644 --- a/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Timeline.razor +++ b/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Timeline.razor @@ -44,7 +44,7 @@ {
- @cloudEvent.Time?.LocalDateTime.ToString("R") + @cloudEvent.Time?.LocalDateTime.ToString("R")
@@ -81,7 +81,7 @@ /// private DotNetObjectReference? dotnetReference = null; /// - /// Indicates whether or not the componenet has been disposed + /// Indicates whether or not the component has been disposed /// private bool disposed = false; /// diff --git a/src/dashboard/CloudStreams.Dashboard/Program.cs b/src/dashboard/CloudStreams.Dashboard/Program.cs index a724c63b..4cfd4079 100644 --- a/src/dashboard/CloudStreams.Dashboard/Program.cs +++ b/src/dashboard/CloudStreams.Dashboard/Program.cs @@ -17,12 +17,6 @@ using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Neuroglia.Serialization; -using Neuroglia.Serialization.Json.Converters; -using Neuroglia.Serialization.Json; -using System.Text.Json.Serialization; -using System.Text.Json; -using Microsoft.Extensions.Options; -using System.Text.Json.Nodes; var builder = WebAssemblyHostBuilder.CreateDefault(args); diff --git a/src/dashboard/CloudStreams.Dashboard/Services/EventDropsInterop.cs b/src/dashboard/CloudStreams.Dashboard/Services/EventDropsInterop.cs index 37dc3520..b8e41da6 100644 --- a/src/dashboard/CloudStreams.Dashboard/Services/EventDropsInterop.cs +++ b/src/dashboard/CloudStreams.Dashboard/Services/EventDropsInterop.cs @@ -20,22 +20,15 @@ namespace CloudStreams.Dashboard.Services; /// /// The service used to build a bridge with event drops /// -public class EventDropsInterop - : IAsyncDisposable +/// +/// Constructs a new +/// +/// The service used to interop with JS +public class EventDropsInterop(IJSRuntime jsRuntime) + : IAsyncDisposable { - /// - /// A reference to the js interop module - /// - private readonly Lazy> moduleTask; - /// - /// Constructs a new - /// - /// The service used to interop with JS - public EventDropsInterop(IJSRuntime jsRuntime) - { - moduleTask = new(() => jsRuntime.InvokeAsync("import", "./js/event-drops-interop.js").AsTask()); - } + readonly Lazy> moduleTask = new(() => jsRuntime.InvokeAsync("import", "./js/event-drops-interop.js").AsTask()); /// /// Renders a using event-drops @@ -45,6 +38,7 @@ public EventDropsInterop(IJSRuntime jsRuntime) /// The event-drops dataset /// The moment the timeline starts /// The moment the timeline starts> + /// A boolean indicating whether or not to keep the time range public async ValueTask RenderTimelineAsync(ElementReference domElement, DotNetObjectReference? dotnetReference, IEnumerable dataset, DateTimeOffset start, DateTimeOffset end, bool keepTimeRange) { var module = await moduleTask.Value; @@ -60,5 +54,7 @@ public async ValueTask DisposeAsync() await module.InvokeVoidAsync("dispose"); await module.DisposeAsync(); } + GC.SuppressFinalize(this); } + } diff --git a/src/gateway/CloudStreams.Gateway.Api/CloudStreams.Gateway.Api.csproj b/src/gateway/CloudStreams.Gateway.Api/CloudStreams.Gateway.Api.csproj index ae5c46ff..c5a514dc 100644 --- a/src/gateway/CloudStreams.Gateway.Api/CloudStreams.Gateway.Api.csproj +++ b/src/gateway/CloudStreams.Gateway.Api/CloudStreams.Gateway.Api.csproj @@ -25,12 +25,12 @@ - - - - - - + + + + + + diff --git a/src/gateway/CloudStreams.Gateway.Application/CloudStreams.Gateway.Application.csproj b/src/gateway/CloudStreams.Gateway.Application/CloudStreams.Gateway.Application.csproj index 7bd302a8..b6718139 100644 --- a/src/gateway/CloudStreams.Gateway.Application/CloudStreams.Gateway.Application.csproj +++ b/src/gateway/CloudStreams.Gateway.Application/CloudStreams.Gateway.Application.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/gateway/CloudStreams.Gateway.Application/Services/CloudEventAdmissionControl.cs b/src/gateway/CloudStreams.Gateway.Application/Services/CloudEventAdmissionControl.cs index 8d1af251..344b14a5 100644 --- a/src/gateway/CloudStreams.Gateway.Application/Services/CloudEventAdmissionControl.cs +++ b/src/gateway/CloudStreams.Gateway.Application/Services/CloudEventAdmissionControl.cs @@ -90,7 +90,7 @@ public class CloudEventAdmissionControl(IServiceProvider serviceProvider, ILogge /// /// Gets the service used to manage s /// - protected IRepository Resources => this.ServiceProvider.GetRequiredService(); + protected IResourceRepository Resources => this.ServiceProvider.GetRequiredService(); /// /// Gets the service used to evaluate runtime expressions