Skip to content

Commit

Permalink
update net8
Browse files Browse the repository at this point in the history
  • Loading branch information
suraciii committed Nov 30, 2023
1 parent 20a7170 commit 41fdbd2
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 150 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<VersionPrefix>0.1.0</VersionPrefix>
<VersionPrefix>1.0.0</VersionPrefix>
<RepositoryUrl>https://github.com/DCArea/Fabron</RepositoryUrl>
</PropertyGroup>

Expand Down
51 changes: 25 additions & 26 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<PropertyGroup>
<OrleansVersion>7.2.1</OrleansVersion>
<MExVersion>7.0.0</MExVersion>
<OrleansVersion>7.2.3</OrleansVersion>
<MExVersion>8.0.0</MExVersion>
<DCAExtensionsVersion>0.0.1-alpha4.1</DCAExtensionsVersion>
<OtelVersion>1.7.0-rc.1</OtelVersion>
<OtelExtVersion>1.6.0-beta.3</OtelExtVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.2.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="DCA.DotNet.Extensions.OpenTelemetry.AspNetCore" Version="0.1.0-alpha1.0" />
<PackageVersion Include="DCA.DotNet.Extensions.Logging" Version="$(DCAExtensionsVersion)" />
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.2.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="$(MExVersion)" />
<PackageVersion Include="InstrumentAggregators" Version="0.1.0-rc1.1" />
<PackageVersion Include="AspNetCore.Authentication.ApiKey" Version="7.0.0" />
<PackageVersion Include="Cronos" Version="0.7.1" />
<PackageVersion Include="Npgsql" Version="7.0.4" />
<PackageVersion Include="Npgsql.OpenTelemetry" Version="7.0.4" />
<PackageVersion Include="OpenTelemetry" Version="1.6.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.6.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.6.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.0-beta.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.5.0-beta.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.5.0-beta.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.6.0-alpha.1" />
<PackageVersion Include="Npgsql" Version="8.0.0" />
<PackageVersion Include="Npgsql.OpenTelemetry" Version="8.0.0" />
<PackageVersion Include="OpenTelemetry" Version="$(OtelVersion)" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="$(OtelVersion)" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="$(OtelVersion)" />
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="$(OtelVersion)" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="$(OtelVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="$(OtelExtVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="$(OtelExtVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="$(OtelExtVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(MExVersion)" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="$(MExVersion)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(MExVersion)" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="$(MExVersion)" />
<PackageVersion Include="Microsoft.Orleans.SDK" Version="$(OrleansVersion)" />
Expand All @@ -41,19 +40,19 @@
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.6" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.10" />
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="Moq.Contrib.HttpClient" Version="1.4.0" />
<PackageVersion Include="FakeItEasy" Version="7.4.0" />
<PackageVersion Include="FluentAssertions" Version="6.11.0" />
<PackageVersion Include="FakeItEasy" Version="8.0.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.9" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="skwas.MockHttp" Version="3.0.1" />
<PackageVersion Include="skwas.MockHttp.Json" Version="3.0.1" />
<PackageVersion Include="xunit" Version="2.5.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
<PackageVersion Include="xunit" Version="2.6.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "7.0.400"
"version": "8.0.100"
}
}
5 changes: 2 additions & 3 deletions src/Fabron.Core/Diagnostics/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Fabron.Diagnostics;

#pragma warning disable IDE0052 // Remove unread private members
internal sealed class Telemetry
{
public const string TelemetryName = "Fabron";
Expand All @@ -19,7 +18,7 @@ internal sealed class Telemetry

public static HistogramAggregator TimerDispatchTardiness = new(
new(),
new(Buckets: new[] { 0L, 1L, 5L, 50L, 1_000L, 5_000L, 60_000L }));
new(Buckets: [0L, 1L, 5L, 50L, 1_000L, 5_000L, 60_000L]));
private static readonly ObservableCounter<long> timerDispatchTardinessCount
= s_meter.CreateObservableCounter("fabron-timer-dispatch-tardiness-count", TimerDispatchTardiness.CollectCount);
private static readonly ObservableCounter<long> timerDispatchTardinessSum
Expand All @@ -33,7 +32,7 @@ private static readonly ObservableCounter<long> timerDispatchTardinessBuckets

