CoolCMS API

EsClientFactory
in package

FinalYes

Builds the ES clients (elasticsearch-php v8) on top of Guzzle 7 (PSR-18).

Constructing a client opens no connection, so it is safe even when ES is disabled.

Two profiles (see elasticsearch.neon): a read client with a short timeout (a search request fails fast during an outage and opens the circuit breaker) and an indexing client with a long timeout (a bulk of hundreds of documents during reindex must not fail on 2.5 s).

IMPORTANT: timeouts must go through the own Guzzle instance in setHttpClient(). If setHttpClientOptions() or SSL options are ever added, the vendor adapter builds a new Guzzle client from those options only and the constructor timeouts are lost.

Table of Contents

Constants

INDEXING_REQUEST_TIMEOUT  : mixed = 60.0
SEARCH_REQUEST_TIMEOUT  : mixed = 2.5
CONNECT_TIMEOUT  : mixed = 1.0

Properties

$config  : EsConfig

Methods

__construct()  : mixed
create()  : Client

Constants

INDEXING_REQUEST_TIMEOUT

public mixed INDEXING_REQUEST_TIMEOUT = 60.0

Properties

Methods

create()

public create([float $requestTimeout = self::SEARCH_REQUEST_TIMEOUT ]) : Client
Parameters
$requestTimeout : float = self::SEARCH_REQUEST_TIMEOUT
Return values
Client
On this page

Search results