-
Notifications
You must be signed in to change notification settings - Fork 0
Hangfire added #18
base: master
Are you sure you want to change the base?
Hangfire added #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
using System.IO; | ||
using AutoMapper; | ||
using Hangfire; | ||
using Hangfire.Common; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused directive |
||
using Hangfire.Mongo; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need it here? |
||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Tinkoff.ISA.AppLayer; | ||
using Tinkoff.ISA.AppLayer.Jobs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jobs in API? |
||
using Tinkoff.ISA.Infrastructure.Settings; | ||
using Tinkoff.ISA.DAL; | ||
using Tinkoff.ISA.DAL.Common; | ||
using Tinkoff.ISA.Infrastructure.Configuration; | ||
using Tinkoff.ISA.Infrastructure.Extensions; | ||
using Tinkoff.ISA.Infrastructure.MongoDb; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see any reason to add reference with MongoDb here. |
||
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment; | ||
|
||
namespace Tinkoff.ISA.API | ||
|
@@ -40,10 +45,31 @@ public void ConfigureServices(IServiceCollection services) | |
services.AddAppDependencies(); | ||
services.AddMvc(); | ||
services.AddAutoMapper(); | ||
services.AddHangfire((serviceProvider, config) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems better to move it to Tinkoff.Isa.Infrastructure project, do you agree? to avoid duplications in API, Scheduler, SchedulerUI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason to have Hangfire in API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can remove it? |
||
{ | ||
var mongoContext = serviceProvider | ||
.GetService<IMongoContext>(); | ||
|
||
config.UseMongoStorage( | ||
mongoContext.MongoClient.Settings, | ||
"Jobs", | ||
new MongoStorageOptions | ||
{ | ||
MigrationOptions = new MongoMigrationOptions | ||
{ | ||
Strategy = MongoMigrationStrategy.Drop, | ||
BackupStrategy = MongoBackupStrategy.Collections | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's remove also here :) |
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | ||
public void Configure( | ||
IApplicationBuilder app, | ||
IHostingEnvironment env, | ||
ILoggerFactory loggerFactory, | ||
IRecurringJobManager recurringJobManager) | ||
{ | ||
var logSettings = _configuration.GetSection("Logging").Get<LoggingSettings>(); | ||
|
||
|
@@ -60,6 +86,22 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF | |
} | ||
|
||
app.UseMvc(); | ||
|
||
recurringJobManager.AddOrUpdate<JiraJob>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to add this reference to have an ability to configure new providers in main ISA project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, are you sure about further code placement in ISA.Jira, ISA.Confluence, etc? I supposed that we will have a core job that will ask IKnowledgeProvider for data (is it possible to create a job per each registered provider?). Is it necessary to force providers to depend on Hangfire? Correct me, if I'm wrong. |
||
nameof(JiraJob), | ||
job => job.StartJob(), | ||
Cron.Minutely | ||
); | ||
recurringJobManager.AddOrUpdate<ConfluenceJob>( | ||
nameof(ConfluenceJob), | ||
job => job.StartJob(), | ||
Cron.Minutely | ||
); | ||
recurringJobManager.AddOrUpdate<MongoIndexingForElasticJob>( | ||
nameof(MongoIndexingForElasticJob), | ||
job => job.StartJob(), | ||
Cron.Minutely | ||
); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
namespace Tinkoff.ISA.AppLayer.Jobs | ||
{ | ||
internal class ConfluenceJob : IJob | ||
public class ConfluenceJob : IJob | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going to move this to another project |
||
{ | ||
private readonly IConfluenceHttpClient _confluenceHttpClient; | ||
private readonly IElasticsearchClient _elasticsearchClient; | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the reason to change it to RunAsync? Is there any other processes?
Is there any difference in runtime level?