Skip to content

Commit 006b809

Browse files
committed
fix bugs.
1 parent f8081ea commit 006b809

File tree

4 files changed

+107
-3
lines changed

4 files changed

+107
-3
lines changed

Elastica/AsyncDoctrineOrmProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Enqueue\ElasticaBundle\Listener;
2+
namespace Enqueue\ElasticaBundle\Elastica;
33

44
use Enqueue\Psr\Context;
55
use Enqueue\Util\JSON;

README.md

+104
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,109 @@
11
# Enqueue Elastica Bundle
22

3+
Improves performance of `fos:elastica:populate` commands by distributing the work among consumers.
4+
The performance gain depends on how much consumers you run.
5+
For example 10 consumers may give you 5 to 7 times better performance.
6+
7+
## Installation
8+
9+
Install packages using [composer](https://getcomposer.org/)
10+
11+
```bash
12+
$ composer require enqueue/elastica-bundle friendsofsymfony/elastica-bundle
13+
```
14+
15+
Add bundles to `AppKernel`
16+
17+
```php
18+
<?php
19+
use Symfony\Component\HttpKernel\Kernel;
20+
21+
class AppKernel extends Kernel
22+
{
23+
public function registerBundles()
24+
{
25+
$bundles = [
26+
// ...
27+
28+
new Enqueue\Bundle\EnqueueBundle(),
29+
new Enqueue\ElasticaBundle\EnqueueElasticaBundle(),
30+
new FOS\ElasticaBundle\FOSElasticaBundle(),
31+
];
32+
33+
return $bundles;
34+
}
35+
}
36+
```
37+
38+
Here's an example of what your `FOSElasticaBundle` configuration may look like:
39+
40+
```yaml
41+
fos_elastica:
42+
clients:
43+
default: { host: %elasticsearch_host%, port: %elasticsearch_port% }
44+
indexes:
45+
app:
46+
index_name: app_%kernel.environment%
47+
types:
48+
blog:
49+
mappings:
50+
text: ~
51+
persistence:
52+
driver: orm
53+
model: AppBundle\Entity\Blog
54+
provider: ~
55+
listener: ~
56+
finder: ~
57+
```
58+
59+
Here's an example of what your EnqueueBundle configuration may look like:
60+
61+
```yaml
62+
enqueue:
63+
transport:
64+
default: 'amqp'
65+
amqp:
66+
host: '%rabbitmq_host%'
67+
port: '%rabbitmq_port%'
68+
login: '%rabbitmq_user%'
69+
password: '%rabbitmq_password%'
70+
vhost: '%rabbitmq_vhost%'
71+
```
72+
73+
Create a `fos_elastica.populate` queue on broker side, if needed.
74+
75+
## Usage
76+
77+
The bundle once registered automatically replaces Doctrine ORM provider by async one.
78+
So you have to run as usual
79+
80+
```bash
81+
$ ./bin/console fos:elastica:populate
82+
```
83+
84+
and have pull of consumer commands run somewhere, run them as many as you'd like
85+
86+
```bash
87+
$ ./bin/console enqueue:transport:consume fos_elastica.populate enqueue_elastica.populate_processor
88+
```
89+
90+
We suggest to use [supervisor](http://supervisord.org/) on production to control numbers of consumers and restart them.
91+
92+
Here's config example
93+
94+
```
95+
# cat /etc/supervisor/conf.d/fos_elastica_populate.conf
96+
[program:fos_elastica_populate]
97+
command=/mqs/symfony/bin/console enqueue:transport:consume fos_elastica.populate enqueue_elastica.populate_processor
98+
process_name=%(program_name)s_%(process_num)02d
99+
numprocs=10
100+
autostart=true
101+
autorestart=true
102+
startsecs=0
103+
user=root
104+
redirect_stderr=true
105+
```
106+
3107
## License
4108
5109
It is released under the [MIT License](LICENSE).

Resources/config/services.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
services:
2-
enqueue_elastica.async.elastica_populate_processor:
2+
enqueue_elastica.populate_processor:
33
class: 'Enqueue\ElasticaBundle\Async\ElasticaPopulateProcessor'
44
arguments:
55
- '@fos_elastica.provider_registry'
66

7-
app.listener.purge_fos_elastic_populate_queue:
7+
enqueue_elastica.purge_fos_elastic_populate_queue_listener:
88
class: 'Enqueue\ElasticaBundle\Listener\PurgeFosElasticPopulateQueueListener'
99
arguments:
1010
- '@enqueue.transport.context'

0 commit comments

Comments
 (0)