-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the StreamClassRepository class (#27)
- Loading branch information
Showing
3 changed files
with
93 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json; | ||
using Akka.Util; | ||
using Akka.Util.Extensions; | ||
using Arcane.Operator.Models.StreamDefinitions; | ||
using Arcane.Operator.Models.StreamDefinitions.Base; | ||
|
||
namespace Arcane.Operator.Extensions; | ||
|
||
/// <summary> | ||
/// Extension methods for the JsonElement class | ||
/// </summary> | ||
public static class JsonElementExtensions | ||
{ | ||
/// <summary> | ||
/// Deserialize the JsonElement to IStreamDefinition object and wrap it in an Option{IStreamDefinition} object | ||
/// </summary> | ||
/// <param name="jsonElement">Element to deserialize</param> | ||
/// <returns></returns> | ||
public static Option<IStreamDefinition> AsOptionalStreamDefinition(this JsonElement jsonElement) => | ||
jsonElement.Deserialize<StreamDefinition>().AsOption<IStreamDefinition>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
using Arcane.Operator.Configurations; | ||
using System.Threading.Tasks; | ||
using Akka.Util; | ||
using Arcane.Operator.Models.StreamClass.Base; | ||
|
||
namespace Arcane.Operator.Services.Base; | ||
|
||
public interface IStreamClassRepository | ||
{ | ||
CustomResourceConfiguration Get(string nameSpace, string kind); | ||
Task<Option<IStreamClass>> Get(string nameSpace, string streamDefinitionKind); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters