Skip to content

Commit

Permalink
allow multiple endpoints as dsn to avoid downtime if single node fail…
Browse files Browse the repository at this point in the history
…s. (new config `hosts`)
  • Loading branch information
rliebi committed Mar 18, 2024
1 parent d3c07c3 commit cd91fb6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function getConfigTreeBuilder()
->children()
->arrayNode('client')
->children()
->arrayNode('hosts')->defaultValue([])->info('An array of DSN to connect to the Elasticsearch cluster.')->scalarPrototype()->end()->end()
->scalarNode('dsn')->defaultValue('http://localhost:9200')->info('The DSN to connect to the Elasticsearch cluster.')->end()
->booleanNode('should_add_sentry_breadcrumbs')->defaultFalse()->info('If true, breadcrumbs are added to Sentry for every request made to Elasticsearch via Elastica.')->end()
->end()
Expand Down
5 changes: 4 additions & 1 deletion src/Repository/ConfigurationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ public function __construct(
private readonly ContainerBagInterface $containerBag,
) {}

public function getClientDsn(): string
public function getClientDsn(): string|array

Check failure on line 18 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Method Valantic\ElasticaBridgeBundle\Repository\ConfigurationRepository::getClientDsn() return type has no value type specified in iterable type array.

Check failure on line 18 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Method Valantic\ElasticaBridgeBundle\Repository\ConfigurationRepository::getClientDsn() return type has no value type specified in iterable type array.

Check failure on line 18 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Method Valantic\ElasticaBridgeBundle\Repository\ConfigurationRepository::getClientDsn() return type has no value type specified in iterable type array.

Check failure on line 18 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Method Valantic\ElasticaBridgeBundle\Repository\ConfigurationRepository::getClientDsn() return type has no value type specified in iterable type array.
{
if (!empty($this->containerBag->get('valantic_elastica_bridge')['client']['hosts'])) {

Check failure on line 20 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Construct empty() is not allowed. Use more strict comparison.

Check failure on line 20 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Construct empty() is not allowed. Use more strict comparison.

Check failure on line 20 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Construct empty() is not allowed. Use more strict comparison.

Check failure on line 20 in src/Repository/ConfigurationRepository.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Construct empty() is not allowed. Use more strict comparison.
return $this->containerBag->get('valantic_elastica_bridge')['client']['hosts'];
}
return $this->containerBag->get('valantic_elastica_bridge')['client']['dsn'];
}

Expand Down

0 comments on commit cd91fb6

Please sign in to comment.