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

refactor: Consolidated SessionServices into common #194

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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

Large diffs are not rendered by default.

21 changes: 7 additions & 14 deletions Client/src/Symphony/ArmonikSymphonyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using ArmoniK.DevelopmentKit.Client.Common.Submitter;
using ArmoniK.DevelopmentKit.Common;

using JetBrains.Annotations;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

Expand All @@ -35,7 +37,6 @@ namespace ArmoniK.DevelopmentKit.Client.Symphony;
[MarkDownDoc]
public class ArmonikSymphonyClient
{
private readonly IConfigurationSection controlPlanSection_;
private readonly ILogger<ArmonikSymphonyClient> Logger;


Expand All @@ -48,38 +49,29 @@ public ArmonikSymphonyClient(IConfiguration configuration,
ILoggerFactory loggerFactory)
{
Configuration = configuration;
controlPlanSection_ = configuration.GetSection(SectionGrpc)
.Exists()
? configuration.GetSection(SectionGrpc)
: null;
LoggerFactory = loggerFactory;
Logger = loggerFactory.CreateLogger<ArmonikSymphonyClient>();
}

private ILoggerFactory LoggerFactory { get; }

/// <summary>
/// Returns the section key Grpc from appSettings.json
/// </summary>
public string SectionGrpc { get; set; } = "Grpc";

private ChannelPool GrpcPool { get; set; }


private IConfiguration Configuration { get; }

/// <summary>
/// Create the session to submit task
/// </summary>
/// <param name="taskOptions">Optional parameter to set TaskOptions during the Session creation</param>
/// <returns>Returns the SessionService to submit, wait or get result</returns>
[PublicAPI]
public SessionService CreateSession(TaskOptions taskOptions = null)
{
ControlPlaneConnection();

return new SessionService(GrpcPool,
LoggerFactory,
taskOptions);
taskOptions ?? SessionService.GetDefaultTaskOptions(EngineType.Symphony),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Options are not impacted in other clients ?

LoggerFactory);
}

/// <summary>
Expand All @@ -88,14 +80,15 @@ public SessionService CreateSession(TaskOptions taskOptions = null)
/// <param name="sessionId">The sessionId string which will opened</param>
/// <param name="clientOptions">the customer taskOptions send to the server by the client</param>
/// <returns>Returns the SessionService to submit, wait or get result</returns>
[PublicAPI]
public SessionService OpenSession(Session sessionId,
TaskOptions clientOptions = null)
{
ControlPlaneConnection();

return new SessionService(GrpcPool,
clientOptions ?? SessionService.GetDefaultTaskOptions(EngineType.Symphony),
LoggerFactory,
clientOptions ?? SessionService.InitializeDefaultTaskOptions(),
sessionId);
}

Expand Down
190 changes: 0 additions & 190 deletions Client/src/Symphony/SessionService.cs

This file was deleted.

13 changes: 6 additions & 7 deletions Client/src/Unified/Factory/SessionServiceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using ArmoniK.Api.gRPC.V1;
using ArmoniK.DevelopmentKit.Client.Common;
using ArmoniK.DevelopmentKit.Client.Common.Submitter;
using ArmoniK.DevelopmentKit.Client.Unified.Services;
using ArmoniK.DevelopmentKit.Client.Unified.Services.Admin;
using ArmoniK.DevelopmentKit.Common;

Expand Down Expand Up @@ -70,8 +69,8 @@ public SessionService CreateSession(Properties properties)
Logger?.LogDebug("Creating Session... ");

return new SessionService(GrpcPool,
LoggerFactory,
properties.TaskOptions);
properties.TaskOptions,
LoggerFactory);
}

private void ControlPlaneConnection(Properties properties)
Expand All @@ -92,15 +91,15 @@ private void ControlPlaneConnection(Properties properties)
/// <param name="properties">The properties setting for the session</param>
/// <param name="sessionId">SessionId previously opened</param>
/// <param name="clientOptions"></param>
public SessionService OpenSession(Properties properties,
string sessionId,
TaskOptions clientOptions = null)
public SessionService OpenSession(Properties properties,
string sessionId,
[CanBeNull] TaskOptions clientOptions = null)
{
ControlPlaneConnection(properties);

return new SessionService(GrpcPool,
clientOptions ?? SessionService.GetDefaultTaskOptions(EngineType.Unified),
LoggerFactory,
clientOptions,
new Session
{
Id = sessionId,
Expand Down
Loading