feat(cqrs): migrate Events, Agents, Assignments, Discovery, Others to CQRS
- Events: CRUD commands/queries + EventCreatedNotification for SignalR - Agents: Register (with API key gen), Heartbeat, queries - Assignments: Assign, Failover, Release commands + queries - Discovery: 10 handlers delegating to existing probes/services - Groups/Persons/Settings/Audit/Stats: full CQRS for remaining domains - Extend IApplicationDbContext with all DbSets
This commit is contained in:
1 parent
11f7fd8d20
commit
c1b3b3d3b4
74 files changed
+1981
-2
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
using Heimdall.Application.Common;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Heimdall.Application.Settings.Queries.GetEffectiveAgentConfig;
|
||||
|
||||
public record GetEffectiveAgentConfigQuery(Guid AgentId) : IRequest<ServiceResult<Dictionary<string, string>>>;
|
||||
|
||||
public class GetEffectiveAgentConfigQueryHandler
|
||||
: IRequestHandler<GetEffectiveAgentConfigQuery, ServiceResult<Dictionary<string, string>>>
|
||||
{
|
||||
private readonly IApplicationDbContext _db;
|
||||
|
||||
public GetEffectiveAgentConfigQueryHandler(IApplicationDbContext db) => _db = db;
|
||||
|
||||
public async Task<ServiceResult<Dictionary<string, string>>> Handle(
|
||||
GetEffectiveAgentConfigQuery request, CancellationToken ct)
|
||||
{
|
||||
var appSettings = await _db.AppSettings.ToListAsync(ct);
|
||||
var config = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
|
||||
foreach (var s in appSettings)
|
||||
config[s.Key] = s.Value;
|
||||
|
||||
var agentSettings = await _db.AgentSettings
|
||||
.Where(s => s.AgentId == request.AgentId)
|
||||
.ToListAsync(ct);
|
||||
|
||||
foreach (var s in agentSettings)
|
||||
config[s.Key] = s.Value;
|
||||
|
||||
return ServiceResult<Dictionary<string, string>>.Success(config);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user