コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public static string GetCrontabSetName(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}CrontabSet");
 }
コード例 #4
0
 public static string GetCrontabHashId(RedisMessageBusOptions options, string jobId)
 {
     return($"{options.TopicPrefix}crontabdata:{jobId}");
 }
コード例 #5
0
 public static string GetCrontabChannel(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}CrontabJobChannel");
 }
コード例 #6
0
 public static string GetErrorChannel(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}ErrorJobChannel");
 }
コード例 #7
0
 public static string GetDelayChannel(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}DelayJobChannel");
 }
コード例 #8
0
 public static string GetDelaySortedSetName(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}delay:jobid");
 }
コード例 #9
0
 public RedisMessageBus_Subscriber(ILogger <RedisMessageBus_Subscriber> logger, RedisMessageBusOptions options, ConnectionMultiplexer connectionMultiplexer)
 {
     _logger  = logger;
     _options = options;
     _connectionMultiplexer = connectionMultiplexer;
     _subscriber            = _connectionMultiplexer.GetSubscriber();
 }
コード例 #10
0
 public static IServiceCollection AddRedisMessageBus(this IServiceCollection services, RedisMessageBusOptions options)
 {
     AddService(services, options);
     services.AddSingleton <IRedisMessageBus, RedisMessageBus>();
     return(services);
 }