public static HistogramAggregator FabronTimerDispatchDuration = new(
new(),
new(Buckets: new[] { 0L, 1L, 5L, 50L, 1_000L, 5_000L, 10_000L }));
new(Buckets: [0L, 1L, 5L, 50L, 1_000L, 5_000L, 10_000L]));
private static readonly ObservableCounter<long> timerDispatchDurationCount
= s_meter.CreateObservableCounter("fabron-timer-dispatch-duration-count", FabronTimerDispatchDuration.CollectCount);
private static readonly ObservableCounter<long> timerDispatchDurationSum
Expand Down
2 changes: 1 addition & 1 deletion src/Fabron.Core/Dispatching/SimpleFireRouterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class SimpleFireRouterOptions
{
public List<SimpleFireRouter.Route> Routes { get; init; } = new();
public List<SimpleFireRouter.Route> Routes { get; init; } = [];
}
2 changes: 1 addition & 1 deletion src/Fabron.Core/Schedulers/CronScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<CronTimer> Schedule(
CreationTimestamp: utcNow,
DeletionTimestamp: null,
Owner: owner,
Extensions: extensions ?? new()),
Extensions: extensions ?? []),
Data: data,
Spec: spec
);
Expand Down
2 changes: 1 addition & 1 deletion src/Fabron.Core/Schedulers/GenericScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<GenericTimer> Schedule(
CreationTimestamp: utcNow,
DeletionTimestamp: null,
Owner: owner,
Extensions: extensions ?? new()),
Extensions: extensions ?? []),
Data: data,
Spec: spec
);
Expand Down
2 changes: 1 addition & 1 deletion src/Fabron.Core/Schedulers/PeriodicScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task<PeriodicTimer> Schedule(
CreationTimestamp: utcNow,
DeletionTimestamp: null,
Owner: owner,
Extensions: extensions ?? new()),
Extensions: extensions ?? []),
Data: data,
Spec: spec
);
Expand Down
2 changes: 1 addition & 1 deletion src/Fabron.Core/Stores/InMemoryStateStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class InMemoryPeriodicTimerStore : InMemoryStateStore<PeriodicTimer>, IPe
public abstract class InMemoryStateStore<TState> : IStateStore<TState>
where TState : IDistributedTimer
{
private readonly Dictionary<string, StateEntry<TState>> _states = new();
private readonly Dictionary<string, StateEntry<TState>> _states = [];

public Task<StateEntry<TState>?> GetAsync(string key)
{
Expand Down
1 change: 0 additions & 1 deletion src/FabronService/FabronService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNetCore.Authentication.ApiKey" />
<PackageReference Include="Npgsql" />
<PackageReference Include="Npgsql.OpenTelemetry" />
<PackageReference Include="Microsoft.Orleans.Sdk" />
Expand Down
54 changes: 0 additions & 54 deletions src/FabronService/Hosting/SecurityConfigureExtensions.cs

This file was deleted.

6 changes: 2 additions & 4 deletions src/FabronService/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using FabronService.Hosting;
using FabronService.Hosting;

var builder = WebApplication.CreateBuilder(args);
builder.ConfigureFabron();
builder.ConfigureSecurity();
builder.ConfigureOpenTelemetry();
builder.ConfigureSwagger();
builder.Services.AddHealthChecks();
Expand All @@ -11,9 +10,8 @@
app.MapHealthChecks("/health").AllowAnonymous();
app.UseOpenTelemetry();
app.UseConfiguredSwagger();
app.UseSecurity();
app.MapRoutes();

app.Run();

public partial class Program { }
public partial class Program { }
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal CronFakes PrepareGrain(string? schedule = null, [CallerMemberName] stri
CreationTimestamp: DateTimeOffset.UtcNow,
DeletionTimestamp: null,
Owner: null,
Extensions: new()
Extensions: []
),
Data: JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
Spec: new CronTimerSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new CronTimerSpec("0 0 0 1 6 *"),
null,
new());
[]);

