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,10 @@
namespace Particular.LicensingComponent.Persistence;

public static class ThroughputReporting
{
/// <summary>
/// How far back a throughput report reaches. Throughput reads are filtered to this window, so it
/// has to be the same wherever <see cref="ILicensingDataStore"/> is implemented.
/// </summary>
public const int ReportedMonths = 14;
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ServiceControl.Persistence.EFCore.PostgreSql.Migrations
{
/// <inheritdoc />
public partial class AddLicensingThroughput : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "licensing_endpoints",
columns: table => new
{
normalized_name = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
throughput_source = table.Column<int>(type: "integer", nullable: false),
name = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
sanitized_name = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
normalized_sanitized_name = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
user_indicator = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
scope = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: true),
endpoint_indicators = table.Column<List<string>>(type: "text[]", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_licensing_endpoints", x => new { x.normalized_name, x.throughput_source });
});

migrationBuilder.CreateTable(
name: "licensing_endpoint_throughput",
columns: table => new
{
normalized_name = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
throughput_source = table.Column<int>(type: "integer", nullable: false),
date_utc = table.Column<DateOnly>(type: "date", nullable: false),
message_count = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_licensing_endpoint_throughput", x => new { x.normalized_name, x.throughput_source, x.date_utc });
table.ForeignKey(
name: "fk_licensing_endpoint_throughput_licensing_endpoints_normalize",
columns: x => new { x.normalized_name, x.throughput_source },
principalTable: "licensing_endpoints",
principalColumns: new[] { "normalized_name", "throughput_source" },
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "ix_licensing_endpoint_throughput_date_utc",
table: "licensing_endpoint_throughput",
column: "date_utc");

migrationBuilder.CreateIndex(
name: "ix_licensing_endpoints_normalized_sanitized_name",
table: "licensing_endpoints",
column: "normalized_sanitized_name");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "licensing_endpoint_throughput");

migrationBuilder.DropTable(
name: "licensing_endpoints");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,88 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("known_endpoints", (string)null);
});

modelBuilder.Entity("ServiceControl.Persistence.EFCore.Entities.LicensingEndpointEntity", b =>
{
b.Property<string>("NormalizedName")
.HasMaxLength(300)
.HasColumnType("character varying(300)")
.HasColumnName("normalized_name");

b.Property<int>("ThroughputSource")
.HasColumnType("integer")
.HasColumnName("throughput_source");

b.PrimitiveCollection<List<string>>("EndpointIndicators")
.IsRequired()
.HasColumnType("text[]")
.HasColumnName("endpoint_indicators");

b.Property<string>("Name")
.IsRequired()
.HasMaxLength(300)
.HasColumnType("character varying(300)")
.HasColumnName("name");

b.Property<string>("NormalizedSanitizedName")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)")
.HasColumnName("normalized_sanitized_name");

b.Property<string>("SanitizedName")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)")
.HasColumnName("sanitized_name");

b.Property<string>("Scope")
.HasMaxLength(450)
.HasColumnType("character varying(450)")
.HasColumnName("scope");

b.Property<string>("UserIndicator")
.IsRequired()
.HasMaxLength(450)
.HasColumnType("character varying(450)")
.HasColumnName("user_indicator");

b.HasKey("NormalizedName", "ThroughputSource")
.HasName("pk_licensing_endpoints");

b.HasIndex("NormalizedSanitizedName")
.HasDatabaseName("ix_licensing_endpoints_normalized_sanitized_name");

b.ToTable("licensing_endpoints", (string)null);
});

modelBuilder.Entity("ServiceControl.Persistence.EFCore.Entities.LicensingEndpointThroughputEntity", b =>
{
b.Property<string>("NormalizedName")
.HasMaxLength(300)
.HasColumnType("character varying(300)")
.HasColumnName("normalized_name");

b.Property<int>("ThroughputSource")
.HasColumnType("integer")
.HasColumnName("throughput_source");

b.Property<DateOnly>("DateUtc")
.HasColumnType("date")
.HasColumnName("date_utc");

b.Property<long>("MessageCount")
.HasColumnType("bigint")
.HasColumnName("message_count");

b.HasKey("NormalizedName", "ThroughputSource", "DateUtc")
.HasName("pk_licensing_endpoint_throughput");

b.HasIndex("DateUtc")
.HasDatabaseName("ix_licensing_endpoint_throughput_date_utc");

b.ToTable("licensing_endpoint_throughput", (string)null);
});

modelBuilder.Entity("ServiceControl.Persistence.EFCore.Entities.MessageRedirectEntity", b =>
{
b.Property<string>("FromPhysicalAddress")
Expand Down Expand Up @@ -765,6 +847,16 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasConstraintName("fk_failed_message_groups_failed_messages_failed_message_unique");
});

modelBuilder.Entity("ServiceControl.Persistence.EFCore.Entities.LicensingEndpointThroughputEntity", b =>
{
b.HasOne("ServiceControl.Persistence.EFCore.Entities.LicensingEndpointEntity", null)
.WithMany()
.HasForeignKey("NormalizedName", "ThroughputSource")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_licensing_endpoint_throughput_licensing_endpoints_normalize");
});
#pragma warning restore 612, 618
}
}
Expand Down
Loading