-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceA.cs
More file actions
25 lines (20 loc) · 735 Bytes
/
ServiceA.cs
File metadata and controls
25 lines (20 loc) · 735 Bytes
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
namespace EventBusStuff;
public sealed class ServiceA {
private readonly IEventBus _eventBus;
public ServiceA(IEventBus eventBus) {
_eventBus = eventBus;
_eventBus.RegisterHandler(EventType.EVENT1, HandleEvent1);
_eventBus.RegisterHandler(EventType.EVENT3, HandleEvent3);
}
public async Task<object[]> FireEvent2() {
return await _eventBus.FireEvent(EventType.EVENT2);
}
private async Task<object?> HandleEvent1(object? payload = null) {
Console.WriteLine("Service A - Event 1");
return "Service A - Event 1 - Response";
}
private async Task<object?> HandleEvent3(object? payload = null) {
Console.WriteLine($"Service A - Event 3 :: {(string) payload!}");
return null;
}
}