Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

feat(messenger): Add Symfony Messenger integration #56

Merged
merged 1 commit into from
Jun 7, 2019

Conversation

k911
Copy link
Owner

@k911 k911 commented May 8, 2019

Asynchronously dispatch messages using Symfony Messanger API and Swoole inter-process communication (Swoole task) without serialization.

Notice: Symfony messenger messenger:consume-messages command is not supported. Dispatched messages are handled in task worker processes of Swoole server via Swoole\Server->task() interface, and thus cannot be dispatched in independent PHP process.

Usage:

  1. Install symfony/messenger package via composer

  2. Enable task workers inside configuration

    Example:

    # config/packages/swoole.yaml
    swoole:
        http_server:
            ...
            settings:
                ...
                task_worker_count: auto
  3. Configure swoole messenger transport

    Example:

    # config/packages/messenger.yaml
    framework:
        messenger:
            transports:
                swoole: swoole://task
            routing:
                '*': swoole
  4. (optional) Follow official symfony messenger guide to define message object and its handler

Relates to #4

@k911 k911 self-assigned this May 8, 2019
@k911 k911 mentioned this pull request May 8, 2019
19 tasks
@codecov-io
Copy link

codecov-io commented May 8, 2019

Codecov Report

Merging #56 into develop will increase coverage by 0.32%.
The diff coverage is 86.36%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop      #56      +/-   ##
=============================================
+ Coverage      84.73%   85.05%   +0.32%     
- Complexity       468      502      +34     
=============================================
  Files             67       77      +10     
  Lines           1448     1526      +78     
=============================================
+ Hits            1227     1298      +71     
- Misses           221      228       +7
Impacted Files Coverage Δ Complexity Δ
src/Server/TaskHandler/NoOpTaskFinishedHandler.php 0% <0%> (ø) 1 <1> (?)
...dge/Symfony/Bundle/Command/ServerStatusCommand.php 100% <100%> (ø) 8 <0> (ø) ⬇️
...rc/Server/Configurator/WithTaskFinishedHandler.php 100% <100%> (ø) 3 <3> (?)
...mfony/Bundle/DependencyInjection/Configuration.php 98.66% <100%> (+0.02%) 8 <0> (ø) ⬇️
src/Server/HttpServer.php 87.93% <100%> (+0.43%) 28 <1> (+1) ⬆️
...ony/Messenger/SwooleServerTaskTransportFactory.php 100% <100%> (ø) 3 <3> (?)
src/Server/TaskHandler/NoOpTaskHandler.php 100% <100%> (ø) 1 <1> (?)
src/Server/Configurator/WithTaskHandler.php 100% <100%> (ø) 3 <3> (?)
...senger/Exception/ReceiverNotAvailableException.php 100% <100%> (ø) 1 <1> (?)
...ony/Bundle/DependencyInjection/SwooleExtension.php 84.61% <100%> (+1.43%) 35 <1> (+2) ⬆️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 427dd2b...1dd01ba. Read the comment docs.

@k911 k911 force-pushed the feature/symfony-messenger branch from 4ffe654 to e32e73e Compare June 6, 2019 20:46
@k911 k911 force-pushed the feature/symfony-messenger branch 2 times, most recently from 00fa63c to 65906f8 Compare June 6, 2019 21:10
Asynchronously dispatch messages using Symfony Messanger API and Swoole inter-process communication (Swoole task) without serialization.

Notice: Symfony messenger `messenger:consume-messages` command is not supported. Dispatched messages are handled in task worker processes of Swoole server.

Usage:

1. Install `symfony/messenger` package via composer
2. Enable task workers inside configuration

    Example:

    ```yaml
    # config/packages/swoole.yaml
    swoole:
        http_server:
            ...
            settings:
                ...
                task_worker_count: auto
    ```
3. Configure swoole messenger transport

   Example:

   ```yaml
   # config/packages/messenger.yaml
   framework:
       messenger:
           transports:
               swoole: swoole://task
           routing:
               '*': swoole
   ```
4. (optional) Follow official [symfony messenger guide](https://symfony.com/doc/current/messenger.html) to define message object and its handler

Relates to #4
@k911 k911 force-pushed the feature/symfony-messenger branch from 65906f8 to 1dd01ba Compare June 6, 2019 21:32
@codeclimate
Copy link

codeclimate bot commented Jun 6, 2019

Code Climate has analyzed commit 1dd01ba and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 84.8% (50% is the threshold).

This pull request will bring the total coverage in the repository to 85.2% (0.2% change).

View more on Code Climate.

@k911 k911 merged commit d136313 into develop Jun 7, 2019
@k911 k911 deleted the feature/symfony-messenger branch June 7, 2019 15:31
@k911 k911 removed the status/wip Work in progress label Jul 18, 2019
k911 pushed a commit that referenced this pull request Aug 11, 2019
##  (2019-08-11)

* docs: Add bug report template (#61) ([45aa20e](45aa20e)), closes [#61](#61)
* docs: Add contributing guide (#58) ([f49f159](f49f159)), closes [#58](#58)
* docs: Add feature request template (#62) ([a7dbbe1](a7dbbe1)), closes [#62](#62)
* docs: Create Code of Conduct (#60) ([e185638](e185638)), closes [#60](#60)
* docs(messenger): Add documentation about Symfony Messenger integration (#64) ([37d18bc](37d18bc)), closes [#64](#64)
* docs(readme): Add build matrix ([35d88ad](35d88ad))
* ci: Add composer option '--ignore-platform-reqs' to CI Jobs ([f0c2b73](f0c2b73))
* chore(composer): Upgrade dependencies (#59) ([49b75b4](49b75b4)), closes [#59](#59)
* feat(messenger): Add Symfony Messenger integration (#56) ([d136313](d136313)), closes [#56](#56) [#4](#4)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants