Skip to content

Commit

Permalink
Fixed host config
Browse files Browse the repository at this point in the history
  • Loading branch information
Spamercz committed Feb 24, 2022
1 parent 716375c commit 6edd5c9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"ext-json": "*",
"nette/di": "^2.4.10",
"nette/utils": "^2.4.10",
"spameri/elastic-query": "v1.0.0-alpha",
"spameri/elastic-query": "v1.0.0-alpha.4",
"elasticsearch/elasticsearch": "^2.4.0",
"kdyby/console": "^2.7.1",
"kdyby/datetime-provider": "v1.0.0",
Expand All @@ -39,7 +39,7 @@
"spameri/coding-standard": "dev-master",
"spameri/dependency-mocker": "^1.3",
"nette/tester": "^2.2.0",
"phpstan/phpstan": "^0.12.53",
"phpstan/phpstan": "0.12.84",
"php-coveralls/php-coveralls": "^2.1",
"nette/bootstrap": "2.4",
"nette/http": "^2.4.7",
Expand Down
4 changes: 3 additions & 1 deletion src/Config/Elastic.neon
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ services:

elasticPanelLogger:
factory: Spameri\Elastic\Diagnostics\PanelLogger(@spameriElasticSearch.nullLogger)
autowired: false

nullLogger:
factory: Psr\Log\NullLogger
autowired: false

elasticPanel:
factory: Spameri\Elastic\Diagnostics\Panel
factory: Spameri\Elastic\Diagnostics\Panel(@spameriElasticSearch.elasticPanelLogger)

documentMigrateStatus:
factory: Spameri\Elastic\Model\TypeToNewIndex\DocumentMigrateStatus
Expand Down
13 changes: 11 additions & 2 deletions src/DI/SpameriElasticSearchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function loadConfiguration(): void
$services = $this->removeCommandDefinitions($services);
}

$this->setConfigOptions($services, $config);
$services = $this->setConfigOptions($services, $config);

$this->compiler::loadDefinitions(
$this->getContainerBuilder(),
Expand All @@ -49,14 +49,23 @@ public function loadConfiguration(): void
public function setConfigOptions(
array $services,
array $config
): void
): array
{
$neonSettingsProvider = $services['services']['neonSettingsProvider']['factory'];
$neonSettingsProvider->arguments[0] = $config['host'];
$neonSettingsProvider->arguments[1] = $config['port'];

$versionProvider = $services['services']['versionProvider']['factory'];
$versionProvider->arguments[0] = $config['version'];

$services['services']['clientBuilder']['setup'][] = new \Nette\DI\Statement(
'setHosts',
[
[$config['host'] . ':' . $config['port']],
]
);

return $services;
}


Expand Down
2 changes: 1 addition & 1 deletion tests/SpameriTests/Elastic/Model/DumpIndex/Execute.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Execute extends \Tester\TestCase
\Tester\Assert::true(\file_exists('test.log'));

$dumpFile = \file_get_contents('test.log');
$exploded = explode("\r\n", $dumpFile);
$exploded = explode(\PHP_EOL, $dumpFile);
$decoded = \Nette\Utils\Json::decode($exploded[10]);

\Tester\Assert::same('192437', $decoded->index->_id);
Expand Down
5 changes: 5 additions & 0 deletions tests/php.ini-unix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extension=curl.so
extension=json.so
extension=iconv.so
extension=tokenizer.so

0 comments on commit 6edd5c9

Please sign in to comment.