@@ -27,15 +27,13 @@ public sealed class Builder
27
27
28
28
private EndpointVerificationStrategy _verificationStrategy ;
29
29
30
- internal EndpointRoutingStrategy RoutingStrategy
31
- {
32
- get { return _routingStrategy ?? EndpointRoutingStrategy . Default ; }
33
- }
30
+ private TimeSpan ? _httpGetTimeout ;
34
31
35
- internal EndpointVerificationStrategy VerificationStrategy
36
- {
37
- get { return _verificationStrategy ?? EndpointVerificationStrategy . Default ; }
38
- }
32
+ private EndpointRoutingStrategy RoutingStrategy => _routingStrategy ?? EndpointRoutingStrategy . Default ;
33
+
34
+ private EndpointVerificationStrategy VerificationStrategy => _verificationStrategy ?? EndpointVerificationStrategy . Default ;
35
+
36
+ internal TimeSpan ? HttpGetTimeout => _httpGetTimeout ;
39
37
40
38
/// <summary>
41
39
/// Verifies the passed <paramref name="uris" /> first to ensure that they are <see cref="Uri.IsAbsoluteUri" />. Then
@@ -54,19 +52,22 @@ public async Task<EndpointPool> VerifyAndBuild(params Uri[] uris)
54
52
{
55
53
if ( uris == null || ! uris . Any ( ) )
56
54
{
57
- throw new ArgumentNullException ( " uris" , "You must supply at least 1 Uri" ) ;
55
+ throw new ArgumentNullException ( nameof ( uris ) , "You must supply at least 1 Uri" ) ;
58
56
}
59
57
var invalidUris = uris . Where ( x => ! x . IsAbsoluteUri ) . ToList ( ) ;
60
58
if ( invalidUris . Any ( ) )
61
59
{
62
60
throw new ArgumentException (
63
- string . Format ( "The following Uri(s) are not valid absolute Uri(s): '{0}'" , string . Join ( ", " , invalidUris ) ) ,
64
- " uris"
61
+ $ "The following Uri(s) are not valid absolute Uri(s): '{ string . Join ( ", " , invalidUris ) } '" ,
62
+ nameof ( uris )
65
63
) ;
66
64
}
67
65
var endpoints = await VerificationStrategy . Verify ( uris ) ;
68
66
69
- return new EndpointPool ( endpoints , RoutingStrategy ) ;
67
+ return new EndpointPool ( endpoints , RoutingStrategy )
68
+ {
69
+ HttpGetTimeout = _httpGetTimeout
70
+ } ;
70
71
}
71
72
72
73
/// <summary>
@@ -77,7 +78,7 @@ public Builder WithRoutingStrategy(EndpointRoutingStrategy routingStrategy)
77
78
{
78
79
if ( routingStrategy == null )
79
80
{
80
- throw new ArgumentNullException ( " routingStrategy" ) ;
81
+ throw new ArgumentNullException ( nameof ( routingStrategy ) ) ;
81
82
}
82
83
_routingStrategy = routingStrategy ;
83
84
return this ;
@@ -91,12 +92,27 @@ public Builder WithVerificationStrategy(EndpointVerificationStrategy verificatio
91
92
{
92
93
if ( verificationStrategy == null )
93
94
{
94
- throw new ArgumentNullException ( " verificationStrategy" ) ;
95
+ throw new ArgumentNullException ( nameof ( verificationStrategy ) ) ;
95
96
}
96
97
_verificationStrategy = verificationStrategy ;
97
98
return this ;
98
99
}
99
100
101
+ /// <summary>
102
+ /// Sets the default timeout for HTTP GET requests
103
+ /// </summary>
104
+ /// <param name="httpGetTimeout"></param>
105
+ /// <returns></returns>
106
+ public Builder WithHttpReadTimeout ( TimeSpan httpGetTimeout )
107
+ {
108
+ if ( httpGetTimeout == null )
109
+ {
110
+ throw new ArgumentNullException ( nameof ( httpGetTimeout ) ) ;
111
+ }
112
+ _httpGetTimeout = httpGetTimeout ;
113
+ return this ;
114
+ }
115
+
100
116
}
101
117
102
118
}
0 commit comments