Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
40 changes: 39 additions & 1 deletion Client/src/Common/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class Properties
private const string SectionRetryBackoffMultiplier = "RetryBackoffMultiplier";
private const string SectionRetryMaxBackoff = "RetryMaxBackoff";

private const string SectionKeepAliveTime = "KeepAliveTime";
private const string SectionKeepAliveTimeInterval = "KeepAliveTimeInterval";

/// <summary>
/// The default configuration to submit task in a Session
/// </summary>
Expand Down Expand Up @@ -127,6 +130,11 @@ public Properties(TaskOptions options,
/// <param name="retryInitialBackoff">Initial retry backoff delay</param>
/// <param name="retryBackoffMultiplier">Retry backoff multiplier</param>
/// <param name="retryMaxBackoff">Max retry backoff</param>
/// <param name="proxy">Proxy url</param>
/// <param name="proxyUsername">Proxy Username</param>
/// <param name="proxyPassword">Proxy Password</param>
/// <param name="keepAliveTime">KeepAlive Time</param>
/// <param name="keepAliveTimeInterval">KeepAlive Time Interval</param>
/// <exception cref="ArgumentException"></exception>
public Properties(IConfiguration configuration,
TaskOptions options,
Expand All @@ -143,7 +151,9 @@ public Properties(IConfiguration configuration,
TimeSpan retryMaxBackoff = new(),
string? proxy = null,
string? proxyUsername = null,
string? proxyPassword = null)
string? proxyPassword = null,
TimeSpan keepAliveTime = new(),
TimeSpan keepAliveTimeInterval = new())
{
TaskOptions = options;
Configuration = configuration;
Expand Down Expand Up @@ -224,6 +234,24 @@ public Properties(IConfiguration configuration,
RetryMaxBackoff = TimeSpan.Parse(sectionGrpc[SectionRetryMaxBackoff]);
}

if (keepAliveTime != TimeSpan.Zero)
{
KeepAliveTime = keepAliveTime;
}
else if (!string.IsNullOrWhiteSpace(sectionGrpc?[SectionKeepAliveTime]))
{
KeepAliveTime = TimeSpan.Parse(sectionGrpc[SectionKeepAliveTime]);
}

if (keepAliveTimeInterval != TimeSpan.Zero)
{
KeepAliveTimeInterval = keepAliveTimeInterval;
}
else if (!string.IsNullOrWhiteSpace(sectionGrpc?[SectionKeepAliveTimeInterval]))
{
KeepAliveTime = TimeSpan.Parse(sectionGrpc[SectionKeepAliveTimeInterval]);
}


if (connectionPort != 0)
{
Expand Down Expand Up @@ -393,4 +421,14 @@ public string ConnectionString
/// Password for the proxy
/// </summary>
public string ProxyPassword { get; set; }

/// <summary>
/// TCP KeepAlive Time
/// </summary>
public TimeSpan KeepAliveTime { get; } = TimeSpan.FromSeconds(30);

/// <summary>
/// TCP KeepAlive Time Interval
/// </summary>
public TimeSpan KeepAliveTimeInterval { get; } = TimeSpan.FromSeconds(30);
}
Loading