define index drivers config

This commit is contained in:
ghost 2024-02-12 16:53:41 +02:00
parent 5d6781a997
commit 47b1cad89a
2 changed files with 48 additions and 31 deletions

View File

@ -7,6 +7,8 @@
"username":"", "username":"",
"password":"" "password":""
}, },
"index":
{
"manticore": "manticore":
{ {
"name":"kvazar", "name":"kvazar",
@ -20,5 +22,7 @@
"min_word_len":3, "min_word_len":3,
"min_prefix_len":3 "min_prefix_len":3
} }
},
"driver":"manticore"
} }
} }

View File

@ -12,9 +12,6 @@ if (false === sem_acquire($semaphore, true))
); );
} }
// Load dependencies
require_once __DIR__ . '/../vendor/autoload.php';
// Init config // Init config
if (!file_exists(__DIR__ . '/../config.json')) if (!file_exists(__DIR__ . '/../config.json'))
{ {
@ -29,25 +26,41 @@ $config = json_decode(
) )
); );
// Init index // Load dependencies
try require_once __DIR__ . '/../vendor/autoload.php';
{
$index = new \Kvazar\Index\Manticore(
(string) $config->manticore->name,
(array) $config->manticore->meta,
(string) $config->manticore->host,
(int) $config->manticore->port
);
}
catch (Exception $exception) // Init index
switch ($config->index->driver)
{ {
case 'manticore':
try
{
$index = new \Kvazar\Index\Manticore(
(string) $config->index->manticore->name,
(array) $config->index->manticore->meta,
(string) $config->index->manticore->host,
(int) $config->index->manticore->port
);
}
catch (Exception $exception)
{
exit( exit(
print_r( print_r(
$exception, $exception,
true true
) )
); );
}
break;
default:
exit(
_('Undefined index driver!')
);
} }
// Init kevacoin // Init kevacoin