Skip to content

Commit

Permalink
updated libs and added storage helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofx committed Jul 17, 2024
1 parent 0ed2857 commit 23ae18d
Show file tree
Hide file tree
Showing 30 changed files with 579 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<ProjectReference Include="..\..\..\..\src\Miru.PageTesting\Miru.PageTesting.csproj" />
<ProjectReference Include="..\..\..\..\src\Miru.PageTesting.Chrome\Miru.PageTesting.Chrome.csproj" />

<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />

<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="121.0.6167.8500" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="126.0.6478.18200" />
</ItemGroup>

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

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />

<ProjectReference Include="..\..\..\..\src\Miru.Testing\Miru.Testing.csproj" />
<ProjectReference Include="..\..\..\..\src\Miru.Fabrication\Miru.Fabrication.csproj" />
Expand Down
16 changes: 4 additions & 12 deletions samples/Playground/src/Playground/Features/Jobs/JobNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,14 @@ public class NameNewJob : IRequest
public string Name { get; set; }
}

public class JobHandler : IRequestHandler<NameNewJob>
public class JobHandler(ILogger<JobHandler> logger, PlaygroundDbContext db)
: IRequestHandler<NameNewJob>
{
private readonly ILogger<JobHandler> _logger;
private readonly PlaygroundDbContext _db;

public JobHandler(ILogger<JobHandler> logger, PlaygroundDbContext db)
{
_logger = logger;
_db = db;
}

public async Task<Unit> Handle(NameNewJob request, CancellationToken cancellationToken)
{
_db.Users.ToList();
db.Users.ToList();

_logger.LogInformation("From ILogger {Name}", request.Name);
logger.LogInformation("From ILogger {Name}", request.Name);

App.Log.Information("Name is {Name}", request.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<ProjectReference Include="..\..\..\..\src\Miru.PageTesting.Firefox\Miru.PageTesting.Firefox.csproj" />
<ProjectReference Include="..\..\..\..\src\Miru.PageTesting\Miru.PageTesting.csproj" />

<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />

<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.34.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />

<ProjectReference Include="..\..\..\..\src\Miru.Testing\Miru.Testing.csproj" />
<ProjectReference Include="..\..\..\..\src\Miru.Fabrication\Miru.Fabrication.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions src/Miru.Core/Miru.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<ItemGroup>
<PackageReference Include="Baseline" Version="4.1.0" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Scriban" Version="5.9.1" />
<PackageReference Include="Scriban" Version="5.10.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
<PackageReference Include="YamlDotNet" Version="15.1.1" />
<PackageReference Include="YamlDotNet" Version="16.0.0" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/Miru.Core/Templates/Corpo.Skeleton.PageTests.csproj.stub
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<PackageReference Include="Miru.PageTesting" Version="{{ MiruVersion }}" />
<PackageReference Include="Miru.PageTesting.Chrome" Version="{{ MiruVersion }}" />

<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />

<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="121.0.6167.8500" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="126.0.6478.18200" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Miru.Core/Templates/Corpo.Skeleton.Tests.csproj.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />

<PackageReference Include="Miru.Testing" Version="{{ MiruVersion }}" />
<PackageReference Include="Miru.Fabrication" Version="{{ MiruVersion }}" />
Expand Down
12 changes: 5 additions & 7 deletions src/Miru.Core/Yml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,16 @@ public static string ToYml<T>(T value) =>
public static T FromYml<T>(string content) =>
Deserializer.Value.Deserialize<T>(content);

public class FilterPropertiesInspector : TypeInspectorSkeleton
public class FilterPropertiesInspector(ITypeInspector innerTypeDescriptor) : TypeInspectorSkeleton
{
private readonly ITypeInspector _innerTypeDescriptor;
public override string GetEnumName(Type enumType, string name) =>
innerTypeDescriptor.GetEnumName(enumType, name);

public FilterPropertiesInspector(ITypeInspector innerTypeDescriptor)
{
_innerTypeDescriptor = innerTypeDescriptor;
}
public override string GetEnumValue(object enumValue) => innerTypeDescriptor.GetEnumValue(enumValue);

public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object container)
{
var properties = _innerTypeDescriptor.GetProperties(type, container)
var properties = innerTypeDescriptor.GetProperties(type, container)
.Where(p => !p.Name.ContainsNoCase("password"))
.Where(p => !(p.Name.ContainsNoCase("body") && type.FullName.Equals("Miru.Mailing.Email")));

Expand Down
2 changes: 1 addition & 1 deletion src/Miru.Fabrication/Miru.Fabrication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="Bogus" Version="35.4.0" />
<PackageReference Include="Bogus" Version="35.5.1" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Miru.PageTesting.Chrome/Miru.PageTesting.Chrome.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="121.0.6167.8500" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="126.0.6478.18200" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Miru.PageTesting/Miru.PageTesting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Selenium.WebDriver" Version="4.17.0" />
<PackageReference Include="Selenium.Support" Version="4.17.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.22.0" />
<PackageReference Include="Selenium.Support" Version="4.22.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Miru.Postgres/Miru.Postgres.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Respawn" Version="6.2.1" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/Miru.SqlServer/Miru.SqlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Hangfire.SqlServer" Version="1.8.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" />
<PackageReference Include="Hangfire.SqlServer" Version="1.8.14" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Miru.Sqlite/Miru.Sqlite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<ItemGroup>
<PackageReference Include="Hangfire.LiteDB" Version="0.4.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
<PackageReference Include="Hangfire.Storage.SQLite" Version="0.4.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" />
<PackageReference Include="Hangfire.Storage.SQLite" Version="0.4.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Miru.Storage.Ftp/Miru.Storage.Ftp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentFTP" Version="49.0.2" />
<PackageReference Include="FluentFTP" Version="50.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/Miru.Testing/Miru.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnitLite" Version="4.0.1" />
<PackageReference Include="Hangfire.MemoryStorage" Version="1.8.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.1" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnitLite" Version="4.1.0" />
<PackageReference Include="Hangfire.MemoryStorage" Version="1.8.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.7" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.7" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Respawn" Version="6.2.1" />
<PackageReference Include="Shouldly" Version="4.2.1" />
Expand Down
4 changes: 2 additions & 2 deletions src/Miru.Testing/StorageTestServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ public static void ShouldNotContain(this MiruPath fileName, params string[] line
}
}

public static MiruPath MakeFake(this MiruPath path)
public static MiruPath MakeFake(this MiruPath path, int letters = 16)
{
path.Dir().EnsureDirExist();

File.WriteAllText(path, new Faker().Lorem.Sentence());
File.WriteAllText(path, new Faker().Lorem.Letter(letters));

return path;
}
Expand Down
30 changes: 15 additions & 15 deletions src/Miru/Miru.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
<ItemGroup>

<!-- Core -->
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
<PackageReference Include="Scrutor" Version="4.2.2" />
<PackageReference Include="Ardalis.SmartEnum" Version="8.0.0" />
<PackageReference Include="Ardalis.SmartEnum.EFCore" Version="8.0.0" />

<!-- Data -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.1" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="8.102.1" />
<PackageReference Include="FluentMigrator" Version="5.0.0" />
<PackageReference Include="FluentMigrator.Runner" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.7" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="8.103.0" />
<PackageReference Include="FluentMigrator" Version="5.2.0" />
<PackageReference Include="FluentMigrator.Runner" Version="5.2.0" />

<!-- Features -->
<PackageReference Include="MediatR" Version="11.1.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.2" />

<!-- View -->
<PackageReference Include="Vereyon.Web.FlashMessage" Version="3.0.0" />
Expand All @@ -39,18 +39,18 @@
<PackageReference Include="MimeTypeMapOfficial" Version="1.0.17" />

<!-- Logging -->
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />

<!-- Queuing -->
<PackageReference Include="Hangfire.Core" Version="1.8.9" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.9" />
<PackageReference Include="Hangfire.Core" Version="1.8.14" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" />
<PackageReference Include="Hangfire.Console.Extensions.Serilog" Version="2.0.0" />

<!-- Userfy -->
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.7" />

<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />

Expand Down
61 changes: 61 additions & 0 deletions src/Miru/Queuing/AppQueueRunConsolable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Collections.Generic;
using System.CommandLine;
using System.Linq;
using Hangfire;
using Miru.Consolables;

namespace Miru.Queuing;

// TODO: add automated tests
public class AppQueueRunConsolable : Consolable
{
public AppQueueRunConsolable() : base("app.queue.run", "Run queue")
{
Add(new Option<string[]>(["--queues", "--queue", "-q"])
{
AllowMultipleArgumentsPerToken = true
});
}

public class ConsolableHandler(IAppWarmup appWarmup, JobStorage jobStorage)
: IConsolableHandler
{
public string[] Queues { get; set; } = { "default:20" };

public async Task Execute()
{
appWarmup.InitiateServices();

// miru app.queue.run --queues default:15 default,exports:5 scheduled:1
var servers = new List<BackgroundJobServer>();

foreach (var queue in Queues)
{
var split = queue.Split(':');
var queueNames = split[0].Split(',').ToArray();
var workers = split[1];

var options = new BackgroundJobServerOptions
{
Queues = queueNames,
WorkerCount = workers.ToInt()
};

Console2.WhiteLine($"Adding a queue processor for {split[0]} queues with {workers} workers");

servers.Add(new BackgroundJobServer(options, jobStorage));
}

var tasks = new List<Task>();

foreach (var server in servers)
tasks.Add(server.WaitForShutdownAsync(default));

Console2.GreenLine("Queues are running");

Task.WaitAll(tasks.ToArray());

await Task.CompletedTask;
}
}
}
6 changes: 6 additions & 0 deletions src/Miru/Queuing/IAppWarmup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Miru.Queuing;

public interface IAppWarmup
{
void InitiateServices();
}
8 changes: 8 additions & 0 deletions src/Miru/Queuing/NullAppWarmup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Miru.Queuing;

public class NullAppWarmup : IAppWarmup
{
public void InitiateServices()
{
}
}
Loading

0 comments on commit 23ae18d

Please sign in to comment.