-
Notifications
You must be signed in to change notification settings - Fork 2
/
StreamClassCommands.cs
61 lines (53 loc) · 2.66 KB
/
StreamClassCommands.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
58
59
60
using Arcane.Operator.Models.Api;
using Arcane.Operator.Models.Base;
using Arcane.Operator.Models.Resources;
using Arcane.Operator.Models.Resources.Status.V1Alpha1;
using Arcane.Operator.Models.Resources.StreamClass.Base;
using Arcane.Operator.Services.Base;
using Arcane.Operator.Services.Base.CommandHandlers;
namespace Arcane.Operator.Models.Commands;
/// <summary>
/// Possible stream class lifecycle phases.
/// </summary>
public enum StreamClassPhase
{
/// <summary>
/// A ready streaming class is ready to be used and new Streams of this class can be created.
/// </summary>
READY,
/// <summary>
/// An error occured in stream class controller and new Streams of this class can not be created.
/// </summary>
FAILED,
/// <summary>
/// The stream class is stopped and new Streams of this class can not be created.
/// </summary>
STOPPED
}
/// <summary>
/// Base class for stream class status update commands
/// </summary>
/// <param name="resourceName">Affected resource name</param>
/// <param name="request">Resource metadata required for the Kubernetes Custom Resource APIs</param>
/// <param name="conditions">Resource conditions</param>
/// <param name="phase">Resource phase</param>
/// <param name="streamClass">Affected resource</param>
public abstract record SetStreamClassStatusCommand(string resourceName,
CustomResourceApiRequest request, V1Alpha1StreamCondition[] conditions,
StreamClassPhase phase, IStreamClass streamClass) : SetResourceStatusCommand<V1Alpha1StreamCondition, StreamClassPhase>(request, conditions, phase);
/// <summary>
/// Update the stream class status command to Ready
/// </summary>
/// <param name="resourceName">Affected resource name</param>
/// <param name="request">Resource metadata required for the Kubernetes Custom Resource APIs</param>
/// <param name="streamClass">Affected resource</param>
public record SetStreamClassReady(string resourceName, CustomResourceApiRequest request, IStreamClass streamClass)
: SetStreamClassStatusCommand(resourceName, request, V1Alpha1StreamCondition.ReadyCondition, StreamClassPhase.READY, streamClass);
/// <summary>
/// Update the stream class status command to Stopped
/// </summary>
/// <param name="resourceName">Affected resource name</param>
/// <param name="request">Resource metadata required for the Kubernetes Custom Resource APIs</param>
/// <param name="streamClass">Affected resource</param>
public record SetStreamClassStopped(string resourceName, CustomResourceApiRequest request, IStreamClass streamClass)
: SetStreamClassStatusCommand(resourceName, request, V1Alpha1StreamCondition.WarningCondition, StreamClassPhase.STOPPED, streamClass);