Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace ServiceControl.Persistence.EFCore.EntityConfigurations;

using Entities;
using MessageFailures;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

class FailedMessageConfiguration : IEntityTypeConfiguration<FailedMessageEntity>
{
public void Configure(EntityTypeBuilder<FailedMessageEntity> builder)
{
// Drives the retention sweep.
// The index is restricted to the statuses the sweep deletes (Resolved and Archived)
builder.HasIndex(e => e.StatusChangedAt)
.HasFilter($"status IN ({(int)FailedMessageStatus.Resolved}, {(int)FailedMessageStatus.Archived})");

builder.HasIndex(e => new { e.Status, e.LastModified, e.UniqueMessageId })
.IncludeProperties(nameof(FailedMessageEntity.FirstTimeOfFailure), nameof(FailedMessageEntity.LastTimeOfFailure));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace ServiceControl.Persistence.EFCore.EntityConfigurations;

using Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

class FailedMessageGroupConfiguration : IEntityTypeConfiguration<FailedMessageGroupEntity>
{
public void Configure(EntityTypeBuilder<FailedMessageGroupEntity> builder)
{
// Both the join column (FailedMessageUniqueId) and the per-group title lookup's column
// (Title) have to be INCLUDEs. Without Title the lookup heap-fetches, and without
// FailedMessageUniqueId step 1 of the aggregate cannot join index-only
builder.HasIndex(e => new { e.Type, e.GroupId })
.IncludeProperties(nameof(FailedMessageGroupEntity.FailedMessageUniqueId), nameof(FailedMessageGroupEntity.Title));
}
}
Loading