Skip to content

Commit f46e920

Browse files
authored
Merge pull request #123 from CyberSource/restclient-rewrite
Rewrite of RestClient usage
2 parents 11eb943 + 71d5f45 commit f46e920

File tree

8 files changed

+389
-516
lines changed

8 files changed

+389
-516
lines changed

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/core/MerchantConfig.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ public bool UseMLEGlobally
179179

180180
public string MleKeyAlias { get; set; }
181181

182+
public string MaxConnectionPoolSize { get; set; }
183+
184+
public string KeepAliveTime { get; set; }
185+
182186
public string MleForRequestPublicCertPath { get; set; }
183187

184188
#endregion
@@ -294,6 +298,24 @@ private void SetValuesFromAppConfig(NameValueCollection merchantConfigSection, D
294298
{
295299
MleKeyAlias = Constants.DefaultMleAliasForCert;
296300
}
301+
302+
if (merchantConfigSection["maxConnectionPoolSize"] != null)
303+
{
304+
MaxConnectionPoolSize = merchantConfigSection["maxConnectionPoolSize"];
305+
}
306+
else
307+
{
308+
MaxConnectionPoolSize = Constants.DefaultMaxConnectionPoolSize;
309+
}
310+
311+
if (merchantConfigSection["keepAliveTime"] != null)
312+
{
313+
KeepAliveTime = merchantConfigSection["keepAliveTime"];
314+
}
315+
else
316+
{
317+
KeepAliveTime = Constants.DefaultKeepAliveTime;
318+
}
297319
}
298320

299321
private void SetValuesUsingDictObj(IReadOnlyDictionary<string, string> merchantConfigDictionary, Dictionary<string,bool> mapToControlMLEonAPI)
@@ -558,6 +580,24 @@ private void SetValuesUsingDictObj(IReadOnlyDictionary<string, string> merchantC
558580
MleKeyAlias = Constants.DefaultMleAliasForCert;
559581
}
560582

583+
if (merchantConfigDictionary.ContainsKey("maxConnectionPoolSize"))
584+
{
585+
MaxConnectionPoolSize = merchantConfigDictionary["maxConnectionPoolSize"];
586+
}
587+
else
588+
{
589+
MaxConnectionPoolSize = Constants.DefaultMaxConnectionPoolSize;
590+
}
591+
592+
if (merchantConfigDictionary.ContainsKey("keepAliveTime"))
593+
{
594+
KeepAliveTime = merchantConfigDictionary["keepAliveTime"];
595+
}
596+
else
597+
{
598+
KeepAliveTime = Constants.DefaultKeepAliveTime;
599+
}
600+
561601
if (merchantConfigDictionary.ContainsKey("mleForRequestPublicCertPath") && !string.IsNullOrEmpty(merchantConfigDictionary["mleForRequestPublicCertPath"].Trim()))
562602
{
563603
MleForRequestPublicCertPath = merchantConfigDictionary["mleForRequestPublicCertPath"].Trim();
@@ -587,7 +627,7 @@ private void ValidateProperties()
587627

588628
if (string.IsNullOrEmpty(TimeOut))
589629
{
590-
TimeOut = string.Empty; // In Millisec
630+
TimeOut = Constants.DEFAULT_TIME_OUT; // In Millisec
591631
}
592632

593633
// setting up hostname based on the run environment value

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/util/Constants.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public static class Constants
4242

4343
public static readonly string LOG_REQUEST_AFTER_MLE = "LOG_REQUEST_AFTER_MLE: ";
4444

45+
public static readonly string DEFAULT_TIME_OUT = "100000"; // Time in milliseconds
46+
47+
public static readonly string DefaultMaxConnectionPoolSize = $"{int.MaxValue}";
48+
49+
// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-9.0
50+
public static readonly string DefaultKeepAliveTime = "300000"; // Time in milliseconds
4551
public static readonly string MLE_CACHE_IDENTIFIER_FOR_CONFIG_CERT = "mleCertFromMerchantConfig";
4652

4753
public static readonly string MLE_CACHE_IDENTIFIER_FOR_P12_CERT = "mleCertFromP12";

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/util/LogUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public string MaskSensitiveData(string str)
8585
catch (Exception e)
8686
{
8787
throw e;
88-
}
88+
}
8989
}
9090

9191
return str;

0 commit comments

Comments
 (0)