-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
118 additions
and
16 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
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,6 +1,6 @@ | ||
// This file is part of the ArmoniK project | ||
// | ||
// Copyright (C) ANEO, 2021-2023. All rights reserved. | ||
// Copyright (C) ANEO, 2021-2024. All rights reserved. | ||
// W. Kirschenmann <[email protected]> | ||
// J. Gurhem <[email protected]> | ||
// D. Dubuc <[email protected]> | ||
|
@@ -33,6 +33,9 @@ | |
|
||
namespace ArmoniK.Api.Client.Utils | ||
{ | ||
/// <summary> | ||
/// Extensions for configuring services | ||
/// </summary> | ||
public static class ServiceConfigExt | ||
{ | ||
private const string MaxAttemptsPropertyName = "maxAttempts"; | ||
|
@@ -46,16 +49,37 @@ public static class ServiceConfigExt | |
private const string MethodPropertyName = "method"; | ||
private const string RetryPolicyPropertyName = "retryPolicy"; | ||
|
||
/// <summary> | ||
/// Convert <see cref="ServiceConfig" /> to JSON | ||
/// </summary> | ||
/// <param name="config">Input config</param> | ||
/// <returns> | ||
/// A string containing the config in JSON format | ||
/// </returns> | ||
public static string ToJson(this ServiceConfig config) | ||
=> JsonConvert.SerializeObject(config.ToDict()); | ||
|
||
/// <summary> | ||
/// Convert <see cref="ServiceConfig" /> to dictionary | ||
/// </summary> | ||
/// <param name="config">Input service config</param> | ||
/// <returns> | ||
/// A dictionary containing the service config | ||
/// </returns> | ||
public static Dictionary<string, object> ToDict(this ServiceConfig config) | ||
=> new() | ||
{ | ||
[MethodConfigPropertyName] = config.MethodConfigs.Select(methodConfig => methodConfig.ToDict()) | ||
.ToArray(), | ||
}; | ||
|
||
/// <summary> | ||
/// Convert <see cref="MethodConfig" /> to dictionary | ||
/// </summary> | ||
/// <param name="config">Input method config</param> | ||
/// <returns> | ||
/// A dictionary containing the method config | ||
/// </returns> | ||
public static Dictionary<string, object> ToDict(this MethodConfig config) | ||
{ | ||
var dict = new Dictionary<string, object> | ||
|
@@ -71,6 +95,13 @@ public static Dictionary<string, object> ToDict(this MethodConfig config) | |
return dict; | ||
} | ||
|
||
/// <summary> | ||
/// Convert <see cref="MethodName" /> to dictionary | ||
/// </summary> | ||
/// <param name="methodName">Input method name</param> | ||
/// <returns> | ||
/// A dictionary containing the method name | ||
/// </returns> | ||
public static Dictionary<string, string> ToDict(this MethodName methodName) | ||
{ | ||
var dict = new Dictionary<string, string>(); | ||
|
@@ -87,6 +118,13 @@ public static Dictionary<string, string> ToDict(this MethodName methodName) | |
return dict; | ||
} | ||
|
||
/// <summary> | ||
/// Convert <see cref="RetryPolicy" /> to dictionary | ||
/// </summary> | ||
/// <param name="retryPolicy">Input retry policy</param> | ||
/// <returns> | ||
/// A dictionary containing the retry policy | ||
/// </returns> | ||
public static Dictionary<string, object> ToDict(this RetryPolicy retryPolicy) | ||
{ | ||
var dict = new Dictionary<string, object>(); | ||
|
@@ -122,7 +160,7 @@ public static Dictionary<string, object> ToDict(this RetryPolicy retryPolicy) | |
return dict; | ||
} | ||
|
||
public static string ToSimpleString(this Duration duration) | ||
private static string ToSimpleString(this Duration duration) | ||
=> duration.Seconds + (duration.Nanos > 0 | ||
? $".{duration.Nanos: D9}s" | ||
: "s"); | ||
|
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
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
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
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
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
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
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,6 +1,6 @@ | ||
// This file is part of the ArmoniK project | ||
// | ||
// Copyright (C) ANEO, 2021-2022. All rights reserved. | ||
// | ||
// Copyright (C) ANEO, 2021-2024. All rights reserved. | ||
// W. Kirschenmann <[email protected]> | ||
// J. Gurhem <[email protected]> | ||
// D. Dubuc <[email protected]> | ||
|
@@ -29,12 +29,9 @@ | |
|
||
using Google.Protobuf; | ||
|
||
using JetBrains.Annotations; | ||
|
||
namespace ArmoniK.Api.Worker.Worker; | ||
|
||
[PublicAPI] | ||
public static class TaskRequestExtensions | ||
internal static class TaskRequestExtensions | ||
{ | ||
public static IEnumerable<CreateTaskRequest> ToRequestStream(this IEnumerable<TaskRequest> taskRequests, | ||
TaskOptions? taskOptions, | ||
|
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