public UnitTest1()
 {
     redisProvider = new RedisProvider(new RedisOptions
     {
         Configuration = "127.0.0.1:6379"
     });
 }
 private CommonManager()
 {
     _RedisProvider = new RedisProvider(new RedisKitOptions()
     {
         EndPoints = "127.0.0.1:6379"
     }, _ServiceProvider.Object, _Logger.Object);
 }
Beispiel #3
0
        /// <summary>
        /// 创建一个用于命令模型的服务容器。
        /// </summary>
        /// <param name="userFactory">用户工厂。</param>
        /// <param name="mockFactoryCallback">模拟的执行器工厂回调函数。</param>
        /// <param name="redisProvider">Redis 提供程序。若为 null 值表示启用基于应用程序域各种提供程序的服务容器。</param>
        /// <returns>服务容器。</returns>
        public static IIocContainer CreateContainer(IUserFactory userFactory
                                                    , Action <MockExecutorFactory> mockFactoryCallback = null
                                                    , IRedisProvider redisProvider = null)
        {
            if (userFactory == null)
            {
                userFactory = new UserFactory(c => null);
            }

            var container = new IocContainer();

            container.Add(userFactory);
            if (redisProvider != null)
            {
                container.Add(redisProvider);
            }

            if (mockFactoryCallback != null)
            {
                var executorFactory = new MockExecutorFactory(container);
                mockFactoryCallback(executorFactory);
                container.Add <IExecutorFactory>(executorFactory);
            }
            if (Db.Engine != null)
            {
                container.Add <IDbEngine>(lmps => Db.Context);
            }
            else
            {
                container.Add <IDbEngine>(lmps => new DbEngine(new SqlEngineProvider("UNIT TEST")));
            }
            return(container);
        }
