@@ -20,16 +20,18 @@ namespace Elastic.Transport;
20
20
/// Allows you to control how <see cref="ITransport{TConfiguration}"/> behaves and where/how it connects to Elastic Stack products
21
21
/// </summary>
22
22
/// <remarks> <inheritdoc cref="TransportConfigurationDescriptor" path="/summary"/></remarks>
23
- /// <param name="nodePool"><inheritdoc cref="NodePool" path="/summary"/></param>
24
- /// <param name="invoker"><inheritdoc cref="IRequestInvoker" path="/summary"/></param>
25
- /// <param name="serializer"><inheritdoc cref="Serializer" path="/summary"/></param>
26
- /// <param name="productRegistration"><inheritdoc cref="ProductRegistration" path="/summary"/></param>
27
- public class TransportConfigurationDescriptor (
28
- NodePool nodePool ,
29
- IRequestInvoker ? invoker = null ,
30
- Serializer ? serializer = null ,
31
- ProductRegistration ? productRegistration = null ) : TransportConfigurationDescriptorBase < TransportConfigurationDescriptor > ( nodePool , invoker , serializer , productRegistration )
23
+ public class TransportConfigurationDescriptor : TransportConfigurationDescriptorBase < TransportConfigurationDescriptor >
32
24
{
25
+ /// <summary>
26
+ /// Creates a new instance of <see cref="TransportConfigurationDescriptor"/>
27
+ /// </summary>
28
+ /// <param name="nodePool"><inheritdoc cref="NodePool" path="/summary"/></param>
29
+ /// <param name="invoker"><inheritdoc cref="IRequestInvoker" path="/summary"/></param>
30
+ /// <param name="serializer"><inheritdoc cref="Serializer" path="/summary"/></param>
31
+ /// <param name="productRegistration"><inheritdoc cref="ProductRegistration" path="/summary"/></param>
32
+ public TransportConfigurationDescriptor ( NodePool nodePool , IRequestInvoker ? invoker = null , Serializer ? serializer = null , ProductRegistration ? productRegistration = null )
33
+ : base ( nodePool , invoker , serializer , productRegistration ) { }
34
+
33
35
/// <summary>
34
36
/// Creates a new instance of <see cref="TransportConfigurationDescriptor"/>
35
37
/// </summary>
@@ -51,6 +53,15 @@ public TransportConfigurationDescriptor(string cloudId, BasicAuthentication cred
51
53
/// </summary>
52
54
public TransportConfigurationDescriptor ( string cloudId , Base64ApiKey credentials , ProductRegistration ? productRegistration = null )
53
55
: this ( new CloudNodePool ( cloudId , credentials ) , productRegistration : productRegistration ) { }
56
+
57
+ /// <summary>
58
+ /// Creates a new instance of <see cref="TransportConfigurationDescriptor"/>
59
+ /// <para>
60
+ /// Expert usage: Create a new transport configuration based of a previously configured instance.
61
+ /// </para>
62
+ /// </summary>
63
+ public TransportConfigurationDescriptor ( ITransportConfiguration config )
64
+ : base ( config ) { }
54
65
}
55
66
56
67
/// <inheritdoc cref="TransportConfigurationDescriptor"/>>
@@ -98,6 +109,79 @@ protected TransportConfigurationDescriptorBase(NodePool nodePool, IRequestInvoke
98
109
_responseHeadersToParse = new HeadersList ( _productRegistration . ResponseHeadersToParse ) ;
99
110
}
100
111
112
+ /// Expert usage: Create a new transport configuration based of a previously configured instance
113
+ protected TransportConfigurationDescriptorBase ( ITransportConfiguration config )
114
+ {
115
+ #if NET
116
+ ArgumentNullException . ThrowIfNull ( config ) ;
117
+ #else
118
+ if ( config is null )
119
+ throw new ArgumentNullException ( nameof ( config ) ) ;
120
+ #endif
121
+
122
+ // it's important url formatter is repointed to the new instance of ITransportConfiguration
123
+ _urlFormatter = new UrlFormatter ( this ) ;
124
+
125
+ _accept = config . Accept ;
126
+ _allowedStatusCodes = config . AllowedStatusCodes ;
127
+ _authentication = config . Authentication ;
128
+ _bootstrapLock = config . BootstrapLock ;
129
+ _certificateFingerprint = config . CertificateFingerprint ;
130
+ _clientCertificates = config . ClientCertificates ;
131
+ _connectionLimit = config . ConnectionLimit ;
132
+ _contentType = config . ContentType ;
133
+ _dateTimeProvider = config . DateTimeProvider ;
134
+ _deadTimeout = config . DeadTimeout ;
135
+ _disableAuditTrail = config . DisableAuditTrail ;
136
+ _disableAutomaticProxyDetection = config . DisableAutomaticProxyDetection ;
137
+ _disableDirectStreaming = config . DisableDirectStreaming ;
138
+ _disableMetaHeader = config . DisableMetaHeader ;
139
+ _disablePings = config . DisablePings ;
140
+ _disableSniff = config . DisableSniff ;
141
+ _dnsRefreshTimeout = config . DnsRefreshTimeout ;
142
+ _enableHttpCompression = config . EnableHttpCompression ;
143
+ _enableTcpStats = config . EnableTcpStats ;
144
+ _enableThreadPoolStats = config . EnableThreadPoolStats ;
145
+ _forceNode = config . ForceNode ;
146
+ _headers = config . Headers ;
147
+ _httpPipeliningEnabled = config . HttpPipeliningEnabled ;
148
+ _keepAliveInterval = config . KeepAliveInterval ;
149
+ _keepAliveTime = config . KeepAliveTime ;
150
+ _maxDeadTimeout = config . MaxDeadTimeout ;
151
+ _maxRetries = config . MaxRetries ;
152
+ _maxRetryTimeout = config . MaxRetryTimeout ;
153
+ _memoryStreamFactory = config . MemoryStreamFactory ;
154
+ _nodePool = config . NodePool ;
155
+ _nodePredicate = config . NodePredicate ;
156
+ _onRequestCompleted = config . OnRequestCompleted ;
157
+ _onRequestDataCreated = config . OnRequestDataCreated ;
158
+ _opaqueId = config . OpaqueId ;
159
+ _parseAllHeaders = config . ParseAllHeaders ;
160
+ _pingTimeout = config . PingTimeout ;
161
+ _pipelineProvider = config . PipelineProvider ;
162
+ _prettyJson = config . PrettyJson ;
163
+ _productRegistration = config . ProductRegistration ;
164
+ _proxyAddress = config . ProxyAddress ;
165
+ _proxyPassword = config . ProxyPassword ;
166
+ _proxyUsername = config . ProxyUsername ;
167
+ _queryStringParameters = config . QueryStringParameters ;
168
+ _requestInvoker = config . RequestInvoker ;
169
+ _requestMetaData = config . RequestMetaData ;
170
+ _requestResponseSerializer = config . RequestResponseSerializer ;
171
+ _requestTimeout = config . RequestTimeout ;
172
+ _responseHeadersToParse = config . ResponseHeadersToParse ;
173
+ _runAs = config . RunAs ;
174
+ _serverCertificateValidationCallback = config . ServerCertificateValidationCallback ;
175
+ _skipDeserializationForStatusCodes = config . SkipDeserializationForStatusCodes ;
176
+ _sniffInformationLifeSpan = config . SniffInformationLifeSpan ;
177
+ _sniffsOnConnectionFault = config . SniffsOnConnectionFault ;
178
+ _sniffsOnStartup = config . SniffsOnStartup ;
179
+ _statusCodeToResponseSuccess = config . StatusCodeToResponseSuccess ;
180
+ _throwExceptions = config . ThrowExceptions ;
181
+ _transferEncodingChunked = config . TransferEncodingChunked ;
182
+ _userAgent = config . UserAgent ;
183
+ }
184
+
101
185
private readonly SemaphoreSlim _bootstrapLock ;
102
186
private readonly NodePool _nodePool ;
103
187
private readonly ProductRegistration _productRegistration ;
0 commit comments