public static void Start() { var muxer = ConnectionMultiplexer.Connect(EnvironmentReader.FromEnvironment().RedisConnectionString); var timerProvider = new RealTimerProvider(); var worker = new BackgroundWorker(muxer, timerProvider, new JobQueueFactory(muxer.GetDatabase(Constants.Redis.PACKAGES_DB)) .ForQueueName(Constants.Redis.PackageCrawlerJobQueueName)); worker.Run(); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc().AddJsonOptions(json => { json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); var builder = new ContainerBuilder(); builder.Register(_ => EnvironmentReader.FromEnvironment()); builder.RegisterType <LatestPackagesQuery>().As <ILatestPackagesIndex>(); builder.RegisterType <Nuget.NugetApi>().As <Nuget.INugetApi>().InstancePerLifetimeScope(); builder.RegisterType <JobQueueFactory>().As <IJobQueueFactory>(); builder.Register((Func <IComponentContext, Query.RedisGetSetQuery <Package> >)(cc => new RedisGetSetQuery <Package>(cc.Resolve <IDatabase>(), api.Env.Constants.Redis.PackageKeyForName))).As <IGetSetQuerier <Package> >(); builder.Register(BuildConnectionMultiplexer).As <ConnectionMultiplexer>().SingleInstance(); builder.Register(componentContext => componentContext.Resolve <ConnectionMultiplexer>().GetDatabase(api.Env.Constants.Redis.PACKAGES_DB)).As <IDatabase>().InstancePerLifetimeScope(); builder.Populate(services); var container = builder.Build(); return(container.Resolve <IServiceProvider>()); }