mirror of https://github.com/abpframework/abp.git
9 changed files with 192 additions and 9 deletions
@ -0,0 +1,13 @@ |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.DistributedEvents |
|||
{ |
|||
public static class EfCoreOutboxConfigExtensions |
|||
{ |
|||
public static void UseDbContext<TDbContext>(this OutboxConfig outboxConfig) |
|||
where TDbContext : IHasEventOutbox |
|||
{ |
|||
outboxConfig.ImplementationType = typeof(DbContextEventOutbox<TDbContext>); |
|||
} |
|||
} |
|||
} |
|||
@ -1,18 +1,26 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.EventBus.Distributed |
|||
{ |
|||
public class OutboxConfig |
|||
{ |
|||
[NotNull] |
|||
public string Name { get; } |
|||
|
|||
public Type ImplementationType { get; set; } |
|||
|
|||
public Func<Type, bool> Selector { get; set; } |
|||
|
|||
public OutboxConfig(string name, Type implementationType, Func<Type, bool> selector = null) |
|||
/// <summary>
|
|||
/// Used to enable/disable sending events from outbox to the message broker.
|
|||
/// Default: true.
|
|||
/// </summary>
|
|||
public bool IsSendingEnabled { get; set; } = true; |
|||
|
|||
public OutboxConfig([NotNull] string name) |
|||
{ |
|||
Name = name; |
|||
ImplementationType = implementationType; |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,8 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.EventBus.Distributed |
|||
{ |
|||
public class OutboxConfigList : List<OutboxConfig> |
|||
public class OutboxConfigList : Dictionary<string, OutboxConfig> |
|||
{ |
|||
public void Configure(string outboxName, Action<OutboxConfig> configAction) |
|||
{ |
|||
var outboxConfig = this.GetOrAdd(outboxName, () => new OutboxConfig(outboxName)); |
|||
configAction(outboxConfig); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,122 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using DistDemoApp; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace DistDemoApp.Migrations |
|||
{ |
|||
[DbContext(typeof(TodoDbContext))] |
|||
[Migration("20210908075344_Added_Outbox_CreationTime")] |
|||
partial class Added_Outbox_CreationTime |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("ProductVersion", "5.0.9") |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("DistDemoApp.TodoItem", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("nvarchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime2") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("uniqueidentifier") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("Text") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("nvarchar(128)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("TodoItems"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("DistDemoApp.TodoSummary", b => |
|||
{ |
|||
b.Property<int>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("int") |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("nvarchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<byte>("Day") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<byte>("Month") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<int>("TotalCount") |
|||
.HasColumnType("int"); |
|||
|
|||
b.Property<int>("Year") |
|||
.HasColumnType("int"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("TodoSummaries"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.EntityFrameworkCore.DistributedEvents.OutgoingEventRecord", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime2") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<byte[]>("EventData") |
|||
.IsRequired() |
|||
.HasColumnType("varbinary(max)"); |
|||
|
|||
b.Property<string>("EventName") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("nvarchar(256)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("AbpEventOutbox"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace DistDemoApp.Migrations |
|||
{ |
|||
public partial class Added_Outbox_CreationTime : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<DateTime>( |
|||
name: "CreationTime", |
|||
table: "AbpEventOutbox", |
|||
type: "datetime2", |
|||
nullable: false, |
|||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "CreationTime", |
|||
table: "AbpEventOutbox"); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue