@@ -129,6 +129,8 @@ public ConnectionConfiguration(IConnectionPool connectionPool, IConnection conne
129
129
public abstract class ConnectionConfiguration < T > : IConnectionConfigurationValues , IHideObjectMembers
130
130
where T : ConnectionConfiguration < T >
131
131
{
132
+ public static IMemoryStreamFactory DefaultMemoryStreamFactory { get ; } = Elasticsearch . Net . MemoryStreamFactory . Default ;
133
+
132
134
private readonly IConnection _connection ;
133
135
private readonly IConnectionPool _connectionPool ;
134
136
private readonly NameValueCollection _headers = new NameValueCollection ( ) ;
@@ -141,9 +143,7 @@ public abstract class ConnectionConfiguration<T> : IConnectionConfigurationValue
141
143
private Action < IApiCallDetails > _completedRequestHandler = DefaultCompletedRequestHandler ;
142
144
private int _connectionLimit ;
143
145
private TimeSpan ? _deadTimeout ;
144
-
145
146
private bool _disableAutomaticProxyDetection = false ;
146
-
147
147
private bool _disableDirectStreaming = false ;
148
148
private bool _disableMetaHeader ;
149
149
private bool _disablePings ;
@@ -154,12 +154,12 @@ public abstract class ConnectionConfiguration<T> : IConnectionConfigurationValue
154
154
private TimeSpan ? _maxDeadTimeout ;
155
155
private int ? _maxRetries ;
156
156
private TimeSpan ? _maxRetryTimeout ;
157
+ private IMemoryStreamFactory _memoryStreamFactory = DefaultMemoryStreamFactory ;
157
158
private Func < Node , bool > _nodePredicate = DefaultNodePredicate ;
158
159
private Action < RequestData > _onRequestDataCreated = DefaultRequestDataCreated ;
159
160
private TimeSpan ? _pingTimeout ;
160
161
private bool _prettyJson ;
161
162
private string _proxyAddress ;
162
-
163
163
private string _proxyPassword ;
164
164
private string _proxyUsername ;
165
165
private TimeSpan _requestTimeout ;
@@ -217,8 +217,7 @@ protected ConnectionConfiguration(IConnectionPool connectionPool, IConnection co
217
217
TimeSpan ? IConnectionConfigurationValues . MaxDeadTimeout => _maxDeadTimeout ;
218
218
int ? IConnectionConfigurationValues . MaxRetries => _maxRetries ;
219
219
TimeSpan ? IConnectionConfigurationValues . MaxRetryTimeout => _maxRetryTimeout ;
220
- IMemoryStreamFactory IConnectionConfigurationValues . MemoryStreamFactory { get ; } = new RecyclableMemoryStreamFactory ( ) ;
221
-
220
+ IMemoryStreamFactory IConnectionConfigurationValues . MemoryStreamFactory => _memoryStreamFactory ;
222
221
Func < Node , bool > IConnectionConfigurationValues . NodePredicate => _nodePredicate ;
223
222
Action < IApiCallDetails > IConnectionConfigurationValues . OnRequestCompleted => _completedRequestHandler ;
224
223
Action < RequestData > IConnectionConfigurationValues . OnRequestDataCreated => _onRequestDataCreated ;
@@ -585,6 +584,11 @@ public T SkipDeserializationForStatusCodes(params int[] statusCodes) =>
585
584
/// </summary>
586
585
public T UserAgent ( string userAgent ) => Assign ( userAgent , ( a , v ) => a . _userAgent = v ) ;
587
586
587
+ /// <summary>
588
+ /// The memory stream factory to use, defaults to <see cref="MemoryStreamFactory.Default"/>.
589
+ /// </summary>
590
+ public T MemoryStreamFactory ( IMemoryStreamFactory memoryStreamFactory ) => Assign ( memoryStreamFactory , ( a , v ) => a . _memoryStreamFactory = v ) ;
591
+
588
592
protected virtual void DisposeManagedResources ( )
589
593
{
590
594
_connectionPool ? . Dispose ( ) ;
0 commit comments