Skip to content

Commit

Permalink
v2.1.0 - use gdbots/ncr ^v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbrown committed Jul 18, 2020
1 parent 0e45a54 commit 346582d
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 45 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
This changelog references the relevant changes done in 2.x versions.


## v2.1.0
* Uses `"gdbots/ncr": "^2.1"`
* Uses `"gdbots/pbjx-bundle": "^2.1"`


## v2.0.0
__BREAKING CHANGES__

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ __Other twig functions (documentation wip):__
This library provides the basics for creating and extracting data from the Ncr services. Run the Symfony console and look for __ncr__ commands.

```txt
ncr:create-search Creates the NcrSearch storage.
ncr:create Creates the Ncr storage.
ncr:describe-search Describes the NcrSearch storage.
ncr:describe Describes the Ncr storage.
ncr:export-nodes Pipes nodes from the Ncr to STDOUT.
ncr:get-node Fetches a single node by its NodeRef and writes to STDOUT.
ncr:reindex-nodes Pipes nodes from the Ncr and reindexes them.
ncr:sync-node Syncs a single node from the Ncr with the EventStore.
ncr:sync-nodes Syncs nodes from the Ncr with the EventStore.
ncr:create-search-storage Creates the NcrSearch storage.
ncr:create-storage Creates the Ncr storage.
ncr:describe-search-storage Describes the NcrSearch storage.
ncr:describe-storage Describes the Ncr storage.
ncr:export-nodes Pipes nodes from the Ncr to STDOUT.
ncr:get-node Fetches a single node by its NodeRef and writes to STDOUT.
ncr:reindex-nodes Pipes nodes from the Ncr and reindexes them.
ncr:sync-node Syncs a single node from the Ncr with the EventStore.
ncr:sync-nodes Syncs nodes from the Ncr with the EventStore.
```

Review the `--help` on the ncr commands for more details.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"license": "Apache-2.0",
"require": {
"php": ">=7.4",
"gdbots/ncr": "^2.0",
"gdbots/pbjx-bundle": "^2.0"
"gdbots/ncr": "^2.1",
"gdbots/pbjx-bundle": "^2.1"
},
"require-dev": {
"phpunit/phpunit": "^9.2",
Expand Down
8 changes: 8 additions & 0 deletions config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
<tag name="pbjx.handler"/>
</service>

<service id="gdbots_ncr.update_node_labels_handler" class="Gdbots\Ncr\UpdateNodeLabelsHandler">
<tag name="pbjx.handler"/>
</service>

<service id="gdbots_ncr.update_node_tags_handler" class="Gdbots\Ncr\UpdateNodeTagsHandler">
<tag name="pbjx.handler"/>
</service>

<!-- request handlers -->
<service id="gdbots_ncr.get_node_batch_request_handler" class="Gdbots\Ncr\GetNodeBatchRequestHandler">
<argument type="service" id="ncr"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Gdbots\Pbj\MessageResolver;
use Gdbots\Pbj\SchemaCurie;
use Gdbots\Pbj\SchemaQName;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -16,9 +15,9 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ContainerInterface;

final class CreateSearchCommand extends Command
final class CreateSearchStorageCommand extends Command
{
protected static $defaultName = 'ncr:create-search';
protected static $defaultName = 'ncr:create-search-storage';
protected ContainerInterface $container;
protected NcrSearch $ncrSearch;

Expand Down Expand Up @@ -87,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
? [SchemaQName::fromString($input->getArgument('qname'))]
: array_map(
fn(string $curie) => SchemaCurie::fromString($curie)->getQName(),
MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false)
MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false)
);

foreach ($qnames as $qname) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Gdbots\Pbj\MessageResolver;
use Gdbots\Pbj\SchemaCurie;
use Gdbots\Pbj\SchemaQName;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -16,9 +15,9 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ContainerInterface;

final class CreateCommand extends Command
final class CreateStorageCommand extends Command
{
protected static $defaultName = 'ncr:create';
protected static $defaultName = 'ncr:create-storage';
protected ContainerInterface $container;
protected Ncr $ncr;

Expand Down Expand Up @@ -87,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
? [SchemaQName::fromString($input->getArgument('qname'))]
: array_map(
fn(string $curie) => SchemaCurie::fromString($curie)->getQName(),
MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false)
MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false)
);

foreach ($qnames as $qname) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Gdbots\Pbj\MessageResolver;
use Gdbots\Pbj\SchemaCurie;
use Gdbots\Pbj\SchemaQName;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -16,9 +15,9 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ContainerInterface;

final class DescribeSearchCommand extends Command
final class DescribeSearchStorageCommand extends Command
{
protected static $defaultName = 'ncr:describe-search';
protected static $defaultName = 'ncr:describe-search-storage';
protected ContainerInterface $container;
protected NcrSearch $ncrSearch;

Expand Down Expand Up @@ -79,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
? [SchemaQName::fromString($input->getArgument('qname'))]
: array_map(
fn(string $curie) => SchemaCurie::fromString($curie)->getQName(),
MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false)
MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false)
);

