< Summary

Information
Class: AsiBackbone.EntityFrameworkCore.Configurations.GovernanceOutboxEntryEntityConfiguration
Assembly: AsiBackbone.EntityFrameworkCore
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.EntityFrameworkCore/Configurations/GovernanceOutboxEntryEntityConfiguration.cs
Line coverage
100%
Covered lines: 158
Uncovered lines: 0
Coverable lines: 158
Total lines: 253
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
Configure(...)100%11100%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.EntityFrameworkCore/Configurations/GovernanceOutboxEntryEntityConfiguration.cs

#LineLine coverage
 1using AsiBackbone.EntityFrameworkCore.Persistence;
 2using Microsoft.EntityFrameworkCore;
 3using Microsoft.EntityFrameworkCore.Metadata.Builders;
 4using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
 5
 6namespace AsiBackbone.EntityFrameworkCore.Configurations;
 7
 8/// <summary>
 9/// Configures the Entity Framework Core persistence mapping for <see cref="GovernanceOutboxEntryEntity" />.
 10/// </summary>
 11public sealed class GovernanceOutboxEntryEntityConfiguration
 12    : IEntityTypeConfiguration<GovernanceOutboxEntryEntity>
 13{
 14    private const int IdentifierMaxLength = 128;
 15    private const int SchemaVersionMaxLength = 64;
 16    private const int StatusMaxLength = 128;
 17    private const int ProviderMaxLength = 128;
 18    private const int ErrorCodeMaxLength = 128;
 19    private const int ProviderErrorCodeMaxLength = 128;
 20    private const int StageMaxLength = 128;
 21    private const int OperationNameMaxLength = 256;
 22    private const int OutcomeMaxLength = 128;
 23    private const int PolicyVersionMaxLength = 128;
 24    private const int HashMaxLength = 512;
 25    private const int ContentTypeMaxLength = 256;
 26    private const int PayloadTypeMaxLength = 128;
 27    private const int DiagnosticTextMaxLength = 4096;
 28    private const int SerializedJsonMaxLength = 65536;
 29    private const int ConcurrencyStampMaxLength = 64;
 30
 131    private static readonly ValueConverter<DateTimeOffset, long> DateTimeOffsetToUtcTicksConverter = new(
 132        value => value.ToUniversalTime().Ticks,
 133        value => new DateTimeOffset(value, TimeSpan.Zero));
 34
 135    private static readonly ValueConverter<DateTimeOffset?, long?> NullableDateTimeOffsetToUtcTicksConverter = new(
 136        value => value.HasValue ? value.Value.ToUniversalTime().Ticks : null,
 137        value => value.HasValue ? new DateTimeOffset(value.Value, TimeSpan.Zero) : null);
 38
 39    /// <inheritdoc />
 40    public void Configure(EntityTypeBuilder<GovernanceOutboxEntryEntity> builder)
 41    {
 2042        ArgumentNullException.ThrowIfNull(builder);
 43
 2044        _ = builder.ToTable("AsiBackboneGovernanceOutboxEntries");
 45
 2046        _ = builder.HasKey(outboxEntry => outboxEntry.Id);
 47
 2048        _ = builder.Property(outboxEntry => outboxEntry.Id)
 2049            .ValueGeneratedNever();
 50
 2051        _ = builder.Property(outboxEntry => outboxEntry.ConcurrencyStamp)
 2052            .IsRequired()
 2053            .HasMaxLength(ConcurrencyStampMaxLength)
 2054            .IsConcurrencyToken();
 55
 2056        _ = builder.Property(outboxEntry => outboxEntry.OutboxEntryId)
 2057            .IsRequired()
 2058            .HasMaxLength(IdentifierMaxLength);
 59
 2060        _ = builder.Property(outboxEntry => outboxEntry.Status)
 2061            .HasConversion<string>()
 2062            .IsRequired()
 2063            .HasMaxLength(StatusMaxLength);
 64
 2065        _ = builder.Property(outboxEntry => outboxEntry.CreatedUtc)
 2066            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 2067            .IsRequired();
 68
 2069        _ = builder.Property(outboxEntry => outboxEntry.UpdatedUtc)
 2070            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 2071            .IsRequired();
 72
 2073        _ = builder.Property(outboxEntry => outboxEntry.DeliveredUtc)
 2074            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 75
 2076        _ = builder.Property(outboxEntry => outboxEntry.NextRetryUtc)
 2077            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 78
 2079        _ = builder.Property(outboxEntry => outboxEntry.RetryCount)
 2080            .IsRequired();
 81
 2082        _ = builder.Property(outboxEntry => outboxEntry.MaxRetryCount)
 2083            .IsRequired();
 84
 2085        _ = builder.Property(outboxEntry => outboxEntry.ProviderName)
 2086            .HasMaxLength(ProviderMaxLength);
 87
 2088        _ = builder.Property(outboxEntry => outboxEntry.ProviderRecordId)
 2089            .HasMaxLength(IdentifierMaxLength);
 90
 2091        _ = builder.Property(outboxEntry => outboxEntry.DeadLetterReason)
 2092            .HasMaxLength(DiagnosticTextMaxLength);
 93
 2094        _ = builder.Property(outboxEntry => outboxEntry.LastErrorCode)
 2095            .HasMaxLength(ErrorCodeMaxLength);
 96
 2097        _ = builder.Property(outboxEntry => outboxEntry.LastErrorMessage)
 2098            .HasMaxLength(DiagnosticTextMaxLength);
 99
 20100        _ = builder.Property(outboxEntry => outboxEntry.LastErrorProviderName)
 20101            .HasMaxLength(ProviderMaxLength);
 102
 20103        _ = builder.Property(outboxEntry => outboxEntry.LastErrorProviderErrorCode)
 20104            .HasMaxLength(ProviderErrorCodeMaxLength);
 105
 20106        _ = builder.Property(outboxEntry => outboxEntry.MetadataJson)
 20107            .IsRequired()
 20108            .HasMaxLength(SerializedJsonMaxLength);
 109
 20110        _ = builder.Property(outboxEntry => outboxEntry.ClaimOwner)
 20111            .HasMaxLength(IdentifierMaxLength);
 112
 20113        _ = builder.Property(outboxEntry => outboxEntry.ClaimToken)
 20114            .HasMaxLength(IdentifierMaxLength);
 115
 20116        _ = builder.Property(outboxEntry => outboxEntry.ClaimedUtc)
 20117            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 118
 20119        _ = builder.Property(outboxEntry => outboxEntry.ClaimExpiresUtc)
 20120            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 121
 20122        _ = builder.Property(outboxEntry => outboxEntry.ClaimAttemptCount)
 20123            .IsRequired();
 124
 20125        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeId)
 20126            .IsRequired()
 20127            .HasMaxLength(IdentifierMaxLength);
 128
 20129        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeSchemaVersion)
 20130            .IsRequired()
 20131            .HasMaxLength(SchemaVersionMaxLength);
 132
 20133        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEventType)
 20134            .HasConversion<string>()
 20135            .IsRequired()
 20136            .HasMaxLength(StatusMaxLength);
 137
 20138        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEventId)
 20139            .HasMaxLength(IdentifierMaxLength);
 140
 20141        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOccurredUtc)
 20142            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 20143            .IsRequired();
 144
 20145        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeCreatedUtc)
 20146            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 20147            .IsRequired();
 148
 20149        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeCorrelationId)
 20150            .HasMaxLength(IdentifierMaxLength);
 151
 20152        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeDecisionReceiptId)
 20153            .HasMaxLength(IdentifierMaxLength);
 154
 20155        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeLifecycleStage)
 20156            .HasConversion<string>()
 20157            .HasMaxLength(StageMaxLength);
 158
 20159        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePolicyVersion)
 20160            .HasMaxLength(PolicyVersionMaxLength);
 161
 20162        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePolicyHash)
 20163            .HasMaxLength(HashMaxLength);
 164
 20165        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeTraceId)
 20166            .HasMaxLength(IdentifierMaxLength);
 167
 20168        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeSpanId)
 20169            .HasMaxLength(IdentifierMaxLength);
 170
 20171        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeParentSpanId)
 20172            .HasMaxLength(IdentifierMaxLength);
 173
 20174        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOperationName)
 20175            .HasMaxLength(OperationNameMaxLength);
 176
 20177        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOutcome)
 20178            .HasMaxLength(OutcomeMaxLength);
 179
 20180        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeActorId)
 20181            .HasMaxLength(IdentifierMaxLength);
 182
 20183        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEmitterStatus)
 20184            .HasMaxLength(StatusMaxLength);
 185
 20186        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEmitterProvider)
 20187            .HasMaxLength(ProviderMaxLength);
 188
 20189        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeGatewayExecutionId)
 20190            .HasMaxLength(IdentifierMaxLength);
 191
 20192        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeDecisionStage)
 20193            .HasMaxLength(StageMaxLength);
 194
 20195        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeMetadataJson)
 20196            .IsRequired()
 20197            .HasMaxLength(SerializedJsonMaxLength);
 198
 20199        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadType)
 20200            .HasMaxLength(PayloadTypeMaxLength);
 201
 20202        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadSchemaVersion)
 20203            .HasMaxLength(SchemaVersionMaxLength);
 204
 20205        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadContentType)
 20206            .HasMaxLength(ContentTypeMaxLength);
 207
 20208        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadContentHash)
 20209            .HasMaxLength(HashMaxLength);
 210
 20211        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadMetadataJson)
 20212            .IsRequired()
 20213            .HasMaxLength(SerializedJsonMaxLength);
 214
 20215        _ = builder.HasIndex(outboxEntry => outboxEntry.OutboxEntryId)
 20216            .IsUnique();
 217
 20218        _ = builder.HasIndex(outboxEntry => outboxEntry.ClaimToken);
 219
 20220        _ = builder.HasIndex(outboxEntry => new
 20221        {
 20222            outboxEntry.Status,
 20223            outboxEntry.ClaimExpiresUtc,
 20224            outboxEntry.CreatedUtc,
 20225            outboxEntry.OutboxEntryId
 20226        });
 227
 20228        _ = builder.HasIndex(outboxEntry => new
 20229        {
 20230            outboxEntry.Status,
 20231            outboxEntry.ClaimExpiresUtc,
 20232            outboxEntry.NextRetryUtc,
 20233            outboxEntry.UpdatedUtc,
 20234            outboxEntry.OutboxEntryId
 20235        });
 236
 20237        _ = builder.HasIndex(outboxEntry => new
 20238        {
 20239            outboxEntry.Status,
 20240            outboxEntry.NextRetryUtc,
 20241            outboxEntry.UpdatedUtc,
 20242            outboxEntry.OutboxEntryId
 20243        });
 244
 20245        _ = builder.HasIndex(outboxEntry => new
 20246        {
 20247            outboxEntry.Status,
 20248            outboxEntry.CreatedUtc,
 20249            outboxEntry.OutboxEntryId
 20250        });
 251
 20252    }
 253}