Beispiel #4
0
 public CrawlablePageService(IShouldCrawlDecider shouldCrawlDecider, ILogger <CrawlablePageService> logger,
                             IRedisProvider redisProvider)
 {
     _redisProvider      = redisProvider;
     _logger             = logger;
     _shouldCrawlDecider = shouldCrawlDecider;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisTaskMessageBusReceiver"/> class.
 /// </summary>
 /// <param name="provider">The Redis provider to use.</param>
 /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
 public RedisTaskMessageBusReceiver(IRedisProvider provider)
     : base(provider)
 {
     this.AddChannelMapping(MessageBusChannel.TaskStarted, RedisTaskProcessorChannels.TaskStartedChannel);
     this.AddChannelMapping(MessageBusChannel.TaskAssigned, RedisTaskProcessorChannels.TaskAssignedChannel);
     this.AddChannelMapping(MessageBusChannel.TaskCancelRequest, RedisTaskProcessorChannels.TaskCanceledChannel);
 }
        public HybridStorageLayer(IEnumerable <IStorageProvider> providers, IDaemonClient daemonClient, IPoolConfig poolConfig)
        {
            _daemonClient = daemonClient;
            _logger       = Log.ForContext <HybridStorageLayer>().ForContext("Component", poolConfig.Coin.Name);
            _coin         = poolConfig.Coin.Name.ToLower(); // pool's associated coin name.

            // try loading providers.
            try
            {
                foreach (var provider in providers)
                {
                    if (provider is IRedisProvider)
                    {
                        _redisProvider = (IRedisProvider)provider;
                    }
                    else if (provider is IMySqlProvider)
                    {
                        _mySqlProvider = (IMySqlProvider)provider;
                    }
                }

                IsEnabled = (_redisProvider != null && _mySqlProvider != null);
            }
            catch (Exception e)
            {
                _logger.Error("Error initializing hybrid storage layer; {0:l}", e.Message);
            }
        }
 public RedisBaseRepository(IRedisProvider redisProvider, RedisConfig redisConfig)
 {
     EnsureUtil.NotNull(redisProvider, "IRedisProvider");
     EnsureUtil.NotNull(redisConfig, "RedisConfig");
     _redisProvider = redisProvider;
     _redisConfig   = redisConfig;
 }
Beispiel #8
0
        /// <summary>
        /// 创建一个用于命令模型的服务容器。
        /// </summary>
        /// <param name="userFactory">用户工厂。</param>
        /// <param name="mockFactoryCallback">模拟的执行器工厂回调函数。</param>
        /// <param name="redisProvider">Redis 提供程序。若为 null 值表示启用基于应用程序域各种提供程序的服务容器。</param>
        /// <returns>返回一个服务容器。</returns>
        public static IIocContainer CreateContainer(IUserFactory userFactory
                                                    , Action <CommandModel.MockExecutorFactory> mockFactoryCallback = null
                                                    , IRedisProvider redisProvider = null)
        {
            if (userFactory == null)
            {
                throw new ArgumentNullException("userFactory");
            }

            var container = new IocContainer();

            container.AddService <IUserFactory>(userFactory);
            if (redisProvider != null)
            {
                container.AddService <IRedisProvider>(redisProvider);
            }

            if (mockFactoryCallback != null)
            {
                var executorFactory = new Aoite.CommandModel.MockExecutorFactory(container);
                mockFactoryCallback(executorFactory);
                container.AddService <CommandModel.IExecutorFactory>(executorFactory);
            }
            if (Db.Engine == null)
            {
                Lazy <IDbEngine> lazyEngine = new Lazy <IDbEngine>(() => new Aoite.Data.MsSqlEngine(""));
                container.AddService <IDbEngine>(lmps => Db.Engine == null ? lazyEngine.Value : Db.Context);
            }
            return(container);
        }
Beispiel #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisTaskProcessorsMonitoringMessageBus"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
        public RedisTaskProcessorMonitoringMessageBusReceiver(IRedisProvider provider)
            : base(provider)
        {
            this.AddChannelMapping(MessageBusChannel.TaskProcessorState, RedisMonitoringMessageBusChannels.TaskProcessorStateChannel);
            this.AddChannelMapping(MessageBusChannel.PerformanceReport, RedisMonitoringMessageBusChannels.PerformanceReportChannel);

            this.SubscribeTimeout = TimeSpan.FromSeconds(5);
        }
Beispiel #10
0
 public WorkerNode(ILogger <WorkerNode> logger
                   , IRedisProvider redisProvider
                   , IDistributedLocker distributedLocker)
 {
     _redisProvider     = redisProvider;
     _distributedLocker = distributedLocker;
     _logger            = logger;
 }
Beispiel #11
0
 public GameController(IGameAppService gameAppService,
                       IGameStatsService gameStatsService,
                       IRedisProvider redisProvider)
 {
     this.gameAppService   = gameAppService ?? throw new ArgumentNullException(nameof(gameAppService));
     this.gameStatsService = gameStatsService ?? throw new ArgumentNullException(nameof(gameStatsService));
     this.redisProvider    = redisProvider ?? throw new ArgumentNullException(nameof(redisProvider));
 }
Beispiel #12
0
 public RedisCahceTests(RedisCacheFixture fixture, ITestOutputHelper output)
 {
     _fixture           = fixture;
     _output            = output;
     _cache             = _fixture.Container.GetRequiredService <ICacheProvider>();
     _redisProvider     = _fixture.Container.GetRequiredService <IRedisProvider>();
     _distributedLocker = _fixture.Container.GetRequiredService <IDistributedLocker>();
 }
Beispiel #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisDateTimeProvider"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
        public RedisDateTimeProvider(IRedisProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            this.provider = provider;
        }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisTaskProcessorMessageBusReceiver"/> class.
 /// </summary>
 /// <param name="provider">The Redis provider to use.</param>
 /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
 public RedisTaskProcessorMessageBusReceiver(IRedisProvider provider)
     : base(provider)
 {
     this.AddChannelMapping(MessageBusChannel.MasterModeChangeRequest, RedisTaskProcessorChannels.MasterModeChangeRequestChannel);
     this.AddChannelMapping(MessageBusChannel.MasterModeChanged, RedisTaskProcessorChannels.MasterModeChangedChannel);
     this.AddChannelMapping(MessageBusChannel.StopTaskProcessor, RedisTaskProcessorChannels.StopTaskProcessorChannel);
     this.AddChannelMapping(MessageBusChannel.PerformanceMonitoringRequest, RedisTaskProcessorChannels.PerformanceMonitoringChannel);
     this.AddChannelMapping(MessageBusChannel.ConfigurationChanged, RedisTaskProcessorChannels.ConfigurationChangedChannel);
 }
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisTaskProcessorRepository"/> class.
 /// </summary>
 /// <param name="provider">The Redis provider to use.</param>
 /// <param name="serializer">The serializer to use.</param>
 public RedisTaskProcessorRepository(IRedisProvider provider, IEntityBinarySerializer serializer)
     : base(new RedisTaskRepository(provider, serializer),
            new RedisTaskRuntimeInfoRepository(provider, serializer),
            new RedisTaskProcessorRuntimeInfoRepository(provider),
            new RedisTaskSummaryRepository(provider, serializer),
            new RedisTaskJobSettingsRepository(provider, serializer),
            new RedisScheduledTaskRepository(provider, serializer))
 {
 }
Beispiel #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisTaskMonitoringMessageBusSender"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
        public RedisTaskMonitoringMessageBusSender(IRedisProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            this.provider = provider;
        }
Beispiel #17
0
        /// <summary>
        /// 创建一个模拟的服务。
        /// </summary>
        /// <typeparam name="TService">服务的类型。</typeparam>
        /// <param name="user">当前已授权的登录用户。</param>
        /// <param name="mockFactoryCallback">模拟的执行器工厂回调函数。</param>
        /// <param name="redisProvider">Redis 提供程序。若为 null 值表示启用基于应用程序域各种提供程序的服务容器。</param>
        /// <returns>服务的实例。</returns>
        public static TService CreateMockService <TService>(object user = null
                                                            , Action <MockExecutorFactory> mockFactoryCallback = null
                                                            , IRedisProvider redisProvider = null)
            where TService : IContainerProvider, new()
        {
            var service = new TService();

            service.Container = CreateContainer(user, mockFactoryCallback, redisProvider);
            return(service);
        }
Beispiel #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisTaskMonitoringMessageBus"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
        public RedisTaskMonitoringMessageBusReceiver(IRedisProvider provider)
            : base(provider)
        {
            this.AddChannelMapping(MessageBusChannel.TaskSubmitted, RedisMonitoringMessageBusChannels.TaskRequestedChannel);
            this.AddChannelMapping(MessageBusChannel.TaskProgress, RedisMonitoringMessageBusChannels.TaskProgressChannel);
            this.AddChannelMapping(MessageBusChannel.TaskCancelCompleted, RedisMonitoringMessageBusChannels.TaskCancelCompletedChannel);
            this.AddChannelMapping(MessageBusChannel.TaskFailed, RedisMonitoringMessageBusChannels.TaskFailedChannel);
            this.AddChannelMapping(MessageBusChannel.TaskCompleted, RedisMonitoringMessageBusChannels.TaskCompletedChannel);

            this.SubscribeTimeout = TimeSpan.FromSeconds(5);
        }
Beispiel #19
0
        /// <summary>
        /// 创建一个用于命令模型的服务容器。
        /// </summary>
        /// <param name="user">当前已授权的登录用户。</param>
        /// <param name="mockFactoryCallback">模拟的执行器工厂回调函数。</param>
        /// <param name="redisProvider">Redis 提供程序。若为 null 值表示启用基于应用程序域各种提供程序的服务容器。</param>
        /// <returns>返回一个服务容器。</returns>
        public static IIocContainer CreateContainer(object user = null
                                                    , Action <CommandModel.MockExecutorFactory> mockFactoryCallback = null
                                                    , IRedisProvider redisProvider = null)
        {
            var container = CreateContainer(new UserFactory(c => user));

            if (mockFactoryCallback != null)
            {
                var executorFactory = new Aoite.CommandModel.MockExecutorFactory(container);
                mockFactoryCallback(executorFactory);
                container.AddService <CommandModel.IExecutorFactory>(executorFactory);
            }
            return(container);
        }
Beispiel #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisTaskMessageBusSender"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <param name="masterCommandsQueue">The master commands queue where to push the master commands.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> or <paramref name="masterCommandsQueue"/> is null.</exception>
        public RedisTaskMessageBusSender(IRedisProvider provider, ITaskProcessorMessageQueue masterCommandsQueue)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (masterCommandsQueue == null)
            {
                throw new ArgumentNullException(nameof(masterCommandsQueue));
            }

            this.provider            = provider;
            this.masterCommandsQueue = masterCommandsQueue;
        }
Beispiel #21
0
        /// <summary>
        /// 创建一个用于命令模型的服务容器。
        /// </summary>
        /// <param name="userFactory">用户工厂。</param>
        /// <param name="redisProvider">Redis 提供程序。若为 null 值表示启用基于应用程序域各种提供程序的服务容器。</param>
        /// <returns>返回一个服务容器。</returns>
        public static IIocContainer CreateContainer(IUserFactory userFactory
                                                    , IRedisProvider redisProvider = null)
        {
            if (userFactory == null)
            {
                throw new ArgumentNullException("userFactory");
            }

            var container = new IocContainer();

            container.AddService <IUserFactory>(userFactory);
            if (redisProvider != null)
            {
                container.AddService <IRedisProvider>(redisProvider);
            }
            return(container);
        }
Beispiel #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisMessageBusReceiverBase"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
        protected RedisMessageBusReceiverBase(IRedisProvider provider)
        {
            this.debugName = this.GetType().Name;

            Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName));

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            this.provider = provider;

            this.subscription = provider.CreateSubscription();

            this.subscription.MessageReceived += this.OnMessageReceived;

            Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName));
        }
Beispiel #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisTaskJobSettingsRepository"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <param name="serializer">The serializer to use.</param>
        public RedisTaskJobSettingsRepository(IRedisProvider provider, IEntityBinarySerializer serializer)
        {
            Trace.WriteLine("ENTER: Constructing '{0}' ...".FormatInvariant(this.GetType().Name));

            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            this.provider   = provider;
            this.serializer = serializer;

            Trace.WriteLine("EXIT: '{0}' constructed.".FormatInvariant(this.GetType().Name));
        }
