浏览代码

fixed dependency injection bugs.

master
Savorboard 7 年前
父节点
当前提交
b9c3a536f0
共有 5 个文件被更改,包括 11 次插入11 次删除
  1. +1
    -1
      src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs
  2. +1
    -2
      src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
  3. +5
    -4
      src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
  4. +2
    -2
      src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
  5. +2
    -2
      src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs

+ 1
- 1
src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs 查看文件

@@ -21,7 +21,7 @@ namespace DotNetCore.CAP
services.AddSingleton(kafkaOptions);

services.AddSingleton<IConsumerClientFactory, KafkaConsumerClientFactory>();
services.AddTransient<IQueueExecutor, PublishQueueExecutor>();
services.AddSingleton<IQueueExecutor, PublishQueueExecutor>();
}
}
}

+ 1
- 2
src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs 查看文件

@@ -23,9 +23,8 @@ namespace DotNetCore.CAP
services.AddSingleton<IConsumerClientFactory, RabbitMQConsumerClientFactory>();

services.AddSingleton<ConnectionPool>();
services.AddScoped(x => x.GetService<ConnectionPool>().Rent());

services.AddTransient<IQueueExecutor, PublishQueueExecutor>();
services.AddSingleton<IQueueExecutor, PublishQueueExecutor>();
}
}
}

+ 5
- 4
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs 查看文件

@@ -10,19 +10,19 @@ namespace DotNetCore.CAP.RabbitMQ
internal sealed class PublishQueueExecutor : BasePublishQueueExecutor
{
private readonly ILogger _logger;
private readonly IConnection _connection;
private readonly ConnectionPool _connectionPool;
private readonly RabbitMQOptions _rabbitMQOptions;

public PublishQueueExecutor(
CapOptions options,
IStateChanger stateChanger,
IConnection connection,
ConnectionPool connectionPool,
RabbitMQOptions rabbitMQOptions,
ILogger<PublishQueueExecutor> logger)
: base(options, stateChanger, logger)
{
_logger = logger;
_connection = connection;
_connectionPool = connectionPool;
_rabbitMQOptions = rabbitMQOptions;
}

@@ -30,7 +30,8 @@ namespace DotNetCore.CAP.RabbitMQ
{
try
{
using (var channel = _connection.CreateModel())
var connection = _connectionPool.Rent();
using (var channel = connection.CreateModel())
{
var body = Encoding.UTF8.GetBytes(content);



+ 2
- 2
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs 查看文件

@@ -9,10 +9,10 @@ namespace DotNetCore.CAP.RabbitMQ
private readonly IConnection _connection;


public RabbitMQConsumerClientFactory(RabbitMQOptions rabbitMQOptions, IConnection connection)
public RabbitMQConsumerClientFactory(RabbitMQOptions rabbitMQOptions, ConnectionPool pool)
{
_rabbitMQOptions = rabbitMQOptions;
_connection = connection;
_connection = pool.Rent();
}

public IConsumerClient Create(string groupId)


+ 2
- 2
src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs 查看文件

@@ -19,8 +19,8 @@ namespace DotNetCore.CAP
public void AddServices(IServiceCollection services)
{
services.AddSingleton<IStorage, SqlServerStorage>();
services.AddScoped<IStorageConnection, SqlServerStorageConnection>();
services.AddScoped<ICapPublisher, CapPublisher>();
services.AddSingleton<IStorageConnection, SqlServerStorageConnection>();
services.AddTransient<ICapPublisher, CapPublisher>();
services.AddTransient<ICallbackPublisher, CapPublisher>();
services.AddTransient<IAdditionalProcessor, DefaultAdditionalProcessor>();
AddSqlServerOptions(services);


正在加载...
取消
保存