Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add missing xml-doc #476

Merged
merged 6 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/csharp/ArmoniK.Api.Client/Options/GrpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ namespace ArmoniK.Api.Client.Options
[PublicAPI]
public class GrpcClient
{
/// <summary>
/// Path to the section containing the values in the configuration object
/// </summary>
public const string SettingSection = nameof(GrpcClient);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

namespace ArmoniK.Api.Common.Channel.Utils;

/// <summary>
/// Provides a built gRPC Channel from given options
/// </summary>
[UsedImplicitly]
public sealed class GrpcChannelProvider : IAsyncDisposable
{
Expand All @@ -46,6 +49,12 @@ public sealed class GrpcChannelProvider : IAsyncDisposable
private NetworkStream? networkStream_;
private Socket? socket_;

/// <summary>
/// Instantiate a <see cref="GrpcChannelProvider" /> that creates a gRPC channel
/// </summary>
/// <param name="options">Options to configure the creation of the gRPC channel</param>
/// <param name="logger">Logger that will produce logs</param>
/// <exception cref="InvalidOperationException">when address is empty</exception>
public GrpcChannelProvider(GrpcChannel options,
ILogger<GrpcChannelProvider> logger)
{
Expand All @@ -56,6 +65,7 @@ public GrpcChannelProvider(GrpcChannel options,
address_);
}

/// <inheritdoc />
public async ValueTask DisposeAsync()
{
socket_?.Close();
Expand Down Expand Up @@ -114,6 +124,11 @@ await socket_.ConnectAsync(udsEndPoint,
});
}

/// <summary>
/// Access the created gRPC Channel
aneojgurhem marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
/// <returns>The created gRPC Channel</returns>
/// <exception cref="InvalidOperationException">when socket type is unknown</exception>
public ChannelBase Get()
{
switch (options_.SocketType)
Expand Down
7 changes: 5 additions & 2 deletions packages/csharp/ArmoniK.Api.Common/Options/GrpcChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@

namespace ArmoniK.Api.Common.Options;

/// <summary>
/// Options to configure a channel from gRPC
/// </summary>
[PublicAPI]
public class GrpcChannel
{
/// <summary>
/// Address or path of the resource used to communicate for this Grpc Channel
/// Address or path of the resource used to communicate for this gRPC Channel
/// </summary>
public string Address { get; set; } = "/tmp/armonik.sock";

/// <summary>
/// Type of Grpc Socket used
/// Type of gRPC Socket used
/// </summary>
public GrpcSocketType SocketType { get; set; } = GrpcSocketType.UnixDomainSocket;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@

namespace ArmoniK.Api.Worker.Utils;

/// <summary>
/// Wrapper to add nice logs during application lifetime
/// </summary>
public class ApplicationLifeTimeManager
{
private readonly IHostApplicationLifetime lifetime_;
private readonly ILogger<ApplicationLifeTimeManager> logger_;

/// <summary>
/// Instantiate a wrapper to add nice logs during application lifetime
/// </summary>
/// <param name="logger">Logger that will produce logs</param>
/// <param name="lifetime">Application lifetime to attach events</param>
public ApplicationLifeTimeManager(ILogger<ApplicationLifeTimeManager> logger,
IHostApplicationLifetime lifetime)
{
Expand Down
2 changes: 1 addition & 1 deletion packages/csharp/ArmoniK.Api.Worker/Utils/WorkerServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static WebApplication Create<T>(Action<IServiceCollection, IConfiguration
var computePlanOptions = builder.Configuration.GetRequiredSection(ComputePlane.SettingSection)
.Get<ComputePlane>();

if (computePlanOptions.WorkerChannel == null)
if (computePlanOptions?.WorkerChannel == null)
lemaitre-aneo marked this conversation as resolved.
Show resolved Hide resolved
{
throw new Exception($"{nameof(computePlanOptions.WorkerChannel)} options should not be null");
}
Expand Down
14 changes: 14 additions & 0 deletions packages/csharp/ArmoniK.Api.Worker/Worker/TaskHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public IEnumerable<byte[]> Values
=> dataDependencies_.Select(key => this[key]);
}

/// <summary>
/// Task handler that unifies task execution and calls to the Agent
/// </summary>
public class TaskHandler : ITaskHandler
{
private readonly CancellationToken cancellationToken_;
Expand All @@ -120,6 +123,14 @@ public class TaskHandler : ITaskHandler
private readonly ILoggerFactory loggerFactory_;


/// <summary>
/// Instantiate task handler that unifies task execution and calls to the Agent
/// </summary>
/// <param name="processRequest">Task execution request</param>
/// <param name="client">Client to the agent</param>
/// <param name="loggerFactory">Logger factory used to create loggers</param>
/// <param name="cancellationToken">Token used to cancel the execution of the method</param>
/// <exception cref="InvalidOperationException">when payload is not found</exception>
public TaskHandler(ProcessRequest processRequest,
Agent.AgentClient client,
ILoggerFactory loggerFactory,
Expand Down Expand Up @@ -153,6 +164,9 @@ public TaskHandler(ProcessRequest processRequest,
}
}

/// <summary>
/// Communication token used to identify requests
/// </summary>
public string Token { get; }

/// <inheritdoc />
Expand Down
18 changes: 17 additions & 1 deletion packages/csharp/ArmoniK.Api.Worker/Worker/WorkerStreamWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@

namespace ArmoniK.Api.Worker.Worker;

/// <summary>
/// Wrapper implementation that provide a simpler interface to use for tasks implementations in C#
/// </summary>
[PublicAPI]
public class WorkerStreamWrapper : gRPC.V1.Worker.Worker.WorkerBase, IAsyncDisposable
{
private readonly ChannelBase channel_;
private readonly Agent.AgentClient client_;
private readonly ILogger<WorkerStreamWrapper> logger_;
private readonly ILoggerFactory loggerFactory_;
public ILogger<WorkerStreamWrapper> logger_;

/// <summary>
/// Instantiate a simpler interface to use for tasks implementations
/// </summary>
/// <param name="loggerFactory">LoggerFactory to create loggers</param>
/// <param name="provider">gRPC channel provider to create channels with the Agent</param>
public WorkerStreamWrapper(ILoggerFactory loggerFactory,
GrpcChannelProvider provider)
{
Expand Down Expand Up @@ -87,6 +95,14 @@ public sealed override async Task<ProcessReply> Process(ProcessRequest reques
};
}

/// <summary>
/// User defined computations
/// </summary>
/// <param name="taskHandler">Handler to access input data and task capabilities</param>
/// <returns>
/// The output of the computational task
/// </returns>
/// <exception cref="RpcException">when method is not overwritten</exception>
public virtual Task<Output> Process(ITaskHandler taskHandler)
=> throw new RpcException(new Status(StatusCode.Unimplemented,
""));
Expand Down
Loading