-
Notifications
You must be signed in to change notification settings - Fork 36
/
IBrokerCallbacksInvoker.cs
57 lines (54 loc) · 2.18 KB
/
IBrokerCallbacksInvoker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2020 Sergio Aquilini
// This code is licensed under MIT license (see LICENSE file for details)
using System;
using System.Threading.Tasks;
namespace Silverback.Messaging.Broker.Callbacks
{
/// <summary>
/// Used to invoke the registered <see cref="IBrokerCallback" />.
/// </summary>
public interface IBrokerCallbacksInvoker
{
/// <summary>
/// Resolves and invokes all handlers of the specified type.
/// </summary>
/// <param name="action">
/// The action to be executed for each handler.
/// </param>
/// <param name="scopedServiceProvider">
/// The scoped <see cref="IServiceProvider" />. If not provided a new scope will be created.
/// </param>
/// <param name="invokeDuringShutdown">
/// Specifies whether the callback must be called even if the application is shutting down.
/// </param>
/// <typeparam name="THandler">
/// The type of the handler.
/// </typeparam>
void Invoke<THandler>(
Action<THandler> action,
IServiceProvider? scopedServiceProvider = null,
bool invokeDuringShutdown = true);
/// <summary>
/// Resolves and invokes all handlers of the specified type.
/// </summary>
/// <param name="action">
/// The action to be executed for each handler.
/// </param>
/// <param name="scopedServiceProvider">
/// The scoped <see cref="IServiceProvider" />. If not provided a new scope will be created.
/// </param>
/// <param name="invokeDuringShutdown">
/// Specifies whether the callback must be called even if the application is shutting down.
/// </param>
/// <typeparam name="THandler">
/// The type of the handler.
/// </typeparam>
/// <returns>
/// A <see cref="Task" /> representing the asynchronous operation.
/// </returns>
Task InvokeAsync<THandler>(
Func<THandler, Task> action,
IServiceProvider? scopedServiceProvider = null,
bool invokeDuringShutdown = true);
}
}