-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
82 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 8 additions & 14 deletions
22
src/modules/Elsa.Hangfire/Jobs/ExecuteBackgroundActivityJob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
using Elsa.Common.Multitenancy; | ||
using Elsa.Workflows.Runtime; | ||
using JetBrains.Annotations; | ||
|
||
namespace Elsa.Hangfire.Jobs; | ||
|
||
/// <summary> | ||
/// A job that executes a background activity. | ||
/// </summary> | ||
public class ExecuteBackgroundActivityJob | ||
[UsedImplicitly] | ||
public class ExecuteBackgroundActivityJob(IBackgroundActivityInvoker backgroundActivityInvoker, ITenantFinder tenantFinder, ITenantAccessor tenantAccessor) | ||
{ | ||
private readonly IBackgroundActivityInvoker _backgroundActivityInvoker; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExecuteBackgroundActivityJob"/> class. | ||
/// </summary> | ||
/// <param name="backgroundActivityInvoker"></param> | ||
public ExecuteBackgroundActivityJob(IBackgroundActivityInvoker backgroundActivityInvoker) | ||
{ | ||
_backgroundActivityInvoker = backgroundActivityInvoker; | ||
} | ||
|
||
/// <summary> | ||
/// Executes the job. | ||
/// </summary> | ||
public async Task ExecuteAsync(ScheduledBackgroundActivity scheduledBackgroundActivity, CancellationToken cancellationToken = default) | ||
public async Task ExecuteAsync(ScheduledBackgroundActivity scheduledBackgroundActivity, string? tenantId, CancellationToken cancellationToken = default) | ||
{ | ||
await _backgroundActivityInvoker.ExecuteAsync(scheduledBackgroundActivity, cancellationToken); | ||
var tenant = tenantId != null ? await tenantFinder.FindByIdAsync(tenantId, cancellationToken) : null; | ||
using var scope = tenantAccessor.PushContext(tenant); | ||
await backgroundActivityInvoker.ExecuteAsync(scheduledBackgroundActivity, cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters