tgstation-server 5.12.7
The /tg/station 13 server suite
Loading...
Searching...
No Matches
EventConsumer.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Threading;
4using System.Threading.Tasks;
5
8
10{
13 {
18
23
29 {
30 this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
31 }
32
34 public async Task HandleEvent(EventType eventType, IEnumerable<string> parameters, bool deploymentPipeline, CancellationToken cancellationToken)
35 {
36 ArgumentNullException.ThrowIfNull(parameters);
37
38 if (watchdog == null)
39 throw new InvalidOperationException("EventConsumer used without watchdog set!");
40
41 var scriptTask = configuration.HandleEvent(eventType, parameters, deploymentPipeline, cancellationToken);
42 await watchdog.HandleEvent(eventType, parameters, deploymentPipeline, cancellationToken);
43 await scriptTask;
44 }
45
51 {
52 ArgumentNullException.ThrowIfNull(watchdog);
53 if (this.watchdog != null)
54 throw new InvalidOperationException("watchdog already set!");
55
56 this.watchdog = watchdog;
57 }
58 }
59}
readonly IConfiguration configuration
The IConfiguration for the EventConsumer.
void SetWatchdog(IWatchdog watchdog)
Set the watchdog for the EventConsumer.
EventConsumer(IConfiguration configuration)
Initializes a new instance of the EventConsumer class.
async Task HandleEvent(EventType eventType, IEnumerable< string > parameters, bool deploymentPipeline, CancellationToken cancellationToken)
Handle a given eventType . A Task representing the running operation.
IWatchdog watchdog
The IWatchdog for the EventConsumer.
Consumes EventTypes and takes the appropriate actions.
Task HandleEvent(EventType eventType, IEnumerable< string > parameters, bool deploymentPipeline, CancellationToken cancellationToken)
Handle a given eventType .
For managing the Configuration directory.
Runs and monitors the twin server controllers.
Definition: IWatchdog.cs:16
EventType
Types of events. Mirror in tgs.dm.
Definition: EventType.cs:7