-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* php7.1 updates * requires pbjx-bundle * php7 cleanup * ncr search wip * + add tenant_id options to all commands + general code cleanup + use pbjx aware command trait for mixin loading + add export nodes command + stub reindex nodes command * use "pipeNodes" instead of "streamNodes" from ncr. removes confusion about "streaming". * add "readyForNcrTraffic" method * code cleanup cdo (wip) * elastica config defaults * add "ReindexNodesCommand" * fixup "ReindexNodesCommand". dynamodb parallel processing with no range key creates some inconsistent chunk sizes but the reindexer is now making a copy of the array once it reaches the expected size so the resulting batch sizes are still as expected. removed output to eliminate confusion with ncr batching which may be different from the batching sent for reindexing. this can use more tlc but for a 0.1.x release it will be fine. it works, it's just not the obvious why the chunks would be different at the moment. * when running ReindexNodes ensure the Node has the Indexed interface. * add AbstractNodeType for symfony forms types which are using node mixin * pbj form types don't yet have a handle for constructing custom identifiers.which is fine but it means we'll need to ignore the _id field for now andjust enforce that it has a value in the controller * add documentation for key features provided by this bundle (wip) * cleanup/organize configuration files a little better * prep for initial release... use ncr and pbjx-bundle ~0.1
- Loading branch information
Showing
23 changed files
with
1,785 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
|
||
before_script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Gdbots\Bundle\NcrBundle\Command; | ||
|
||
use Gdbots\Schemas\Ncr\Mixin\Indexed\IndexedV1Mixin; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
class CreateSearchStorageCommand extends ContainerAwareCommand | ||
{ | ||
use NcrAwareCommandTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('ncr:create-search-storage') | ||
->setDescription('Creates the NcrSearch storage.') | ||
->setHelp(<<<EOF | ||
The <info>%command.name%</info> command will create the storage for the NcrSearch. | ||
If a SchemaQName is not provided it will run on all schemas having the mixin "gdbots:ncr:mixin:indexed". | ||
<info>php %command.full_name% --tenant-id=client1 'acme:article'</info> | ||
EOF | ||
) | ||
->addOption( | ||
'skip-errors', | ||
null, | ||
InputOption::VALUE_NONE, | ||
'Skip any schemas that fail to create.' | ||
) | ||
->addOption( | ||
'context', | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'Context to provide to the NcrSearch (json).' | ||
) | ||
->addOption( | ||
'tenant-id', | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'Tenant Id to use for this operation.' | ||
) | ||
->addArgument( | ||
'qname', | ||
InputArgument::OPTIONAL, | ||
'The SchemaQName of the node. e.g. "acme:article"' | ||
); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return null | ||
* | ||
* @throws \Exception | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$skipErrors = $input->getOption('skip-errors'); | ||
$context = json_decode($input->getOption('context') ?: '{}', true); | ||
$context['tenant_id'] = (string)$input->getOption('tenant-id'); | ||
|
||
$io = new SymfonyStyle($input, $output); | ||
$io->title('NcrSearch Storage Creator'); | ||
$ncrSearch = $this->getNcrSearch(); | ||
|
||
foreach ($this->getSchemasUsingMixin(IndexedV1Mixin::create(), $input->getArgument('qname')) as $schema) { | ||
$qname = $schema->getQName(); | ||
|
||
try { | ||
$ncrSearch->createStorage($qname, $context); | ||
$io->success(sprintf('Created NcrSearch storage for "%s".', $qname)); | ||
} catch (\Exception $e) { | ||
if (!$skipErrors) { | ||
throw $e; | ||
} | ||
|
||
$io->error(sprintf('Failed to create NcrSearch storage for "%s".', $qname)); | ||
$io->text($e->getMessage()); | ||
if ($e->getPrevious()) { | ||
$io->newLine(); | ||
$io->text($e->getPrevious()->getMessage()); | ||
} | ||
|
||
$io->newLine(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Gdbots\Bundle\NcrBundle\Command; | ||
|
||
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
class CreateStorageCommand extends ContainerAwareCommand | ||
{ | ||
use NcrAwareCommandTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('ncr:create-storage') | ||
->setDescription('Creates the Ncr storage.') | ||
->setHelp(<<<EOF | ||
The <info>%command.name%</info> command will create the storage for the Ncr. | ||
If a SchemaQName is not provided it will run on all schemas having the mixin "gdbots:ncr:mixin:node". | ||
<info>php %command.full_name% --tenant-id=client1 'acme:article'</info> | ||
EOF | ||
) | ||
->addOption( | ||
'skip-errors', | ||
null, | ||
InputOption::VALUE_NONE, | ||
'Skip any schemas that fail to create.' | ||
) | ||
->addOption( | ||
'context', | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'Context to provide to the NcrSearch (json).' | ||
) | ||
->addOption( | ||
'tenant-id', | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'Tenant Id to use for this operation.' | ||
) | ||
->addArgument( | ||
'qname', | ||
InputArgument::OPTIONAL, | ||
'The SchemaQName of the node. e.g. "acme:article"' | ||
); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return null | ||
* | ||
* @throws \Exception | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$skipErrors = $input->getOption('skip-errors'); | ||
$context = json_decode($input->getOption('context') ?: '{}', true); | ||
$context['tenant_id'] = (string)$input->getOption('tenant-id'); | ||
|
||
$io = new SymfonyStyle($input, $output); | ||
$io->title('Ncr Storage Creator'); | ||
$ncr = $this->getNcr(); | ||
|
||
foreach ($this->getSchemasUsingMixin(NodeV1Mixin::create(), $input->getArgument('qname')) as $schema) { | ||
$qname = $schema->getQName(); | ||
|
||
try { | ||
$ncr->createStorage($qname, $context); | ||
$io->success(sprintf('Created Ncr storage for "%s".', $qname)); | ||
} catch (\Exception $e) { | ||
if (!$skipErrors) { | ||
throw $e; | ||
} | ||
|
||
$io->error(sprintf('Failed to create Ncr storage for "%s".', $qname)); | ||
$io->text($e->getMessage()); | ||
if ($e->getPrevious()) { | ||
$io->newLine(); | ||
$io->text($e->getPrevious()->getMessage()); | ||
} | ||
|
||
$io->newLine(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.