Skip to content

Commit

Permalink
refactor: Consolidated SessionServices into common
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrasseur-aneo committed Jul 4, 2023
1 parent 7764353 commit f7a47c5
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 503 deletions.

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),
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.

12 changes: 6 additions & 6 deletions Client/src/Unified/Factory/SessionServiceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,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 +92,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

0 comments on commit f7a47c5

Please sign in to comment.