-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from dolittle:execution-context
execution-context
- Loading branch information
Showing
10 changed files
with
85 additions
and
17 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
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
15 changes: 15 additions & 0 deletions
15
Source/DotNET/Backend/Execution/ExecutionContextServiceCollectionExtensions.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Dolittle. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Dolittle.Vanir.Backend.Execution; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static class ExecutionContextServiceCollectionExtensions | ||
{ | ||
public static void AddExecutionContext(this IServiceCollection services) | ||
{ | ||
services.AddSingleton<IExecutionContextManager>(new ExecutionContextManager()); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Source/DotNET/Backend/Execution/IExecutionContextManager.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Dolittle. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Dolittle.SDK.Execution; | ||
using Dolittle.SDK.Tenancy; | ||
using ExecutionContext = Dolittle.SDK.Execution.ExecutionContext; | ||
|
||
namespace Dolittle.Vanir.Backend.Execution | ||
{ | ||
/// <summary> | ||
/// Defines a system for working with <see cref="ExecutionContext"/> | ||
/// </summary> | ||
public interface IExecutionContextManager | ||
{ | ||
/// <summary> | ||
/// Get the current <see cref="ExecutionContext"/> for the current call path. | ||
/// </summary> | ||
ExecutionContext Current { get; } | ||
|
||
/// <summary> | ||
/// Establish an <see cref="ExecutionContext"/> for current call path. | ||
/// </summary> | ||
/// <param name="tenantId"><see cref="TenantId"/> to establish for.</param> | ||
/// <param name="correlationId"><see cref="CorrelationId"/> to establish for.</param> | ||
/// <returns>Established <see cref="ExecutionContext"/>.</returns> | ||
ExecutionContext Establish(TenantId tenantId, CorrelationId correlationId); | ||
|
||
/// <summary> | ||
/// Set a <see cref="ExecutionContext"/> for current call path. | ||
/// </summary> | ||
/// <param name="context"><see cref="ExecutionContext"/> to set.</param> | ||
void Set(ExecutionContext context); | ||
} | ||
} |
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