Beispiel #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisTaskProcessorMessageQueue"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <param name="serializer">The serializer to use for master commands serialization.</param>
        public RedisTaskProcessorMessageQueue(IRedisProvider provider, IEntityBinarySerializer serializer)
        {
            Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName));

            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            this.provider   = provider;
            this.serializer = serializer;

            this.subscription = provider.CreateSubscription();

            this.subscription.MessageReceived += this.OnMessageReceived;

            Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName));
        }
        public HybridStorage(IEnumerable<IStorageProvider> providers, IDaemonClient daemonClient, IPoolConfig poolConfig)
        {
            _daemonClient = daemonClient;
            _logger = Log.ForContext<HybridStorage>().ForContext("Component", poolConfig.Coin.Name);
            _coin = poolConfig.Coin.Name.ToLower(); // pool's associated coin name.

            // try loading providers.
            try
            {
                foreach (var provider in providers)
                {
                    if (provider is IRedisProvider)
                        _redisProvider = (IRedisProvider)provider;
                    else if (provider is IMySqlProvider)
                        _mySqlProvider = (IMySqlProvider)provider;
                }

                IsEnabled = (_redisProvider != null && _mySqlProvider != null);
            }
            catch (Exception e)
            {
                _logger.Error("Error initializing hybrid storage; {0:l}", e.Message);
            }
        }
Beispiel #26
0
 public RedisLock(string name, IRedisProvider redisProvider, RedisConfig redisConfig) : base(redisProvider, redisConfig)
 {
     Name = name;
     redisConfig.Prefix = redisConfig.Prefix + redisConfig.NamespaceSplitSymbol + Name;
 }
Beispiel #27
0
 public RedisCacheMonitor()
 {
     redisCache = new RedisProvider();
     Initialization();
 }
Beispiel #28
0
 /// <summary>
 /// 创建一个用于命令模型的服务容器。
 /// </summary>
 /// <param name="user">当前已授权的登录用户。</param>
 /// <param name="mockFactoryCallback">模拟的执行器工厂回调函数。</param>
 /// <param name="redisProvider">Redis 提供程序。若为 null 值表示启用基于应用程序域各种提供程序的服务容器。</param>
 /// <returns>服务容器。</returns>
 public static IIocContainer CreateContainer(object user = null
                                             , Action <MockExecutorFactory> mockFactoryCallback = null
                                             , IRedisProvider redisProvider = null)
 => CreateContainer(new UserFactory(c => user), mockFactoryCallback, redisProvider);
Beispiel #29
0
 /// <summary>
 /// 创建一个模拟的服务。
 /// </summary>
 /// <typeparam name="TService">服务的类型。</typeparam>
 /// <param name="mockFactoryCallback">模拟的执行器工厂回调函数。</param>
 /// <param name="redisProvider">Redis 提供程序。若为 null 值表示启用基于应用程序域各种提供程序的服务容器。</param>
 /// <returns>服务的实例。</returns>
 public static TService CreateMockService <TService>(Action <MockExecutorFactory> mockFactoryCallback = null
                                                     , IRedisProvider redisProvider = null)
     where TService : IContainerProvider, new()
 => CreateMockService <TService>(null, mockFactoryCallback, redisProvider);
 public RedisSessionStorage()
 {
     _redisCache = RedisFactory.GetProvider(RedisProviderGroup);
 }
Beispiel #31
0
 public BaseManager(IRedisProvider redisCache)
 {
     this.redisCache = redisCache;
 }