Properly Dispose IStorageConnection (#1378)

Closes #1376
This commit is contained in:
tomy2105 2021-08-23 11:52:48 +02:00 committed by GitHub
parent d8c3504aa7
commit 9aeee3a15d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -101,7 +101,11 @@ namespace Elsa.Activities.Temporal.Hangfire.Services
_recurringJobManager.RemoveIfExists(job.Id);
}
private IEnumerable<RecurringJobDto> QueryRecurringJobs() => _jobStorage.GetConnection().GetRecurringJobs().Where(x => x.Job.Type == typeof(RunHangfireWorkflowDefinitionJob));
private IEnumerable<RecurringJobDto> QueryRecurringJobs() {
using (var connection = _jobStorage.GetConnection())
return connection.GetRecurringJobs().Where(x => x.Job.Type == typeof(RunHangfireWorkflowDefinitionJob));
}
private static RunHangfireWorkflowDefinitionJobModel GetJobModel(Job job) => (RunHangfireWorkflowDefinitionJobModel) job.Args[0];
private static RunHangfireWorkflowDefinitionJobModel CreateData(string workflowDefinitionId, string activityId, string? cronExpression = default) => new(workflowDefinitionId, activityId, cronExpression);

View file

@ -101,7 +101,11 @@ namespace Elsa.Activities.Temporal.Hangfire.Services
_recurringJobManager.RemoveIfExists(job.Id);
}
private IEnumerable<RecurringJobDto> QueryRecurringJobs() => _jobStorage.GetConnection().GetRecurringJobs().Where(x => x.Job.Type == typeof(RunHangfireWorkflowInstanceJob));
private IEnumerable<RecurringJobDto> QueryRecurringJobs() {
using (var connection = _jobStorage.GetConnection())
return connection.GetRecurringJobs().Where(x => x.Job.Type == typeof(RunHangfireWorkflowInstanceJob));
}
private static RunHangfireWorkflowInstanceJobModel GetJobModel(Job job) => (RunHangfireWorkflowInstanceJobModel) job.Args[0];
private static RunHangfireWorkflowInstanceJobModel CreateData(string workflowInstanceId, string activityId, string? cronExpression = default) => new(workflowInstanceId, activityId, cronExpression);
}