Skip to content

Commit e50da16

Browse files
authored
Merge pull request #403 from php-enqueue/pr-250
[symfony] Async commands
2 parents 3687ad1 + b4aa773 commit e50da16

47 files changed

Lines changed: 800 additions & 51 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.travis.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ cache:
3434
- $HOME/.composer/cache
3535
- $HOME/docker
3636

37-
3837
before_cache:
3938
- >
4039
mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}'
@@ -47,8 +46,8 @@ before_install:
4746
install:
4847
- rm $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini;
4948
- echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
50-
- sed -i '' "s/\"symfony\/\(.*\)\": \".*\"/\"symfony\/\1\": \"$SYMFONY_VERSION\"/g" composer.json && cat composer.json
51-
- composer dunglas/symfony-lock
49+
- php ./bin/fix-symfony-version.php "$SYMFONY_VERSION"
50+
- composer install
5251
- if [ "$PREPARE_CONTAINER" = true ]; then docker --version; fi
5352
- if [ "$PREPARE_CONTAINER" = true ]; then docker-compose --version; fi
5453
- if [ "$PREPARE_CONTAINER" = true ]; then bin/dev -b; fi

‎bin/fix-symfony-version.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
if (empty($argv[1])) {
4+
throw new \LogicException('The new symfony version must be provided');
5+
}
6+
7+
$newVersion = $argv[1];
8+
9+
$composer = file_get_contents(__DIR__.'/../composer.json');
10+
11+
$updatedComposer = preg_replace('/"symfony\/(.*)": ".*"/', '"symfony/$1": "'.$newVersion.'"', $composer).PHP_EOL;
12+
echo $updatedComposer.PHP_EOL;
13+
14+
file_put_contents(__DIR__.'/../composer.json', $updatedComposer);

‎bin/subtree-split‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ remote enqueue-bundle git@github.com:php-enqueue/enqueue-bundle.git
6363
remote job-queue git@github.com:php-enqueue/job-queue.git
6464
remote test git@github.com:php-enqueue/test.git
6565
remote async-event-dispatcher git@github.com:php-enqueue/async-event-dispatcher.git
66+
remote async-command git@github.com:php-enqueue/async-command.git
6667
remote mongodb git@github.com:php-enqueue/mongodb.git
6768

6869
split 'pkg/enqueue' enqueue
@@ -85,4 +86,5 @@ split 'pkg/enqueue-bundle' enqueue-bundle
8586
split 'pkg/job-queue' job-queue
8687
split 'pkg/test' test
8788
split 'pkg/async-event-dispatcher' async-event-dispatcher
88-
split 'pkg/mongodb' mongodb
89+
split 'pkg/async-command' async-command
90+
split 'pkg/mongodb' mongodb

‎composer.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": "^7.1.3",
88

99
"ext-amqp": "^1.9.3",
10-
"ext-gearman": "^1.1 || ^2.0",
10+
"ext-gearman": "^2.0",
1111
"ext-mongodb": "^1.3",
1212
"ext-rdkafka": "^3.0.3",
1313

@@ -56,6 +56,7 @@
5656
"Enqueue\\AmqpLib\\": "pkg/amqp-lib/",
5757
"Enqueue\\AmqpTools\\": "pkg/amqp-tools/",
5858
"Enqueue\\AsyncEventDispatcher\\": "pkg/async-event-dispatcher/",
59+
"Enqueue\\AsyncCommand\\": "pkg/async-command/",
5960
"Enqueue\\Dbal\\": "pkg/dbal/",
6061
"Enqueue\\Bundle\\": "pkg/enqueue-bundle/",
6162
"Enqueue\\Fs\\": "pkg/fs/",
@@ -95,7 +96,7 @@
9596
"bin-dir": "bin",
9697
"platform": {
9798
"ext-amqp": "1.9.3",
98-
"ext-gearman": "1.1",
99+
"ext-gearman": "2.0.3",
99100
"ext-rdkafka": "3.3",
100101
"ext-mongodb": "1.3",
101102
"ext-bcmath": "1",

‎docs/bundle/async_commands.md‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Async commands
2+
3+
## Installation
4+
5+
```bash
6+
$ composer require enqueue/async-command:^0.8
7+
```
8+
9+
## Configuration
10+
11+
```yaml
12+
# config/packages/enqueue_async_commands.yaml
13+
14+
enqueue:
15+
async_commands: true
16+
```
17+
18+
## Usage
19+
20+
```php
21+
<?php
22+
23+
use Enqueue\Client\ProducerInterface;
24+
use Enqueue\AsyncCommand\Commands;
25+
use Enqueue\AsyncCommand\RunCommand;
26+
use Symfony\Component\DependencyInjection\ContainerInterface;
27+
28+
/** @var $container ContainerInterface */
29+
30+
/** @var ProducerInterface $producer */
31+
$producer = $container->get(ProducerInterface::class);
32+
33+
$producer->sendCommand(Commands::RUN_COMMAND, new RunCommand('debug:container'));
34+
```
35+
36+
optionally you can get a command execution result:
37+
38+
```php
39+
<?php
40+
41+
use Enqueue\Client\ProducerInterface;
42+
use Enqueue\AsyncCommand\RunCommandResult;
43+
use Enqueue\AsyncCommand\Commands;
44+
use Enqueue\AsyncCommand\RunCommand;
45+
use Symfony\Component\DependencyInjection\ContainerInterface;
46+
47+
/** @var $container ContainerInterface */
48+
49+
/** @var ProducerInterface $producer */
50+
$producer = $container->get(ProducerInterface::class);
51+
52+
$promise = $producer->sendCommand(Commands::RUN_COMMAND, new RunCommand('debug:container'), true);
53+
54+
// do other stuff.
55+
56+
if ($replyMessage = $promise->receive(5000)) {
57+
$result = RunCommandResult::jsonUnserialize($replyMessage->getBody());
58+
59+
echo $result->getOutput();
60+
}
61+
```
62+
63+
[back to index](../index.md)

‎docs/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- [Message producer](bundle/message_producer.md)
3434
- [Message processor](bundle/message_processor.md)
3535
- [Async events](bundle/async_events.md)
36+
- [Async commands](bundle/async_commands.md)
3637
- [Job queue](bundle/job_queue.md)
3738
- [Consumption extension](bundle/consumption_extension.md)
3839
- [Production settings](bundle/production_settings.md)

‎phpunit.xml.dist‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
<testsuite name="async-event-dispatcher">
9797
<directory>pkg/async-event-dispatcher/Tests</directory>
9898
</testsuite>
99+
100+
<testsuite name="async-command">
101+
<directory>pkg/async-command/Tests</directory>
102+
</testsuite>
99103
</testsuites>
100104

101105
<php>

‎pkg/amqp-bunny/.travis.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ git:
66
language: php
77

88
php:
9-
- '5.6'
10-
- '7.0'
9+
- '7.1'
10+
- '7.2'
1111

1212
cache:
1313
directories:

‎pkg/amqp-ext/.travis.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ git:
66
language: php
77

88
php:
9-
- '5.6'
10-
- '7.0'
9+
- '7.1'
10+
- '7.2'
1111

1212
cache:
1313
directories:

‎pkg/amqp-lib/.travis.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ git:
66
language: php
77

88
php:
9-
- '5.6'
10-
- '7.0'
9+
- '7.1'
10+
- '7.2'
1111

1212
cache:
1313
directories:

0 commit comments

Comments
 (0)