Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate existing Elasticsearch support to Symfony, API Platform #190

Merged
merged 1 commit into from
Nov 17, 2017

Conversation

dkarlovi
Copy link
Contributor

@dkarlovi dkarlovi commented Nov 2, 2017

Makefile Outdated
@@ -1,7 +1,7 @@
dist: test

test: es-up
vendor/bin/simple-phpunit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is committed in error, ignore, I'll undo.

@dkarlovi dkarlovi force-pushed the elasticsearch-integration branch from 8a5d143 to cf06fcd Compare November 2, 2017 13:38
composer.json Outdated
@@ -1,5 +1,6 @@
{
"homepage": "https://rollerworks.github.io/",
"name": "rollerworks/search",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary, just to make it installable from my fork.

@dkarlovi
Copy link
Contributor Author

dkarlovi commented Nov 3, 2017

@sstok can we talk about this one? What do you feel is required to get this merged?

@dkarlovi dkarlovi force-pushed the elasticsearch-integration branch from f0757f5 to 0480842 Compare November 3, 2017 08:14
$configuration = (array) $configuration['elasticsearch'];
ArrayKeysValidator::assertOnlyKeys($configuration, ['mappings', 'identifiers_normalizer'], $configPath);

// this snippet looks weird, factory should create the proper instance on its own
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this one? If needs improving please open an issue afterwards so we don't loose it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, I don't think the factory should leave it up to it's user to compose the cached version, you should just request an instance and get it, cache-decorated or not.

@@ -38,7 +39,7 @@ public function getConfigTreeBuilder()
->children()
->arrayNode('processor')
->info('SearchProcessor configuration')
->{class_exists(Psr7SearchProcessor::class) && interface_exists(HttpFoundationFactoryInterface::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->{class_exists(Psr7SearchProcessor::class) && class_exists(HttpFoundationFactoryInterface::class) ? 'canBeDisabled' : 'canBeEnabled'}()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be reverted. Properly a bad rebase. I have no idea why this even worked in the first place 😳

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I did not do that, might have been CS fixer.


<services>
<service id="rollerworks_search.elasticsearch.factory" class="Rollerworks\Component\Search\Elasticsearch\ElasticsearchFactory" public="true">
<argument type="service" id="rollerworks_search.elasticsearch.factory.cache" on-invalid="null" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollerworks_search.elasticsearch.factory.cache -> rollerworks_search.elasticsearch.cache

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks.

@dkarlovi dkarlovi force-pushed the elasticsearch-integration branch 2 times, most recently from 4c4b529 to 1cd8235 Compare November 5, 2017 09:27
@dkarlovi
Copy link
Contributor Author

dkarlovi commented Nov 5, 2017

I'm adding tests etc, so don't merge if you were going to. 👍

@sstok
Copy link
Member

sstok commented Nov 5, 2017

Thanks for the warning 😄

@dkarlovi dkarlovi force-pushed the elasticsearch-integration branch from 1cd8235 to 34d84ea Compare November 5, 2017 14:23
@dkarlovi
Copy link
Contributor Author

dkarlovi commented Nov 5, 2017

BTW sorry I keep squashing, just realized you might be reading individual commits which makes it awkward. I'll just add WIP commits and squash before merge.

Also, we should try to use the new build process ASAP, fixing CS Fixer and PHPStan issues would allow us to find and fix new ones in new commits.

*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('fos_elastica.client.default')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sstok can you help me out here? For some reason, this will always return false (as if FOS Elastica is not loaded, even though it's registered) and I'm getting

1) Rollerworks\Bundle\SearchBundle\Tests\Functional\ApiPlatformTest::testEmptySearchCodeIsValid
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "rollerworks_search.elasticsearch.client". Did you mean this: "rollerworks_search.elasticsearch.factory"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe try has() if it's an alias it might not be detected 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, nothing related to Elastica is found for some reason. I'm trying to debug this and hitting a wall, can't figure it out. :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundle is definetly registered as I'm seeing compiler passes from it further down the list if I dump the compiler passes from the entire app in the compiler. I've also tried all the PassConfig types, it should work without any of that but it doesn't.

@@ -95,14 +96,4 @@ public function getCacheDir()

return rtrim($tmpDir, '/\\').'/rollerworks-search-'.sha1(__DIR__).'/'.substr(sha1($this->config), 0, 6);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sstok these were to blame, thanks for that. 😭 It took me forever to figure it out. Problem was, for some bizzare reason, the instance of $container FOS Elastica and Search bundle were getting was not the same instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is exactly the reason why it worked in my app, but not in the functional test app. (┛◉Д◉)┛彡┻━┻

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😐 properly not needed anymore then 😄 sorry ¯_(ツ)_/¯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upside is I'm now thoroughly familiar with the Symfony Container compile process. :D

@dkarlovi dkarlovi force-pushed the elasticsearch-integration branch from ec79de2 to 308f9f9 Compare November 5, 2017 21:26
@dkarlovi
Copy link
Contributor Author

@sstok if this looks OK to you, I'll rebase and squash so you can merge.

@dkarlovi
Copy link
Contributor Author

Also, this was my first time using Prophecy (not a fan) so feel free to comment if I missed any important points.

@dkarlovi dkarlovi force-pushed the elasticsearch-integration branch from c142b84 to a9969bc Compare November 12, 2017 11:09
@dkarlovi dkarlovi force-pushed the elasticsearch-integration branch from a9969bc to 00ee5b3 Compare November 13, 2017 08:36
@dkarlovi dkarlovi changed the title WIP: Integrate existing Elasticsearch support to Symfony, API Platform Integrate existing Elasticsearch support to Symfony, API Platform Nov 13, 2017
@dkarlovi
Copy link
Contributor Author

@sstok seeing you're away end of week, could we see this gets merged before then?

@sstok sstok merged commit 8cc0e1b into rollerworks:master Nov 17, 2017
@sstok
Copy link
Member

sstok commented Nov 17, 2017

Thank you @dkarlovi

@dkarlovi
Copy link
Contributor Author

\o/ :+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants