-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
335 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Sitko.Core.Tasks; | ||
using Sitko.Core.Tasks.Data.Entities; | ||
|
||
namespace MudBlazorUnited.Tasks.Demo; | ||
|
||
[Task("logging")] | ||
public record LoggingTask : MudBlazorBaseTask<LoggingTaskConfig, LoggingTaskResult>; | ||
|
||
public record LoggingTaskResult : BaseTaskResult; | ||
|
||
public record LoggingTaskConfig : BaseTaskConfig | ||
{ | ||
public Guid Id { get; set; } | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/Blazor/MudBlazorUnited/Tasks/Demo/LoggingTaskExecutor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Elastic.Apm.Api; | ||
using Sitko.Core.Repository; | ||
using Sitko.Core.Tasks.Execution; | ||
|
||
namespace MudBlazorUnited.Tasks.Demo; | ||
|
||
[TaskExecutor("Loggers", 10)] | ||
public class LoggingTaskExecutor : BaseTaskExecutor<LoggingTask, LoggingTaskConfig, LoggingTaskResult> | ||
{ | ||
public LoggingTaskExecutor(ILogger<LoggingTaskExecutor> logger, IServiceScopeFactory serviceScopeFactory, | ||
IRepository<LoggingTask, Guid> repository, ITracer? tracer = null) : base(logger, serviceScopeFactory, | ||
repository, tracer) | ||
{ | ||
} | ||
|
||
protected override Task<LoggingTaskResult> ExecuteAsync(LoggingTask task, CancellationToken cancellationToken) | ||
{ | ||
Logger.LogInformation("Run Logging Task: {Id}", task.Config.Id); | ||
return Task.FromResult(new LoggingTaskResult()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/Blazor/MudBlazorUnited/Tasks/Demo/LoggingTaskFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sitko.Core.Tasks.Scheduling; | ||
|
||
namespace MudBlazorUnited.Tasks.Demo; | ||
|
||
public class LoggingTaskFactory : IBaseTaskFactory<LoggingTask> | ||
{ | ||
public Task<LoggingTask[]> GetTasksAsync(CancellationToken cancellationToken) | ||
{ | ||
var tasks = new[] { new LoggingTask { Config = new() { Id = Guid.NewGuid() }, Result = new() } }; | ||
return Task.FromResult(tasks); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
apps/Blazor/MudBlazorUnited/Tasks/Migrations/20231018133432_Tasks.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
apps/Blazor/MudBlazorUnited/Tasks/Migrations/20231018133432_Tasks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
using MudBlazorUnited.Tasks.Demo; | ||
|
||
#nullable disable | ||
|
||
namespace MudBlazorUnited.Tasks.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class Tasks : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Tasks", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(type: "uuid", nullable: false), | ||
Config = table.Column<LoggingTaskConfig>(type: "jsonb", nullable: true), | ||
Result = table.Column<LoggingTaskResult>(type: "jsonb", nullable: true), | ||
DateAdded = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), | ||
DateUpdated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), | ||
TaskStatus = table.Column<int>(type: "integer", nullable: false), | ||
ExecuteDateStart = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), | ||
ExecuteDateEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), | ||
Type = table.Column<string>(type: "character varying(21)", maxLength: 21, nullable: false), | ||
ParentId = table.Column<Guid>(type: "uuid", nullable: true), | ||
UserId = table.Column<string>(type: "text", nullable: true), | ||
LastActivityDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Tasks", x => x.Id); | ||
}); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Tasks"); | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
apps/Blazor/MudBlazorUnited/Tasks/Migrations/MudBlazorTasksDbContextModelSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// <auto-generated /> | ||
using System; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
using MudBlazorUnited.Tasks; | ||
using MudBlazorUnited.Tasks.Demo; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; | ||
|
||
#nullable disable | ||
|
||
namespace MudBlazorUnited.Tasks.Migrations | ||
{ | ||
[DbContext(typeof(MudBlazorTasksDbContext))] | ||
partial class MudBlazorTasksDbContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "8.0.0-rc.2.23480.1") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 63); | ||
|
||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); | ||
|
||
modelBuilder.Entity("MudBlazorUnited.Tasks.MudBlazorBaseTask", b => | ||
{ | ||
b.Property<Guid>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("uuid"); | ||
|
||
b.Property<DateTimeOffset>("DateAdded") | ||
.HasColumnType("timestamp with time zone"); | ||
|
||
b.Property<DateTimeOffset>("DateUpdated") | ||
.HasColumnType("timestamp with time zone"); | ||
|
||
b.Property<DateTimeOffset?>("ExecuteDateEnd") | ||
.HasColumnType("timestamp with time zone"); | ||
|
||
b.Property<DateTimeOffset?>("ExecuteDateStart") | ||
.HasColumnType("timestamp with time zone"); | ||
|
||
b.Property<DateTimeOffset?>("LastActivityDate") | ||
.HasColumnType("timestamp with time zone"); | ||
|
||
b.Property<Guid?>("ParentId") | ||
.HasColumnType("uuid"); | ||
|
||
b.Property<int>("TaskStatus") | ||
.HasColumnType("integer"); | ||
|
||
b.Property<string>("Type") | ||
.IsRequired() | ||
.HasMaxLength(21) | ||
.HasColumnType("character varying(21)"); | ||
|
||
b.Property<string>("UserId") | ||
.HasColumnType("text"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("Tasks", (string)null); | ||
|
||
b.HasDiscriminator<string>("Type").HasValue("MudBlazorBaseTask"); | ||
|
||
b.UseTphMappingStrategy(); | ||
}); | ||
|
||
modelBuilder.Entity("MudBlazorUnited.Tasks.Demo.LoggingTask", b => | ||
{ | ||
b.HasBaseType("MudBlazorUnited.Tasks.MudBlazorBaseTask"); | ||
|
||
b.Property<LoggingTaskConfig>("Config") | ||
.IsRequired() | ||
.HasColumnType("jsonb") | ||
.HasColumnName("Config"); | ||
|
||
b.Property<LoggingTaskResult>("Result") | ||
.HasColumnType("jsonb") | ||
.HasColumnName("Result"); | ||
|
||
b.ToTable("Tasks", (string)null); | ||
|
||
b.HasDiscriminator().HasValue("LoggingTask"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sitko.Core.Tasks.Data.Entities; | ||
|
||
namespace MudBlazorUnited.Tasks; | ||
|
||
public abstract record MudBlazorBaseTask : BaseTask; | ||
|
||
public abstract record MudBlazorBaseTask<TConfig, TResult> : MudBlazorBaseTask, IBaseTask<TConfig, TResult> | ||
where TConfig : BaseTaskConfig, new() where TResult : BaseTaskResult | ||
{ | ||
public TConfig Config { get; set; } = default!; | ||
public TResult? Result { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Sitko.Core.Tasks.Data; | ||
|
||
namespace MudBlazorUnited.Tasks; | ||
|
||
public class MudBlazorTasksDbContext(DbContextOptions<MudBlazorTasksDbContext> options) : TasksDbContext<MudBlazorBaseTask>(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
{ | ||
"DetailedErrors": true, | ||
"Serilog":{ | ||
"Serilog": { | ||
"MinimumLevel": { | ||
"Default": "Information", | ||
"Override": { | ||
"Sitko.Core.Apps.Blazor.Forms": "Debug", | ||
"Sitko.Core.Repository": "Debug" | ||
} | ||
} | ||
}, | ||
"Kafka": { | ||
"Brokers": [ | ||
"127.0.0.1:9092" | ||
], | ||
"Tasks": { | ||
"MudBlazorBaseTask": { | ||
"TasksTopic": "MudBlazorTasks" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters