Browse Source

define index drivers config

main
ghost 9 months ago
parent
commit
47b1cad89a
  1. 4
      example/config.json
  2. 35
      src/index.php

4
example/config.json

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

35
src/index.php

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

Loading…
Cancel
Save