/// <summary>
        /// <inheritdoc cref="TransportConfiguration"/>
        /// </summary>
        /// <param name="connectionPool"><inheritdoc cref="IConnectionPool"/></param>
        /// <param name="connection"><inheritdoc cref="IConnection"/></param>
        /// <param name="requestResponseSerializer"><inheritdoc cref="ITransportSerializer"/></param>
        /// <param name="productRegistration"><inheritdoc cref="IProductRegistration"/></param>
        protected TransportConfigurationBase(IConnectionPool connectionPool, IConnection connection, ITransportSerializer requestResponseSerializer, IProductRegistration productRegistration)
        {
            _connectionPool      = connectionPool;
            _connection          = connection ?? new HttpConnection();
            _productRegistration = productRegistration ?? ProductRegistration.Default;
            var serializer = requestResponseSerializer ?? new LowLevelRequestResponseSerializer();

            UseThisRequestResponseSerializer = new DiagnosticsSerializerProxy(serializer);

            _connectionLimit        = TransportConfiguration.DefaultConnectionLimit;
            _requestTimeout         = TransportConfiguration.DefaultTimeout;
            _dnsRefreshTimeout      = TransportConfiguration.DefaultDnsRefreshTimeout;
            _memoryStreamFactory    = TransportConfiguration.DefaultMemoryStreamFactory;
            _sniffOnConnectionFault = true;
            _sniffOnStartup         = true;
            _sniffLifeSpan          = TimeSpan.FromHours(1);

            _urlFormatter = new UrlFormatter(this);
            _statusCodeToResponseSuccess = (m, i) => _productRegistration.HttpStatusCodeClassifier(m, i);
            _userAgent = Elastic.Transport.UserAgent.Create(_productRegistration.Name, _productRegistration.GetType());

            if (connectionPool is CloudConnectionPool cloudPool)
            {
                _authenticationHeader  = cloudPool.AuthenticationHeader;
                _enableHttpCompression = true;
            }
        }
 /// <inheritdoc cref="IAuthenticationHeader"/>
 public T Authentication(IAuthenticationHeader header) => Assign(header, (a, v) => a._authenticationHeader = v);
Esempio n. 3
0
 /// <summary>
 /// Sets up the client to communicate to Elastic Cloud using <paramref name="cloudId"/>,
 /// <para><see cref="CloudConnectionPool"/> documentation for more information on how to obtain your Cloud Id</para>
 /// </summary>
 public ConnectionSettings(string cloudId, IAuthenticationHeader credentials) : this(new CloudConnectionPool(cloudId, credentials))
 {
 }
 /// <inheritdoc cref="IAuthenticationHeader"/>
 public RequestConfigurationDescriptor Authentication(IAuthenticationHeader authentication)
 {
     Self.AuthenticationHeader = authentication;
     return(this);
 }
Esempio n. 5
0
 /// <summary>
 /// Sets up the client to communicate to Elastic Cloud using <paramref name="cloudId"/>,
 /// <para><see cref="CloudConnectionPool"/> documentation for more information on how to obtain your Cloud Id</para>
 /// <para></para>If you want more control use the <see cref="ElasticLowLevelClient(IConnectionConfigurationValues)"/> constructor and pass an instance of
 /// <see cref="ConnectionConfiguration" /> that takes <paramref name="cloudId"/> in its constructor as well
 /// </summary>
 public ElasticLowLevelClient(string cloudId, IAuthenticationHeader credentials) : this(new ConnectionConfiguration(cloudId, credentials))
 {
 }
Esempio n. 6
0
 /// <summary>
 /// An <see cref="IConnectionPool"/> implementation that can be seeded with a cloud id
 /// and will signal the right defaults for the client to use for Elastic Cloud to <see cref="ITransportConfiguration"/>.
 ///
 /// <para>Read more about Elastic Cloud Id here</para>
 /// <para>https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html</para>
 /// </summary>
 /// <param name="cloudId">
 /// The Cloud Id, this is available on your cluster's dashboard and is a string in the form of <code>cluster_name:base_64_encoded_string</code>
 /// <para>Base64 encoded string contains the following tokens in order separated by $:</para>
 /// <para>* Host Name (mandatory)</para>
 /// <para>* Elasticsearch UUID (mandatory)</para>
 /// <para>* Kibana UUID</para>
 /// <para>* APM UUID</para>
 /// <para></para>
 /// <para> We then use these tokens to create the URI to your Elastic Cloud cluster!</para>
 /// <para></para>
 /// <para> Read more here: https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html</para>
 /// </param>
 /// <param name="credentials"></param>
 /// <param name="dateTimeProvider">Optionally inject an instance of <see cref="IDateTimeProvider"/> used to set <see cref="IConnectionPool.LastUpdate"/></param>
 public CloudConnectionPool(string cloudId, IAuthenticationHeader credentials, IDateTimeProvider dateTimeProvider = null) : this(ParseCloudId(cloudId), dateTimeProvider) =>
Esempio n. 7
0
 /// <summary>
 ///     Sets up the client to communicate to Elastic Cloud using <paramref name="cloudId" />,
 ///     <para><see cref="CloudNodePool" /> documentation for more information on how to obtain your Cloud Id</para>
 /// </summary>
 public ElasticsearchClientSettings(string cloudId, IAuthenticationHeader credentials) : this(
         new CloudNodePool(cloudId, credentials))
 {
 }