Browse Source

Use DatabaseName instead of config name

pull/17446/head
Halil İbrahim Kalkan 3 years ago
parent
commit
8bb2c7aa1e
  1. 2
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreInboxConfigExtensions.cs
  2. 4
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreOutboxConfigExtensions.cs
  3. 7
      framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/InboxConfig.cs
  4. 7
      framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/OutboxConfig.cs
  5. 3
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs
  6. 3
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs
  7. 2
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbInboxConfigExtensions.cs
  8. 4
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbOutboxConfigExtensions.cs

2
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreInboxConfigExtensions.cs

@ -1,3 +1,4 @@
using Volo.Abp.Data;
using Volo.Abp.EventBus.Distributed; using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.EntityFrameworkCore.DistributedEvents; namespace Volo.Abp.EntityFrameworkCore.DistributedEvents;
@ -8,5 +9,6 @@ public static class EfCoreInboxConfigExtensions
where TDbContext : IHasEventInbox where TDbContext : IHasEventInbox
{ {
outboxConfig.ImplementationType = typeof(IDbContextEventInbox<TDbContext>); outboxConfig.ImplementationType = typeof(IDbContextEventInbox<TDbContext>);
outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName<TDbContext>();
} }
} }

4
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/EfCoreOutboxConfigExtensions.cs

@ -1,4 +1,5 @@
using Volo.Abp.EventBus.Distributed; using Volo.Abp.Data;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.EntityFrameworkCore.DistributedEvents; namespace Volo.Abp.EntityFrameworkCore.DistributedEvents;
@ -8,5 +9,6 @@ public static class EfCoreOutboxConfigExtensions
where TDbContext : IHasEventOutbox where TDbContext : IHasEventOutbox
{ {
outboxConfig.ImplementationType = typeof(IDbContextEventOutbox<TDbContext>); outboxConfig.ImplementationType = typeof(IDbContextEventOutbox<TDbContext>);
outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName<TDbContext>();
} }
} }

7
framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/InboxConfig.cs

@ -8,6 +8,13 @@ public class InboxConfig
[NotNull] [NotNull]
public string Name { get; } public string Name { get; }
[NotNull]
public string DatabaseName {
get => _databaseName;
set => _databaseName = Check.NotNullOrWhiteSpace(value, nameof(DatabaseName));
}
[NotNull] private string _databaseName;
public Type ImplementationType { get; set; } public Type ImplementationType { get; set; }
public Func<Type, bool> EventSelector { get; set; } public Func<Type, bool> EventSelector { get; set; }

7
framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Distributed/OutboxConfig.cs

@ -7,6 +7,13 @@ public class OutboxConfig
{ {
[NotNull] [NotNull]
public string Name { get; } public string Name { get; }
[NotNull]
public string DatabaseName {
get => _databaseName;
set => _databaseName = Check.NotNullOrWhiteSpace(value, nameof(DatabaseName));
}
[NotNull] private string _databaseName;
public Type ImplementationType { get; set; } public Type ImplementationType { get; set; }

3
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs

@ -27,7 +27,7 @@ public class InboxProcessor : IInboxProcessor, ITransientDependency
protected DateTime? LastCleanTime { get; set; } protected DateTime? LastCleanTime { get; set; }
protected string DistributedLockName => "AbpInbox_" + InboxConfig.Name; protected string DistributedLockName { get; private set; }
public ILogger<InboxProcessor> Logger { get; set; } public ILogger<InboxProcessor> Logger { get; set; }
protected CancellationTokenSource StoppingTokenSource { get; } protected CancellationTokenSource StoppingTokenSource { get; }
protected CancellationToken StoppingToken { get; } protected CancellationToken StoppingToken { get; }
@ -64,6 +64,7 @@ public class InboxProcessor : IInboxProcessor, ITransientDependency
{ {
InboxConfig = inboxConfig; InboxConfig = inboxConfig;
Inbox = (IEventInbox)ServiceProvider.GetRequiredService(inboxConfig.ImplementationType); Inbox = (IEventInbox)ServiceProvider.GetRequiredService(inboxConfig.ImplementationType);
DistributedLockName = $"AbpInbox_{InboxConfig.DatabaseName}";
Timer.Start(cancellationToken); Timer.Start(cancellationToken);
return Task.CompletedTask; return Task.CompletedTask;
} }

3
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs

@ -22,7 +22,7 @@ public class OutboxSender : IOutboxSender, ITransientDependency
protected IEventOutbox Outbox { get; private set; } protected IEventOutbox Outbox { get; private set; }
protected OutboxConfig OutboxConfig { get; private set; } protected OutboxConfig OutboxConfig { get; private set; }
protected AbpEventBusBoxesOptions EventBusBoxesOptions { get; } protected AbpEventBusBoxesOptions EventBusBoxesOptions { get; }
protected string DistributedLockName => "AbpOutbox_" + OutboxConfig.Name; protected string DistributedLockName { get; private set; }
public ILogger<OutboxSender> Logger { get; set; } public ILogger<OutboxSender> Logger { get; set; }
protected CancellationTokenSource StoppingTokenSource { get; } protected CancellationTokenSource StoppingTokenSource { get; }
@ -51,6 +51,7 @@ public class OutboxSender : IOutboxSender, ITransientDependency
{ {
OutboxConfig = outboxConfig; OutboxConfig = outboxConfig;
Outbox = (IEventOutbox)ServiceProvider.GetRequiredService(outboxConfig.ImplementationType); Outbox = (IEventOutbox)ServiceProvider.GetRequiredService(outboxConfig.ImplementationType);
DistributedLockName = $"AbpOutbox_{OutboxConfig.DatabaseName}";
Timer.Start(cancellationToken); Timer.Start(cancellationToken);
return Task.CompletedTask; return Task.CompletedTask;
} }

2
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbInboxConfigExtensions.cs

@ -1,3 +1,4 @@
using Volo.Abp.Data;
using Volo.Abp.EventBus.Distributed; using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.MongoDB.DistributedEvents; namespace Volo.Abp.MongoDB.DistributedEvents;
@ -8,5 +9,6 @@ public static class MongoDbInboxConfigExtensions
where TMongoDbContext : IHasEventInbox where TMongoDbContext : IHasEventInbox
{ {
outboxConfig.ImplementationType = typeof(IMongoDbContextEventInbox<TMongoDbContext>); outboxConfig.ImplementationType = typeof(IMongoDbContextEventInbox<TMongoDbContext>);
outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName<TMongoDbContext>();
} }
} }

4
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbOutboxConfigExtensions.cs

@ -1,4 +1,5 @@
using Volo.Abp.EventBus.Distributed; using Volo.Abp.Data;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.MongoDB.DistributedEvents; namespace Volo.Abp.MongoDB.DistributedEvents;
@ -8,5 +9,6 @@ public static class MongoDbOutboxConfigExtensions
where TMongoDbContext : IHasEventOutbox where TMongoDbContext : IHasEventOutbox
{ {
outboxConfig.ImplementationType = typeof(IMongoDbContextEventOutbox<TMongoDbContext>); outboxConfig.ImplementationType = typeof(IMongoDbContextEventOutbox<TMongoDbContext>);
outboxConfig.DatabaseName = ConnectionStringNameAttribute.GetConnStringName<TMongoDbContext>();
} }
} }

Loading…
Cancel
Save