-
Notifications
You must be signed in to change notification settings - Fork 2
/
StreamDefinitionRepository.cs
45 lines (40 loc) · 1.71 KB
/
StreamDefinitionRepository.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
using System.Threading.Tasks;
using Akka;
using Akka.Streams;
using Akka.Streams.Dsl;
using Akka.Util;
using Arcane.Operator.Extensions;
using Arcane.Operator.Models.Api;
using Arcane.Operator.Models.Resources.StreamDefinitions;
using Arcane.Operator.Models.StreamDefinitions.Base;
using Arcane.Operator.Services.Base.Repositories.CustomResources;
using Snd.Sdk.Kubernetes.Base;
namespace Arcane.Operator.Services.Repositories.CustomResources;
public class StreamDefinitionRepository : IReactiveResourceCollection<IStreamDefinition>,
IResourceCollection<IStreamDefinition>
{
private readonly IKubeCluster kubeCluster;
public StreamDefinitionRepository(IKubeCluster kubeCluster)
{
this.kubeCluster = kubeCluster;
}
/// <inheritdoc cref="IReactiveResourceCollection{TResourceType}.GetEvents"/>
public Source<ResourceEvent<IStreamDefinition>, NotUsed> GetEvents(CustomResourceApiRequest request,
int maxBufferCapacity) =>
this.kubeCluster.StreamCustomResourceEvents<StreamDefinition>(
request.Namespace,
request.ApiGroup,
request.ApiVersion,
request.PluralName,
maxBufferCapacity,
OverflowStrategy.Fail)
.Select(tuple => new ResourceEvent<IStreamDefinition>(tuple.Item1, tuple.Item2));
/// <inheritdoc cref="IResourceCollection{TResourceType}.Get"/>
public Task<Option<IStreamDefinition>> Get(string name, CustomResourceApiRequest request) =>
this.kubeCluster.GetCustomResource(request.ApiGroup,
request.ApiVersion,
request.PluralName,
request.Namespace,
name,
element => element.AsOptionalStreamDefinition());
}