Skip to content

Updated solution packages #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions deployments/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.9.6" />
<PackageReference Include="Neuroglia.Plugins" Version="4.9.6" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.9.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.14.1" />
<PackageReference Include="Neuroglia.Plugins" Version="4.14.1" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.14.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.7.3" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/broker/CloudStreams.Broker.Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.62.0" />
<PackageReference Include="Neuroglia.Data.Expressions.Abstractions" Version="4.9.6" />
<PackageReference Include="Polly" Version="8.3.1" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="Grpc.Core.Api" Version="2.65.0" />
<PackageReference Include="Neuroglia.Data.Expressions.Abstractions" Version="4.14.1" />
<PackageReference Include="Polly" Version="8.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class SubscriptionHandler
/// <param name="cloudEventValidators">An <see cref="IEnumerable{T}"/> containing registered <see cref="CloudEvent"/> <see cref="IValidator"/>s</param>
/// <param name="httpClient">The service used to perform HTTP requests</param>
/// <param name="subscription">The <see cref="Core.Resources.Subscription"/> to dispatch <see cref="CloudEvent"/>s to</param>
public SubscriptionHandler(ILoggerFactory loggerFactory, IHostApplicationLifetime hostApplicationLifetime, IJsonSerializer serializer, ICloudEventStore cloudEventStore, IRepository resourceRepository, IResourceController<Subscription> subscriptionController,
public SubscriptionHandler(ILoggerFactory loggerFactory, IHostApplicationLifetime hostApplicationLifetime, IJsonSerializer serializer, ICloudEventStore cloudEventStore, IResourceRepository resourceRepository, IResourceController<Subscription> subscriptionController,
IResourceMonitor<Core.Resources.Broker> broker, IExpressionEvaluator expressionEvaluator, IEnumerable<IValidator<CloudEvent>> cloudEventValidators, HttpClient httpClient, Subscription subscription)
{
this.Logger = loggerFactory.CreateLogger(this.GetType());
Expand Down Expand Up @@ -85,7 +85,7 @@ public SubscriptionHandler(ILoggerFactory loggerFactory, IHostApplicationLifetim
/// <summary>
/// Gets the service used to manage <see cref="IResource"/>s
/// </summary>
protected IRepository ResourceRepository { get; }
protected IResourceRepository ResourceRepository { get; }

/// <summary>
/// Gets the service used to control <see cref="Core.Resources.Subscription"/> resources
Expand Down Expand Up @@ -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<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false);
await this.ResourceRepository.PatchStatusAsync<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -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<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false);
await this.ResourceRepository.PatchStatusAsync<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -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<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false);
await this.ResourceRepository.PatchStatusAsync<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false);
return;
}
await this.CancelSynchronizationLoopAsync().ConfigureAwait(false);
Expand Down Expand Up @@ -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<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), false, this.CancellationToken).ConfigureAwait(false);
await this.ResourceRepository.PatchStatusAsync<Subscription>(new Patch(PatchType.JsonPatch, patch), resource.GetName(), resource.GetNamespace(), null, false, this.CancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace CloudStreams.Broker.Application.Services;
/// <param name="controllerOptions">The service used to access the current <see cref="IOptions{TOptions}"/></param>
/// <param name="repository">The service used to manage <see cref="IResource"/>s</param>
/// <param name="brokerOptions">The service used to access the current <see cref="Configuration.BrokerOptions"/></param>
public class SubscriptionManager(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions<ResourceControllerOptions<Subscription>> controllerOptions, IRepository repository, IOptions<BrokerOptions> brokerOptions)
public class SubscriptionManager(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions<ResourceControllerOptions<Subscription>> controllerOptions, IResourceRepository repository, IOptions<BrokerOptions> brokerOptions)
: ResourceController<Subscription>(loggerFactory, controllerOptions, repository)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.4" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.8" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 13 additions & 13 deletions src/core/CloudStreams.Core.Api/CloudStreams.Core.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.4" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.9.6" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.9.6" />
<PackageReference Include="Neuroglia.Plugins" Version="4.9.6" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.9.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.8" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.14.1" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.14.1" />
<PackageReference Include="Neuroglia.Plugins" Version="4.14.1" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.14.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.7.3" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/core/CloudStreams.Core.Api/Services/BrokerHealthMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace CloudStreams.Core.Api.Services;
/// <param name="repository">The service used to manage resources</param>
/// <param name="monitor">The service used to monitor the handled <see cref="Resources.Broker"/></param>
/// <param name="httpClient">The service used to perform HTTP requests</param>
public class BrokerHealthMonitor(ILogger<BrokerHealthMonitor> logger, IJsonSerializer serializer, IRepository repository, IResourceMonitor<Broker> monitor, HttpClient httpClient)
public class BrokerHealthMonitor(ILogger<BrokerHealthMonitor> logger, IJsonSerializer serializer, IResourceRepository repository, IResourceMonitor<Broker> monitor, HttpClient httpClient)
: IHostedService, IDisposable, IAsyncDisposable
{

Expand All @@ -47,7 +47,7 @@ public class BrokerHealthMonitor(ILogger<BrokerHealthMonitor> logger, IJsonSeria
/// <summary>
/// Gets the service used to manage resources
/// </summary>
protected IRepository Repository { get; } = repository;
protected IResourceRepository Repository { get; } = repository;

/// <summary>
/// Gets the service used to monitor the handled <see cref="Resources.Broker"/>
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}

/// <summary>
/// Handles ticks of the <see cref="HealthCheckTimer"/>
/// </summary>
/// <param name="state">The timer's async state</param>
protected virtual async void OnHealthCheckIntervalEllapsedAsync(object? state)
protected virtual async void OnHealthCheckIntervalElapsedAsync(object? state)
{
try
{
Expand Down Expand Up @@ -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)
Expand All @@ -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<Broker>(patch, this.Broker.GetName(), this.Broker.GetNamespace(), false, this.CancellationTokenSource!.Token).ConfigureAwait(false);
await this.Repository.PatchStatusAsync<Broker>(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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace CloudStreams.Core.Api.Services;
/// Represents a <see cref="ResourceController{TResource}"/> used to control <see cref="Broker"/>s
/// </summary>
/// <inheritdoc/>
public class BrokerResourceController(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions<ResourceControllerOptions<Broker>> controllerOptions, IRepository repository)
public class BrokerResourceController(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IOptions<ResourceControllerOptions<Broker>> controllerOptions, IResourceRepository repository)
: ResourceController<Broker>(loggerFactory, controllerOptions, repository)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public CloudStreamsApplicationBuilder(ConfigurationManager configuration, IHostE
this.Services.AddHostedService<Application.Services.DatabaseInitializer>();
this.Services.AddSingleton<IAdmissionControl, AdmissionControl>();
this.Services.AddSingleton<IVersionControl, VersionControl>();
this.Services.AddSingleton<IRepository, Repository>();
this.Services.AddSingleton<IResourceRepository, ResourceRepository>();
this.Services.AddSingleton<IPatchHandler, JsonMergePatchHandler>();
this.Services.AddSingleton<IPatchHandler, JsonPatchHandler>();
this.Services.AddSingleton<IPatchHandler, JsonStrategicMergePatchHandler>();
Expand Down
Loading
Loading