feat(assign): implement camera-to-agent assignment with failover and strategy support
Multi-agent sites need automatic camera distribution, failover when an agent goes offline, and rebalancing when new agents join. Adds CameraAssignment entity with audit trail, 4 assignment strategies (RoundRobin, GpuPriority, LeastCameras, Failover), a Hangfire failover job that checks for stale heartbeats every 60s, a discovery coordinator for leader election, 6 REST endpoints, EF migration, and DI registration.
This commit is contained in:
1 parent
2152fca3c6
commit
159da2ca26
13 files changed
+2248
No files matched your search
@@ -29,6 +29,9 @@ public class AppDbContext : IdentityDbContext<AppUser, AppRole, Guid>
|
||||
public DbSet<CameraDiscoveryResult> CameraDiscoveryResults => Set<CameraDiscoveryResult>();
|
||||
public DbSet<DiscoveredStreamUrl> DiscoveredStreams => Set<DiscoveredStreamUrl>();
|
||||
|
||||
// Assignment entities
|
||||
public DbSet<CameraAssignment> CameraAssignments => Set<CameraAssignment>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using Heimdall.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Heimdall.Infrastructure.Data.Configurations;
|
||||
|
||||
public class CameraAssignmentConfiguration : IEntityTypeConfiguration<CameraAssignment>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<CameraAssignment> builder)
|
||||
{
|
||||
builder.ToTable("camera_assignments");
|
||||
|
||||
builder.HasKey(a => a.Id);
|
||||
|
||||
builder.Property(a => a.Reason)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired()
|
||||
.IsUnicode(false);
|
||||
|
||||
// Index for active assignment lookups by camera
|
||||
builder.HasIndex(a => new { a.CameraId, a.ReleasedAt })
|
||||
.HasFilter("\"ReleasedAt\" IS NULL")
|
||||
.IsUnique();
|
||||
|
||||
// Index for agent workload queries
|
||||
builder.HasIndex(a => new { a.AgentId, a.ReleasedAt })
|
||||
.HasFilter("\"ReleasedAt\" IS NULL");
|
||||
|
||||
builder.HasIndex(a => a.AssignedAt);
|
||||
|
||||
// Relationships
|
||||
builder.HasOne(a => a.Camera)
|
||||
.WithMany()
|
||||
.HasForeignKey(a => a.CameraId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(a => a.Agent)
|
||||
.WithMany()
|
||||
.HasForeignKey(a => a.AgentId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user