5
5
using System ;
6
6
using System . Threading ;
7
7
using System . Threading . Tasks ;
8
- using Elastic . Transport ;
9
8
using Elastic . Transport . Products ;
10
- using Elasticsearch . Net . VirtualizedCluster . Providers ;
9
+ using Elastic . Transport . VirtualizedCluster . Providers ;
11
10
12
- namespace Elasticsearch . Net . VirtualizedCluster
11
+ namespace Elastic . Transport . VirtualizedCluster
13
12
{
14
13
public class VirtualizedCluster
15
14
{
16
15
private readonly FixedPipelineFactory _fixedRequestPipeline ;
17
16
private readonly TestableDateTimeProvider _dateTimeProvider ;
18
17
private readonly ConnectionConfiguration _settings ;
19
- private Func < IElasticLowLevelClient , Func < RequestConfigurationDescriptor , IRequestConfiguration > , Task < ITransportResponse > > _asyncCall ;
20
- private Func < IElasticLowLevelClient , Func < RequestConfigurationDescriptor , IRequestConfiguration > , ITransportResponse > _syncCall ;
18
+
19
+ private Func < ITransport < IConnectionConfigurationValues > , Func < RequestConfigurationDescriptor , IRequestConfiguration > , Task < ITransportResponse > > _asyncCall ;
20
+ private Func < ITransport < IConnectionConfigurationValues > , Func < RequestConfigurationDescriptor , IRequestConfiguration > , ITransportResponse > _syncCall ;
21
21
22
22
private class VirtualResponse : TransportResponseBase { }
23
23
@@ -28,29 +28,35 @@ public VirtualizedCluster(TestableDateTimeProvider dateTimeProvider, ConnectionC
28
28
//TODO this assumes Elasticsearch as product
29
29
_fixedRequestPipeline = new FixedPipelineFactory ( settings , _dateTimeProvider , ElasticsearchProductRegistration . Default ) ;
30
30
31
- _syncCall = ( c , r ) => c . Search < VirtualResponse > ( PostData . Serializable ( new { } ) , new SearchRequestParameters
31
+ _syncCall = ( t , r ) => t . Request < VirtualResponse > (
32
+ HttpMethod . GET , "/" ,
33
+ PostData . Serializable ( new { } ) , new RequestParameters ( HttpMethod . GET , supportsBody : false )
32
34
{
33
35
RequestConfiguration = r ? . Invoke ( new RequestConfigurationDescriptor ( null ) )
34
36
} ) ;
35
- _asyncCall = async ( c , r ) =>
37
+ _asyncCall = async ( t , r ) =>
36
38
{
37
- var res = await c . SearchAsync < VirtualResponse >
39
+ var res = await t . RequestAsync < VirtualResponse >
38
40
(
41
+ HttpMethod . GET , "/" ,
42
+ CancellationToken . None ,
39
43
PostData . Serializable ( new { } ) ,
40
- new SearchRequestParameters { RequestConfiguration = r ? . Invoke ( new RequestConfigurationDescriptor ( null ) ) } ,
41
- CancellationToken . None
44
+ new RequestParameters ( HttpMethod . GET , supportsBody : false )
45
+ {
46
+ RequestConfiguration = r ? . Invoke ( new RequestConfigurationDescriptor ( null ) )
47
+ }
42
48
) . ConfigureAwait ( false ) ;
43
49
return ( ITransportResponse ) res ;
44
50
} ;
45
51
}
46
52
47
53
public VirtualClusterConnection Connection => Client . Settings . Connection as VirtualClusterConnection ;
48
54
public IConnectionPool ConnectionPool => Client . Settings . ConnectionPool ;
49
- public ElasticLowLevelClient Client => _fixedRequestPipeline ? . Client ;
55
+ public ITransport < IConnectionConfigurationValues > Client => _fixedRequestPipeline ? . Transport ;
50
56
51
- public VirtualizedCluster ClientProxiesTo (
52
- Func < IElasticLowLevelClient , Func < RequestConfigurationDescriptor , IRequestConfiguration > , ITransportResponse > sync ,
53
- Func < IElasticLowLevelClient , Func < RequestConfigurationDescriptor , IRequestConfiguration > , Task < ITransportResponse > > async
57
+ public VirtualizedCluster TransportProxiesTo (
58
+ Func < ITransport < IConnectionConfigurationValues > , Func < RequestConfigurationDescriptor , IRequestConfiguration > , ITransportResponse > sync ,
59
+ Func < ITransport < IConnectionConfigurationValues > , Func < RequestConfigurationDescriptor , IRequestConfiguration > , Task < ITransportResponse > > async
54
60
)
55
61
{
56
62
_syncCall = sync ;
0 commit comments