Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Context" /> class.
 /// </summary>
 /// <param name="configuration">The configuration string.</param>
 /// <param name="serializer">The serializer.</param>
 /// <param name="log">The textwriter to use for logging purposes.</param>
 public Context(string configuration, ISerializer serializer, TextWriter log)
 {
     _internalContext = new RedisProviderContext(configuration, serializer, log);
     _collectionProvider = new RedisCollectionProvider(_internalContext);
     _cacheProvider = new RedisCacheProvider(_internalContext);
     _geoProvider = new RedisGeoProvider(_internalContext);
     _pubsubProvider = new RedisPubSubProvider(_internalContext);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Context" /> class.
 /// </summary>
 /// <param name="configuration">The configuration string.</param>
 /// <param name="serializer">The serializer.</param>
 /// <param name="log">The textwriter to use for logging purposes.</param>
 public Context(string configuration, ISerializer serializer, TextWriter log)
 {
     _internalContext    = new RedisProviderContext(configuration, serializer, log);
     _cacheProvider      = new RedisCacheProvider(_internalContext);
     _collectionProvider = new RedisCollectionProvider(_internalContext, _cacheProvider);
     _geoProvider        = new RedisGeoProvider(_internalContext, _cacheProvider);
     _pubsubProvider     = new RedisPubSubProvider(_internalContext);
     _keyEventsProvider  = new RedisKeyEventsProvider(_internalContext);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisContext" /> class injecting the connection multiplexer and serializer to use.
 /// </summary>
 /// <param name="connection">The connection multiplexer to use.</param>
 /// <param name="serializer">The serializer.</param>
 public RedisContext(IConnectionMultiplexer connection, ISerializer serializer)
 {
     _internalContext    = new RedisProviderContext(connection, serializer ?? RedisContext.DefaultSerializer);
     _cacheProvider      = new RedisCacheProvider(_internalContext);
     _collectionProvider = new RedisCollectionProvider(_internalContext, _cacheProvider);
     _geoProvider        = new RedisGeoProvider(_internalContext, _cacheProvider);
     _pubsubProvider     = new RedisPubSubProvider(_internalContext);
     _keyEventsProvider  = new RedisKeyEventsProvider(_internalContext);
 }
Пример #4
0
 public OrderManager(IDataProvider dataProvider,
                     IPubSubProvider pubSubProvider,
                     IOptions <KafkaSettings> kafkaSettings,
                     IDeadlineManager deadlineManager
                     )
 {
     _pubSubProvider  = pubSubProvider;
     _dataProvider    = dataProvider;
     _kafkaSettings   = kafkaSettings;
     _deadlineManager = deadlineManager;
 }
Пример #5
0
        private static bool StartUpService()
        {
            try
            {
                var builder = new ConfigurationBuilder()
                              .AddJsonFile(Constant.AppSettingsFile, optional: false, reloadOnChange: true);

                _configuration = builder.Build();

                _kafkaSettings = new KafkaSettings();
                _configuration.GetSection("KafkaSettings").Bind(_kafkaSettings);

                var mongoDbSettings = new MongoDbSettings();
                _configuration.GetSection("MongoDbSettings").Bind(mongoDbSettings);

                var serviceProvider = new ServiceCollection()
                                      .AddSingleton <IPubSubProvider, KafkaProvider>()
                                      .AddSingleton <IOrderServiceManager, OrderServiceManager>()
                                      .AddSingleton <ILogProvider, LogProvider>()
                                      .AddSingleton <IMetricsProvider, PrometheusProvider>()
                                      .AddSingleton <IDataProvider, MongoDBProvider>(settings =>
                                                                                     new MongoDBProvider(mongoDbSettings.Host, mongoDbSettings.Database, mongoDbSettings.OrderCollection))
                                      .Configure <KafkaSettings>(_configuration.GetSection("KafkaSettings"))
                                      .AddOptions()
                                      .BuildServiceProvider();

                _pubSubProvider      = serviceProvider.GetService <IPubSubProvider>();
                _orderServiceManager = serviceProvider.GetService <IOrderServiceManager>();
                _logProvider         = serviceProvider.GetService <ILogProvider>();
                _metricsProvider     = serviceProvider.GetService <IMetricsProvider>();
                var dbProvider = serviceProvider.GetService <IDataProvider>();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #6
0
 public LogProvider(IPubSubProvider pubSubProvider, IOptions <KafkaSettings> kafkaSettings)
 {
     _pubSubProvider = pubSubProvider;
     _kafkaSettings  = kafkaSettings;
 }