@@ -119,12 +119,12 @@ private void UpdateCluster(VirtualCluster cluster)
119119 private bool IsPingRequest ( Endpoint endpoint ) => _productRegistration . IsPingRequest ( endpoint ) ;
120120
121121 /// <inheritdoc cref="IRequestInvoker.RequestAsync{TResponse}"/>>
122- public Task < TResponse > RequestAsync < TResponse > ( Endpoint endpoint , RequestData requestData , PostData ? postData , CancellationToken cancellationToken )
122+ public Task < TResponse > RequestAsync < TResponse > ( Endpoint endpoint , BoundConfiguration boundConfiguration , PostData ? postData , CancellationToken cancellationToken )
123123 where TResponse : TransportResponse , new ( ) =>
124- Task . FromResult ( Request < TResponse > ( endpoint , requestData , postData ) ) ;
124+ Task . FromResult ( Request < TResponse > ( endpoint , boundConfiguration , postData ) ) ;
125125
126126 /// <inheritdoc cref="IRequestInvoker.Request{TResponse}"/>>
127- public TResponse Request < TResponse > ( Endpoint endpoint , RequestData requestData , PostData ? postData )
127+ public TResponse Request < TResponse > ( Endpoint endpoint , BoundConfiguration boundConfiguration , PostData ? postData )
128128 where TResponse : TransportResponse , new ( )
129129 {
130130 if ( ! _calls . ContainsKey ( endpoint . Uri . Port ) )
@@ -138,11 +138,11 @@ public TResponse Request<TResponse>(Endpoint endpoint, RequestData requestData,
138138 _ = Interlocked . Increment ( ref state . Sniffed ) ;
139139 return HandleRules < TResponse , ISniffRule > (
140140 endpoint ,
141- requestData ,
141+ boundConfiguration ,
142142 postData ,
143143 nameof ( VirtualCluster . Sniff ) ,
144144 _cluster . SniffingRules ,
145- requestData . RequestTimeout ,
145+ boundConfiguration . RequestTimeout ,
146146 ( r ) => UpdateCluster ( r . NewClusterState ) ,
147147 ( r ) => _productRegistration . CreateSniffResponseBytes ( _cluster . Nodes , _cluster . ElasticsearchVersion , _cluster . PublishAddressOverride , _cluster . SniffShouldReturnFqnd )
148148 ) ;
@@ -152,36 +152,36 @@ public TResponse Request<TResponse>(Endpoint endpoint, RequestData requestData,
152152 _ = Interlocked . Increment ( ref state . Pinged ) ;
153153 return HandleRules < TResponse , IRule > (
154154 endpoint ,
155- requestData ,
155+ boundConfiguration ,
156156 postData ,
157157 nameof ( VirtualCluster . Ping ) ,
158158 _cluster . PingingRules ,
159- requestData . PingTimeout ,
159+ boundConfiguration . PingTimeout ,
160160 ( r ) => { } ,
161161 ( r ) => null //HEAD request
162162 ) ;
163163 }
164164 _ = Interlocked . Increment ( ref state . Called ) ;
165165 return HandleRules < TResponse , IClientCallRule > (
166166 endpoint ,
167- requestData ,
167+ boundConfiguration ,
168168 postData ,
169169 nameof ( VirtualCluster . ClientCalls ) ,
170170 _cluster . ClientCallRules ,
171- requestData . RequestTimeout ,
171+ boundConfiguration . RequestTimeout ,
172172 ( r ) => { } ,
173173 CallResponse
174174 ) ;
175175 }
176176 catch ( TheException e )
177177 {
178- return ResponseFactory . Create < TResponse > ( endpoint , requestData , postData , e , null , null , Stream . Null , null , - 1 , null , null ) ;
178+ return ResponseFactory . Create < TResponse > ( endpoint , boundConfiguration , postData , e , null , null , Stream . Null , null , - 1 , null , null ) ;
179179 }
180180 }
181181
182182 private TResponse HandleRules < TResponse , TRule > (
183183 Endpoint endpoint ,
184- RequestData requestData ,
184+ BoundConfiguration boundConfiguration ,
185185 PostData ? postData ,
186186 string origin ,
187187 IList < TRule > rules ,
@@ -203,28 +203,28 @@ private TResponse HandleRules<TResponse, TRule>(
203203 if ( rule . OnPort == null || rule . OnPort . Value != endpoint . Uri . Port ) continue ;
204204
205205 if ( always )
206- return Always < TResponse , TRule > ( endpoint , requestData , postData , timeout , beforeReturn , successResponse , rule ) ;
206+ return Always < TResponse , TRule > ( endpoint , boundConfiguration , postData , timeout , beforeReturn , successResponse , rule ) ;
207207
208208 if ( rule . ExecuteCount > times ) continue ;
209209
210- return Sometimes < TResponse , TRule > ( endpoint , requestData , postData , timeout , beforeReturn , successResponse , rule ) ;
210+ return Sometimes < TResponse , TRule > ( endpoint , boundConfiguration , postData , timeout , beforeReturn , successResponse , rule ) ;
211211 }
212212 foreach ( var rule in rules . Where ( s => ! s . OnPort . HasValue ) )
213213 {
214214 var always = rule . Times . Match ( t => true , t => false ) ;
215215 var times = rule . Times . Match ( t => - 1 , t => t ) ;
216216 if ( always )
217- return Always < TResponse , TRule > ( endpoint , requestData , postData , timeout , beforeReturn , successResponse , rule ) ;
217+ return Always < TResponse , TRule > ( endpoint , boundConfiguration , postData , timeout , beforeReturn , successResponse , rule ) ;
218218
219219 if ( rule . ExecuteCount > times ) continue ;
220220
221- return Sometimes < TResponse , TRule > ( endpoint , requestData , postData , timeout , beforeReturn , successResponse , rule ) ;
221+ return Sometimes < TResponse , TRule > ( endpoint , boundConfiguration , postData , timeout , beforeReturn , successResponse , rule ) ;
222222 }
223223 var count = _calls . Select ( kv => kv . Value . Called ) . Sum ( ) ;
224224 throw new Exception ( $@ "No global or port specific { origin } rule ({ endpoint . Uri . Port } ) matches any longer after { count } calls in to the cluster") ;
225225 }
226226
227- private TResponse Always < TResponse , TRule > ( Endpoint endpoint , RequestData requestData , PostData ? postData , TimeSpan timeout , Action < TRule > beforeReturn , Func < TRule , byte [ ] ? > successResponse , TRule rule
227+ private TResponse Always < TResponse , TRule > ( Endpoint endpoint , BoundConfiguration boundConfiguration , PostData ? postData , TimeSpan timeout , Action < TRule > beforeReturn , Func < TRule , byte [ ] ? > successResponse , TRule rule
228228 )
229229 where TResponse : TransportResponse , new ( )
230230 where TRule : IRule
@@ -233,20 +233,20 @@ private TResponse Always<TResponse, TRule>(Endpoint endpoint, RequestData reques
233233 {
234234 var time = timeout < rule . Takes . Value ? timeout : rule . Takes . Value ;
235235 _dateTimeProvider . ChangeTime ( d => d . Add ( time ) ) ;
236- if ( rule . Takes . Value > requestData . RequestTimeout )
236+ if ( rule . Takes . Value > boundConfiguration . RequestTimeout )
237237 {
238238 throw new TheException (
239239 $ "Request timed out after { time } : call configured to take { rule . Takes . Value } while requestTimeout was: { timeout } ") ;
240240 }
241241 }
242242
243243 return rule . Succeeds
244- ? Success < TResponse , TRule > ( endpoint , requestData , postData , beforeReturn , successResponse , rule )
245- : Fail < TResponse , TRule > ( endpoint , requestData , postData , rule ) ;
244+ ? Success < TResponse , TRule > ( endpoint , boundConfiguration , postData , beforeReturn , successResponse , rule )
245+ : Fail < TResponse , TRule > ( endpoint , boundConfiguration , postData , rule ) ;
246246 }
247247
248248 private TResponse Sometimes < TResponse , TRule > (
249- Endpoint endpoint , RequestData requestData , PostData ? postData , TimeSpan timeout , Action < TRule > beforeReturn , Func < TRule , byte [ ] ? > successResponse , TRule rule
249+ Endpoint endpoint , BoundConfiguration boundConfiguration , PostData ? postData , TimeSpan timeout , Action < TRule > beforeReturn , Func < TRule , byte [ ] ? > successResponse , TRule rule
250250 )
251251 where TResponse : TransportResponse , new ( )
252252 where TRule : IRule
@@ -255,20 +255,20 @@ private TResponse Sometimes<TResponse, TRule>(
255255 {
256256 var time = timeout < rule . Takes . Value ? timeout : rule . Takes . Value ;
257257 _dateTimeProvider . ChangeTime ( d => d . Add ( time ) ) ;
258- if ( rule . Takes . Value > requestData . RequestTimeout )
258+ if ( rule . Takes . Value > boundConfiguration . RequestTimeout )
259259 {
260260 throw new TheException (
261261 $ "Request timed out after { time } : call configured to take { rule . Takes . Value } while requestTimeout was: { timeout } ") ;
262262 }
263263 }
264264
265265 if ( rule . Succeeds )
266- return Success < TResponse , TRule > ( endpoint , requestData , postData , beforeReturn , successResponse , rule ) ;
266+ return Success < TResponse , TRule > ( endpoint , boundConfiguration , postData , beforeReturn , successResponse , rule ) ;
267267
268- return Fail < TResponse , TRule > ( endpoint , requestData , postData , rule ) ;
268+ return Fail < TResponse , TRule > ( endpoint , boundConfiguration , postData , rule ) ;
269269 }
270270
271- private TResponse Fail < TResponse , TRule > ( Endpoint endpoint , RequestData requestData , PostData ? postData , TRule rule , RuleOption < Exception , int > ? returnOverride = null )
271+ private TResponse Fail < TResponse , TRule > ( Endpoint endpoint , BoundConfiguration boundConfiguration , PostData ? postData , TRule rule , RuleOption < Exception , int > ? returnOverride = null )
272272 where TResponse : TransportResponse , new ( )
273273 where TRule : IRule
274274 {
@@ -282,13 +282,13 @@ private TResponse Fail<TResponse, TRule>(Endpoint endpoint, RequestData requestD
282282
283283 return ret . Match (
284284 e => throw e ,
285- statusCode => _inMemoryRequestInvoker . BuildResponse < TResponse > ( endpoint , requestData , postData , CallResponse ( rule ) ,
285+ statusCode => _inMemoryRequestInvoker . BuildResponse < TResponse > ( endpoint , boundConfiguration , postData , CallResponse ( rule ) ,
286286 //make sure we never return a valid status code in Fail responses because of a bad rule.
287287 statusCode >= 200 && statusCode < 300 ? 502 : statusCode , rule . ReturnContentType )
288288 ) ;
289289 }
290290
291- private TResponse Success < TResponse , TRule > ( Endpoint endpoint , RequestData requestData , PostData ? postData , Action < TRule > beforeReturn , Func < TRule , byte [ ] ? > successResponse ,
291+ private TResponse Success < TResponse , TRule > ( Endpoint endpoint , BoundConfiguration boundConfiguration , PostData ? postData , Action < TRule > beforeReturn , Func < TRule , byte [ ] ? > successResponse ,
292292 TRule rule
293293 )
294294 where TResponse : TransportResponse , new ( )
@@ -299,7 +299,7 @@ TRule rule
299299 rule . RecordExecuted ( ) ;
300300
301301 beforeReturn ? . Invoke ( rule ) ;
302- return _inMemoryRequestInvoker . BuildResponse < TResponse > ( endpoint , requestData , postData , successResponse ( rule ) , contentType : rule . ReturnContentType ) ;
302+ return _inMemoryRequestInvoker . BuildResponse < TResponse > ( endpoint , boundConfiguration , postData , successResponse ( rule ) , contentType : rule . ReturnContentType ) ;
303303 }
304304
305305 private static byte [ ] CallResponse < TRule > ( TRule rule )
0 commit comments