Skip to content

Commit 31bec6b

Browse files
committed
Support user-specified connection limits (fixes #191)
1 parent 47c1d20 commit 31bec6b

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

src/corelib/Providers/Rackspace/ProviderBase`1.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public abstract class ProviderBase<TProvider>
4646
/// </summary>
4747
protected readonly IHttpResponseCodeValidator ResponseCodeValidator;
4848

49+
/// <summary>
50+
/// This is the backing field for <see cref="ConnectionLimit"/>.
51+
/// </summary>
52+
private int? _connectionLimit;
53+
4954
/// <summary>
5055
/// Initializes a new instance of the <see cref="ProviderBase{TProvider}"/> class using
5156
/// the specified default identity, identity provider, and REST service implementation,
@@ -73,6 +78,28 @@ protected ProviderBase(CloudIdentity defaultIdentity, IIdentityProvider identit
7378
ResponseCodeValidator = httpStatusCodeValidator ?? HttpResponseCodeValidator.Default;
7479
}
7580

81+
/// <summary>
82+
/// Gets or sets the maximum number of connections allowed on the <see cref="ServicePoint"/>
83+
/// objects used for requests. If the value is <c>null</c>, the connection limit value for the
84+
/// <see cref="ServicePoint"/> object is not altered.
85+
/// </summary>
86+
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="value"/> is less than or equal to 0.</exception>
87+
public int? ConnectionLimit
88+
{
89+
get
90+
{
91+
return _connectionLimit;
92+
}
93+
94+
set
95+
{
96+
if (value <= 0)
97+
throw new ArgumentOutOfRangeException("value");
98+
99+
_connectionLimit = value;
100+
}
101+
}
102+
76103
/// <summary>
77104
/// Execute a REST request with an <see cref="object"/> body and strongly-typed result.
78105
/// </summary>
@@ -469,7 +496,14 @@ protected virtual RequestSettings BuildDefaultRequestSettings(IEnumerable<HttpSt
469496
if(non200SuccessCodes != null)
470497
non200SuccessCodesAggregate.AddRange(non200SuccessCodes);
471498

472-
return new JsonRequestSettings { RetryCount = 2, RetryDelay = TimeSpan.FromMilliseconds(200), Non200SuccessCodes = non200SuccessCodesAggregate, UserAgent = UserAgentGenerator.UserAgent };
499+
return new JsonRequestSettings
500+
{
501+
RetryCount = 2,
502+
RetryDelay = TimeSpan.FromMilliseconds(200),
503+
Non200SuccessCodes = non200SuccessCodesAggregate,
504+
UserAgent = UserAgentGenerator.UserAgent,
505+
ConnectionLimit = ConnectionLimit,
506+
};
473507
}
474508

475509
/// <summary>

0 commit comments

Comments
 (0)