foreach ($qnames as $qname) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Gdbots\Pbj\MessageResolver;
use Gdbots\Pbj\SchemaCurie;
use Gdbots\Pbj\SchemaQName;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -16,9 +15,9 @@
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ContainerInterface;

final class DescribeCommand extends Command
final class DescribeStorageCommand extends Command
{
protected static $defaultName = 'ncr:describe';
protected static $defaultName = 'ncr:describe-storage';
protected ContainerInterface $container;
protected Ncr $ncr;

Expand Down Expand Up @@ -79,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
? [SchemaQName::fromString($input->getArgument('qname'))]
: array_map(
fn(string $curie) => SchemaCurie::fromString($curie)->getQName(),
MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false)
MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false)
);

foreach ($qnames as $qname) {
Expand Down
3 changes: 1 addition & 2 deletions src/Command/ExportNodesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Gdbots\Pbj\SchemaCurie;
use Gdbots\Pbj\SchemaQName;
use Gdbots\Pbj\Util\NumberUtil;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -100,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
? [$qname]
: array_map(
fn(string $curie) => SchemaCurie::fromString($curie)->getQName(),
MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false)
MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false)
);

$i = 0;
Expand Down
9 changes: 4 additions & 5 deletions src/Command/ReindexNodesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Gdbots\Pbj\SchemaCurie;
use Gdbots\Pbj\SchemaQName;
use Gdbots\Pbj\Util\NumberUtil;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -126,7 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
? [$qname]
: array_map(
fn(string $curie) => SchemaCurie::fromString($curie)->getQName(),
MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false)
MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false)
);

foreach ($qnames as $q) {
Expand All @@ -140,9 +139,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'<comment>etag:</comment>%s, <comment>title:</comment>%s',
$i,
$node->generateNodeRef(),
$node->get(NodeV1Mixin::STATUS_FIELD),
$node->get(NodeV1Mixin::ETAG_FIELD),
$node->get(NodeV1Mixin::TITLE_FIELD)
$node->get('status'),
$node->get('etag'),
$node->get('title')
));

if (count($queue) >= $batchSize) {
Expand Down
3 changes: 1 addition & 2 deletions src/Command/SyncNodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Gdbots\Ncr\NcrSearch;
use Gdbots\Pbj\WellKnown\NodeRef;
use Gdbots\Pbjx\Pbjx;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -100,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$expectedEtag = null;
} else {
$node = $this->ncr->getNode($nodeRef, true, $context);
$expectedEtag = $node->get(NodeV1Mixin::ETAG_FIELD);
$expectedEtag = $node->get('etag');
$aggregate = AggregateResolver::resolve($nodeRef->getQName())::fromNode($node, $this->pbjx);
}
} catch (NodeNotFound $nf) {
Expand Down
11 changes: 5 additions & 6 deletions src/Command/SyncNodesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Gdbots\Pbj\SchemaQName;
use Gdbots\Pbj\Util\NumberUtil;
use Gdbots\Pbjx\Pbjx;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -117,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
? [$qname]
: array_map(
fn(string $curie) => SchemaCurie::fromString($curie)->getQName(),
MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false)
MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false)
);

foreach ($qnames as $qname) {
Expand All @@ -127,7 +126,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$nodeRef = $node->generateNodeRef();

try {
$expectedEtag = $node->get(NodeV1Mixin::ETAG_FIELD);
$expectedEtag = $node->get('etag');
$aggregate = AggregateResolver::resolve($nodeRef->getQName())::fromNode($node, $this->pbjx);
$aggregate->sync($context);

Expand All @@ -143,9 +142,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$i,
$aggregate->getEtag() !== $expectedEtag ? 'SYNCED' : 'MATCHED',
$nodeRef,
$node->get(NodeV1Mixin::STATUS_FIELD),
$node->get(NodeV1Mixin::ETAG_FIELD),
$node->get(NodeV1Mixin::TITLE_FIELD)
$node->get('status'),
$node->get('etag'),
$node->get('title')
));

++$synced;
Expand Down
1 change: 0 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Gdbots\Bundle\NcrBundle\DependencyInjection;

use Gdbots\Ncr\Repository\DynamoDb\DynamoDbNcr;
use Gdbots\Ncr\Repository\DynamoDb\NodeTable;
use Gdbots\Ncr\Repository\DynamoDb\TableManager;
use Gdbots\Ncr\Repository\Psr6Ncr;
use Gdbots\Ncr\Search\Elastica\ElasticaNcrSearch;
Expand Down
3 changes: 1 addition & 2 deletions src/Twig/NcrExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Gdbots\Pbj\WellKnown\MessageRef;
use Gdbots\Pbj\WellKnown\NodeRef;
use Gdbots\Schemas\Ncr\Enum\NodeStatus;
use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Twig\Extension\AbstractExtension;
Expand Down Expand Up @@ -114,7 +113,7 @@ public function isNodePublished($node): bool
return false;
}

return NodeStatus::PUBLISHED === $node->fget(NodeV1Mixin::STATUS_FIELD);
return NodeStatus::PUBLISHED === $node->fget('status');
}

/**
Expand Down

0 comments on commit 346582d

Please sign in to comment.