Esempio n. 1
0
        public static void AddRedbox(this IServiceCollection services, Action <RedboxOptions> configure)
        {
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            services.AddSingleton <IRedbox, Redbox>();
            services.AddSingleton <IDispatcher, Dispatcher>();
            services.AddSingleton <ICacheProxy, CacheProxy>();

            services.TryAddEnumerable(
                new[]
            {
                ServiceDescriptor.Singleton <IWorker, KeyPostman>(),
                ServiceDescriptor.Singleton <IWorker, KeyRetrier>(),
                ServiceDescriptor.Singleton <IWorker, KeyCleaner>()
            });

            var options = new RedboxOptions();

            configure(options);
            options.Plugins.ForEach(plugin => plugin.Register(services));
            services.Configure(configure);

            services.AddSingleton <IRedboxEntry, RedboxEntry>();
            services.AddHostedService <RedboxEntry>();
        }
Esempio n. 2
0
 public SqlServerKeyStorage(
     IOptions <SqlServerOptions> options,
     IOptions <RedboxOptions> redboxOptions,
     IStorageBoost storageBoost)
 {
     _options       = options.Value;
     _redboxOptions = redboxOptions.Value;
     _boost         = storageBoost;
 }
Esempio n. 3
0
 public Dispatcher(
     ILogger <Dispatcher> logger,
     IOptions <RedboxOptions> options,
     ICacheClientFactory cacheFactory)
 {
     _cts          = new CancellationTokenSource();
     _keysBuffer   = Channel.CreateUnbounded <IEnumerable <string> >();
     _logger       = logger;
     _options      = options.Value;
     _cacheFactory = cacheFactory;
 }
Esempio n. 4
0
 public static RedboxOptions UseRedis(this RedboxOptions options, Action <RedisOptions> configure)
 {
     options.RegisterPlugin(new RedisPlugin(configure));
     return(options);
 }
Esempio n. 5
0
 public static RedboxOptions UseRedis(this RedboxOptions options)
 {
     options.RegisterPlugin(new RedisPlugin());
     return(options);
 }
Esempio n. 6
0
 public static RedboxOptions UseSqlServer(this RedboxOptions options, Action <SqlServerOptions> configure)
 {
     options.RegisterPlugin(new SqlServerPlugin(configure));
     return(options);
 }
Esempio n. 7
0
 public static RedboxOptions UseSqlServer(this RedboxOptions options)
 {
     options.RegisterPlugin(new SqlServerPlugin());
     return(options);
 }