var reminder = reminderRegistry.Reminders.Single().Value;
reminder.DueTime.Should().Be(TimeSpan.FromDays(49));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Fabron.Core.Test.SchedulerTests
{
public class FakeReminderRegistry : IReminderRegistry
{
public Dictionary<string, FakeGrainReminder> Reminders { get; } = new();
public Dictionary<string, FakeGrainReminder> Reminders { get; } = [];

public static Task Fire(IRemindable remindable, string reminderName, TickStatus tickerStatus) => remindable.ReceiveReminder(reminderName, tickerStatus);

Expand Down
2 changes: 1 addition & 1 deletion test/Fabron.Core.Test/SchedulerTests/FakeSystemClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class FakeSystemClock : ISystemClock

public class FakeFireDispatcher : IFireDispatcher
{
public List<FireEnvelop> Envelops { get; } = new List<FireEnvelop>();
public List<FireEnvelop> Envelops { get; } = [];
public Task DispatchAsync(FireEnvelop envelop)
{
Envelops.Add(envelop);
Expand Down
2 changes: 1 addition & 1 deletion test/Fabron.Core.Test/SchedulerTests/FakeTimerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Fabron.Core.Test.SchedulerTests
{
public class FakeTimerRegistry : ITimerRegistry
{
public List<FakeTimer> Timers { get; } = new();
public List<FakeTimer> Timers { get; } = [];
public IDisposable RegisterTimer(IGrainContext grainContext, Func<object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period)
{
var timer = new FakeTimer(asyncCallback, state, dueTime, period);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private GenericFakes PrepareGrain(DateTimeOffset? schedule = null, [CallerMember
CreationTimestamp: DateTimeOffset.UtcNow,
DeletionTimestamp: null,
Owner: null,
Extensions: new()
Extensions: []
),
Data: JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
Spec: new GenericTimerSpec
Expand Down Expand Up @@ -72,7 +72,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new GenericTimerSpec(tickTime),
null,
new());
[]);

var reminder = reminderRegistry.Reminders.Single().Value;
reminder.DueTime.Should().Be(tickTime - clock.UtcNow);
Expand All @@ -92,7 +92,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new GenericTimerSpec(tickTime),
null,
new());
[]);

reminderRegistry.Reminders.Single().Value.DueTime.Should().Be(tickTime - clock.UtcNow);
var state = await scheduler.GetState();
Expand All @@ -111,7 +111,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new GenericTimerSpec(tickTime),
null,
new());
[]);

var reminder = reminderRegistry.Reminders.Single().Value;
reminder.DueTime.Should().Be(TimeSpan.FromDays(49));
Expand All @@ -130,7 +130,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new GenericTimerSpec(tickTime),
null,
new());
[]);

var reminderDueTime = clock.UtcNow.Add(reminderRegistry.Reminders.Single().Value.DueTime);
clock.UtcNow = reminderDueTime.AddMilliseconds(100);
Expand All @@ -152,7 +152,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new GenericTimerSpec(tickTime),
null,
new());
[]);
var reminderDueTime = clock.UtcNow.Add(reminderRegistry.Reminders.Single().Value.DueTime);
clock.UtcNow = reminderDueTime.AddMilliseconds(100);
await FakeReminderRegistry.Fire(scheduler, Names.TickerReminder, new TickStatus(reminderDueTime.UtcDateTime, Timeout.InfiniteTimeSpan, clock.UtcNow.UtcDateTime));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private PeriodicFakes PrepareGrain(TimeSpan? schedule = null, [CallerMemberName]
CreationTimestamp: DateTimeOffset.UtcNow,
DeletionTimestamp: null,
Owner: null,
Extensions: new()
Extensions: []
),
Data: JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
Spec: new PeriodicTimerSpec
Expand Down Expand Up @@ -72,7 +72,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new(TimeSpan.FromSeconds(10)),
null,
new());
[]);

timerRegistry.Timers.Count.Should().Be(6);
timerRegistry.Timers[0].DueTime.Should().Be(TimeSpan.Zero);
Expand Down Expand Up @@ -101,7 +101,7 @@ await scheduler.Schedule(
JsonSerializer.Serialize(new { data = new { foo = "bar" } }),
new(TimeSpan.FromMinutes(1)),
null,
new());
[]);

timerRegistry.Timers.Count.Should().Be(1);
timerRegistry.Timers[0].DueTime.Should().Be(TimeSpan.Zero);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Fabron.Schedulers;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using Orleans.Timers;
using Xunit;
using Xunit.Abstractions;

namespace Fabron.FunctionalTests.PeriodicTimerTests;

#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
public class PeriodicStopTests(DefaultClusterFixture fixture, ITestOutputHelper output) : TestBase(fixture, output)
{
[Fact]
Expand Down
2 changes: 1 addition & 1 deletion test/Fabron.FunctionalTests/TestSiloConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Configure(ISiloBuilder siloBuilder)

public class TestFireDispatcher : IFireDispatcher
{
public ConcurrentBag<FireEnvelop> Fires { get; } = new();
public ConcurrentBag<FireEnvelop> Fires { get; } = [];
public Task DispatchAsync(FireEnvelop envelop)
{
Fires.Add(envelop);
Expand Down
Loading

0 comments on commit 41fdbd2

Please sign in to comment.