Skip to content

Commit

Permalink
Added proxy settings to properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrasseur-aneo authored and lemaitre-aneo committed May 31, 2024
1 parent 7c948d3 commit 9960a72
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
37 changes: 31 additions & 6 deletions Client/src/Common/Properties.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// This file is part of the ArmoniK project
//
// Copyright (C) ANEO, 2021-2023. All rights reserved.
//
//
// Copyright (C) ANEO, 2021-$CURRENT_YEAR$. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using System;

Expand Down Expand Up @@ -50,6 +51,9 @@ public class Properties
private const string SectionClientKey = "ClientKey";
private const string SectionClientCertP12 = "ClientP12";
private const string SectionTargetNameOverride = "EndpointNameOverride";
private const string SectionProxy = "Proxy";
private const string SectionProxyUsername = "ProxyUsername";
private const string SectionProxyPassword = "ProxyPassword";

private const string SectionRetryInitialBackoff = "RetryInitialBackoff";
private const string SectionRetryBackoffMultiplier = "RetryBackoffMultiplier";
Expand Down Expand Up @@ -137,7 +141,10 @@ public Properties(IConfiguration configuration,
bool? sslValidation = null,
TimeSpan retryInitialBackoff = new(),
double retryBackoffMultiplier = 0,
TimeSpan retryMaxBackoff = new())
TimeSpan retryMaxBackoff = new(),
string? proxy = null,
string? proxyUsername = null,
string? proxyPassword = null)
{
TaskOptions = options;
Configuration = configuration;
Expand Down Expand Up @@ -186,6 +193,9 @@ public Properties(IConfiguration configuration,
ClientCertFilePem = clientCertFilePem ?? sectionGrpc[SectionClientCert] ?? string.Empty;
ClientKeyFilePem = clientKeyFilePem ?? sectionGrpc[SectionClientKey] ?? string.Empty;
ClientP12File = clientP12 ?? sectionGrpc[SectionClientCertP12] ?? string.Empty;
Proxy = proxy ?? sectionGrpc[SectionProxy] ?? string.Empty;
ProxyUsername = proxyUsername ?? sectionGrpc[SectionProxyUsername] ?? string.Empty;
ProxyPassword = proxyPassword ?? sectionGrpc[SectionProxyPassword] ?? string.Empty;

if (retryInitialBackoff != TimeSpan.Zero)
{
Expand Down Expand Up @@ -369,4 +379,19 @@ public string ConnectionString
/// Max backoff for retries
/// </summary>
public TimeSpan RetryMaxBackoff { get; } = TimeSpan.FromSeconds(30);

/// <summary>
/// Proxy URL
/// </summary>
public string Proxy { get; set; }

/// <summary>
/// Username for the proxy
/// </summary>
public string ProxyUsername { get; set; }

/// <summary>
/// Password for the proxy
/// </summary>
public string ProxyPassword { get; set; }
}
5 changes: 5 additions & 0 deletions Client/src/Common/Submitter/ClientServiceConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static ChannelPool ControlPlaneConnectionPool(Properties properties,
KeyPem = properties.ClientKeyFilePem,
Endpoint = properties.ControlPlaneUri.ToString(),
OverrideTargetName = properties.TargetNameOverride,
BackoffMultiplier = properties.RetryBackoffMultiplier,
InitialBackOff = properties.RetryInitialBackoff,
Proxy = properties.Proxy,
ProxyUsername = properties.ProxyUsername,
ProxyPassword = properties.ProxyPassword,
};

return new ChannelPool(() => GrpcChannelFactory.CreateChannel(options,
Expand Down

0 comments on commit 9960a72

Please sign in to comment.