public RedisMessageBus(IServiceProvider serviceProvider, ILogger <RedisMessageBus> logger , RedisMessageBusOptions options , ConnectionMultiplexer connectionMultiplexer , RedisStorage redisStorage) { _serviceProvider = serviceProvider; _logger = logger; _options = options; _redisStorage = redisStorage; backgroundProcessContext = new BackgroundProcessContext(); _processExecuter = new ProcessExecuter(_serviceProvider, backgroundProcessContext); }
private static IServiceCollection AddService(IServiceCollection services, RedisMessageBusOptions options) { if (options.ConnectionMultiplexer != null) { services.AddSingleton(options.ConnectionMultiplexer); } else if (!string.IsNullOrEmpty(options.ConnectionString)) { var redis = ConnectionMultiplexer.Connect(options.ConnectionString); services.AddSingleton(redis); } else { throw new Exception("ConnectionMultiplexer或RedisConnectionString为空"); } services.AddSingleton(options); services.AddSingleton <RedisStorage>(); return(services); }
public static string GetCrontabSetName(RedisMessageBusOptions options) { return($"{options.TopicPrefix}CrontabSet"); }
public static string GetCrontabHashId(RedisMessageBusOptions options, string jobId) { return($"{options.TopicPrefix}crontabdata:{jobId}"); }
public static string GetCrontabChannel(RedisMessageBusOptions options) { return($"{options.TopicPrefix}CrontabJobChannel"); }
public static string GetErrorChannel(RedisMessageBusOptions options) { return($"{options.TopicPrefix}ErrorJobChannel"); }
public static string GetDelayChannel(RedisMessageBusOptions options) { return($"{options.TopicPrefix}DelayJobChannel"); }
public static string GetDelaySortedSetName(RedisMessageBusOptions options) { return($"{options.TopicPrefix}delay:jobid"); }
public RedisMessageBus_Subscriber(ILogger <RedisMessageBus_Subscriber> logger, RedisMessageBusOptions options, ConnectionMultiplexer connectionMultiplexer) { _logger = logger; _options = options; _connectionMultiplexer = connectionMultiplexer; _subscriber = _connectionMultiplexer.GetSubscriber(); }
public static IServiceCollection AddRedisMessageBus(this IServiceCollection services, RedisMessageBusOptions options) { AddService(services, options); services.AddSingleton <IRedisMessageBus, RedisMessageBus>(); return(services); }