diff options
author | Aryadev Chavali <aryadevchavali1@gmail.com> | 2019-03-02 01:45:24 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadevchavali1@gmail.com> | 2019-03-02 01:45:24 +0000 |
commit | dece32e3615656d5ac76f2edd9da032c6452d274 (patch) | |
tree | 54f36518f05ba46e48c0b1972a95f2cd5c93f450 /Main/Startup.cs | |
parent | e547dfb8edf27861eeb65f7f7888610b760ecd0d (diff) | |
download | newsaggregator-dece32e3615656d5ac76f2edd9da032c6452d274.tar.gz newsaggregator-dece32e3615656d5ac76f2edd9da032c6452d274.tar.bz2 newsaggregator-dece32e3615656d5ac76f2edd9da032c6452d274.zip |
Using dependency injection and scoped services, can setup aggregator job to run without config
Diffstat (limited to 'Main/Startup.cs')
-rw-r--r-- | Main/Startup.cs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Main/Startup.cs b/Main/Startup.cs index 980e110..c077b6b 100644 --- a/Main/Startup.cs +++ b/Main/Startup.cs @@ -32,11 +32,13 @@ namespace Main { options.UseMySQL(Configuration.GetConnectionString("Storage"));
});
+ services.AddScoped<IAggregatorJob, AggregatorJob>();
+
services.AddHangfire(options => options.UseStorage(new MySqlStorage(Configuration.GetConnectionString("Storage"))));
services.AddDirectoryBrowser();
}
- public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IAggregatorJob aggregator) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
@@ -51,10 +53,7 @@ namespace Main { app.UseHangfireServer();
app.UseHangfireDashboard();
- RecurringJob.AddOrUpdate<AggregatorJob>(
- x => x.Start(Configuration.GetConnectionString("Aggregator")),
- Cron.HourInterval(3)
- );
+ RecurringJob.AddOrUpdate("aggregator", () => aggregator.Start(), Cron.HourInterval(3));
}
}
}
|