< 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    {
 1942        ArgumentNullException.ThrowIfNull(builder);
 43
 1944        _ = builder.ToTable("AsiBackboneGovernanceOutboxEntries");
 45
 1946        _ = builder.HasKey(outboxEntry => outboxEntry.Id);
 47
 1948        _ = builder.Property(outboxEntry => outboxEntry.Id)
 1949            .ValueGeneratedNever();
 50
 1951        _ = builder.Property(outboxEntry => outboxEntry.ConcurrencyStamp)
 1952            .IsRequired()
 1953            .HasMaxLength(ConcurrencyStampMaxLength)
 1954            .IsConcurrencyToken();
 55
 1956        _ = builder.Property(outboxEntry => outboxEntry.OutboxEntryId)
 1957            .IsRequired()
 1958            .HasMaxLength(IdentifierMaxLength);
 59
 1960        _ = builder.Property(outboxEntry => outboxEntry.Status)
 1961            .HasConversion<string>()
 1962            .IsRequired()
 1963            .HasMaxLength(StatusMaxLength);
 64
 1965        _ = builder.Property(outboxEntry => outboxEntry.CreatedUtc)
 1966            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 1967            .IsRequired();
 68
 1969        _ = builder.Property(outboxEntry => outboxEntry.UpdatedUtc)
 1970            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 1971            .IsRequired();
 72
 1973        _ = builder.Property(outboxEntry => outboxEntry.DeliveredUtc)
 1974            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 75
 1976        _ = builder.Property(outboxEntry => outboxEntry.NextRetryUtc)
 1977            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 78
 1979        _ = builder.Property(outboxEntry => outboxEntry.RetryCount)
 1980            .IsRequired();
 81
 1982        _ = builder.Property(outboxEntry => outboxEntry.MaxRetryCount)
 1983            .IsRequired();
 84
 1985        _ = builder.Property(outboxEntry => outboxEntry.ProviderName)
 1986            .HasMaxLength(ProviderMaxLength);
 87
 1988        _ = builder.Property(outboxEntry => outboxEntry.ProviderRecordId)
 1989            .HasMaxLength(IdentifierMaxLength);
 90
 1991        _ = builder.Property(outboxEntry => outboxEntry.DeadLetterReason)
 1992            .HasMaxLength(DiagnosticTextMaxLength);
 93
 1994        _ = builder.Property(outboxEntry => outboxEntry.LastErrorCode)
 1995            .HasMaxLength(ErrorCodeMaxLength);
 96
 1997        _ = builder.Property(outboxEntry => outboxEntry.LastErrorMessage)
 1998            .HasMaxLength(DiagnosticTextMaxLength);
 99
 19100        _ = builder.Property(outboxEntry => outboxEntry.LastErrorProviderName)
 19101            .HasMaxLength(ProviderMaxLength);
 102
 19103        _ = builder.Property(outboxEntry => outboxEntry.LastErrorProviderErrorCode)
 19104            .HasMaxLength(ProviderErrorCodeMaxLength);
 105
 19106        _ = builder.Property(outboxEntry => outboxEntry.MetadataJson)
 19107            .IsRequired()
 19108            .HasMaxLength(SerializedJsonMaxLength);
 109
 19110        _ = builder.Property(outboxEntry => outboxEntry.ClaimOwner)
 19111            .HasMaxLength(IdentifierMaxLength);
 112
 19113        _ = builder.Property(outboxEntry => outboxEntry.ClaimToken)
 19114            .HasMaxLength(IdentifierMaxLength);
 115
 19116        _ = builder.Property(outboxEntry => outboxEntry.ClaimedUtc)
 19117            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 118
 19119        _ = builder.Property(outboxEntry => outboxEntry.ClaimExpiresUtc)
 19120            .HasConversion(NullableDateTimeOffsetToUtcTicksConverter);
 121
 19122        _ = builder.Property(outboxEntry => outboxEntry.ClaimAttemptCount)
 19123            .IsRequired();
 124
 19125        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeId)
 19126            .IsRequired()
 19127            .HasMaxLength(IdentifierMaxLength);
 128
 19129        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeSchemaVersion)
 19130            .IsRequired()
 19131            .HasMaxLength(SchemaVersionMaxLength);
 132
 19133        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEventType)
 19134            .HasConversion<string>()
 19135            .IsRequired()
 19136            .HasMaxLength(StatusMaxLength);
 137
 19138        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEventId)
 19139            .HasMaxLength(IdentifierMaxLength);
 140
 19141        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOccurredUtc)
 19142            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 19143            .IsRequired();
 144
 19145        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeCreatedUtc)
 19146            .HasConversion(DateTimeOffsetToUtcTicksConverter)
 19147            .IsRequired();
 148
 19149        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeCorrelationId)
 19150            .HasMaxLength(IdentifierMaxLength);
 151
 19152        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeDecisionReceiptId)
 19153            .HasMaxLength(IdentifierMaxLength);
 154
 19155        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeLifecycleStage)
 19156            .HasConversion<string>()
 19157            .HasMaxLength(StageMaxLength);
 158
 19159        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePolicyVersion)
 19160            .HasMaxLength(PolicyVersionMaxLength);
 161
 19162        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePolicyHash)
 19163            .HasMaxLength(HashMaxLength);
 164
 19165        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeTraceId)
 19166            .HasMaxLength(IdentifierMaxLength);
 167
 19168        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeSpanId)
 19169            .HasMaxLength(IdentifierMaxLength);
 170
 19171        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeParentSpanId)
 19172            .HasMaxLength(IdentifierMaxLength);
 173
 19174        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOperationName)
 19175            .HasMaxLength(OperationNameMaxLength);
 176
 19177        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeOutcome)
 19178            .HasMaxLength(OutcomeMaxLength);
 179
 19180        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeActorId)
 19181            .HasMaxLength(IdentifierMaxLength);
 182
 19183        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEmitterStatus)
 19184            .HasMaxLength(StatusMaxLength);
 185
 19186        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeEmitterProvider)
 19187            .HasMaxLength(ProviderMaxLength);
 188
 19189        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeGatewayExecutionId)
 19190            .HasMaxLength(IdentifierMaxLength);
 191
 19192        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeDecisionStage)
 19193            .HasMaxLength(StageMaxLength);
 194
 19195        _ = builder.Property(outboxEntry => outboxEntry.EnvelopeMetadataJson)
 19196            .IsRequired()
 19197            .HasMaxLength(SerializedJsonMaxLength);
 198
 19199        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadType)
 19200            .HasMaxLength(PayloadTypeMaxLength);
 201
 19202        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadSchemaVersion)
 19203            .HasMaxLength(SchemaVersionMaxLength);
 204
 19205        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadContentType)
 19206            .HasMaxLength(ContentTypeMaxLength);
 207
 19208        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadContentHash)
 19209            .HasMaxLength(HashMaxLength);
 210
 19211        _ = builder.Property(outboxEntry => outboxEntry.EnvelopePayloadMetadataJson)
 19212            .IsRequired()
 19213            .HasMaxLength(SerializedJsonMaxLength);
 214
 19215        _ = builder.HasIndex(outboxEntry => outboxEntry.OutboxEntryId)
 19216            .IsUnique();
 217
 19218        _ = builder.HasIndex(outboxEntry => outboxEntry.ClaimToken);
 219
 19220        _ = builder.HasIndex(outboxEntry => new
 19221        {
 19222            outboxEntry.Status,
 19223            outboxEntry.ClaimExpiresUtc,
 19224            outboxEntry.CreatedUtc,
 19225            outboxEntry.OutboxEntryId
 19226        });
 227
 19228        _ = builder.HasIndex(outboxEntry => new
 19229        {
 19230            outboxEntry.Status,
 19231            outboxEntry.ClaimExpiresUtc,
 19232            outboxEntry.NextRetryUtc,
 19233            outboxEntry.UpdatedUtc,
 19234            outboxEntry.OutboxEntryId
 19235        });
 236
 19237        _ = builder.HasIndex(outboxEntry => new
 19238        {
 19239            outboxEntry.Status,
 19240            outboxEntry.NextRetryUtc,
 19241            outboxEntry.UpdatedUtc,
 19242            outboxEntry.OutboxEntryId
 19243        });
 244
 19245        _ = builder.HasIndex(outboxEntry => new
 19246        {
 19247            outboxEntry.Status,
 19248            outboxEntry.CreatedUtc,
 19249            outboxEntry.OutboxEntryId
 19250        });
 251
 19252    }
 253}