Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Add debug:messenger CLI command#26803

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sroze merged 3 commits intosymfony:4.1fromro0NL:debug-messenger
May 9, 2018
Merged

[Messenger] Add debug:messenger CLI command#26803

sroze merged 3 commits intosymfony:4.1fromro0NL:debug-messenger
May 9, 2018

Conversation

@ro0NL
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#...
LicenseMIT
Doc PRsymfony/symfony-docs#...

Adds adebug:messenger CLI command to expose message classes that can be dispatched. Heavily inspired bydebug:autowiring.

chalasr, Nyholm, yceruto, andreybolonin, and Koc reacted with heart emoji
@ogizanagi
Copy link
Contributor

One less PR to do on my list :)

The tactician debug command looks like this:

Tactician routing=================Bus: default------------ ----------------------------------------------------- -----------------   Command                                               Handler Service   ----------------------------------------------------- -----------------   League\Tactician\Bundle\Tests\Fake\FakeCommand        a.handler          League\Tactician\Bundle\Tests\Fake\OtherFakeCommand   b.handler         ----------------------------------------------------- -----------------

https://github.com/thephpleague/tactician-bundle/blob/master/tests/Integration/DebugCommandTest.php#L37-L48

Would be great to have messages <-> handlers too here.

chalasr, sroze, yceruto, and andreybolonin reacted with thumbs up emoji

{
$this
->setDefinition(array(
newInputArgument('search', InputArgument::OPTIONAL,'A search filter'),
Copy link
Contributor

@ogizanagiogizanagiApr 4, 2018
edited
Loading

Choose a reason for hiding this comment

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

Not convinced this is useful until we have more info to show about a message. A simplegrep is enough for this for now.

sroze reacted with thumbs up emoji
@ro0NL
Copy link
ContributorAuthor

ro0NL commentedApr 4, 2018
edited
Loading

A message can have multiple handlers .. 🤔

Also the intend was concerning end users who mostly care about$bus->dispatch($whatCanIPutHere).

@ogizanagi
Copy link
Contributor

A message can have multiple handlers ..

Wasn't the case with tactician, but it's not a problem here. Just show all associated handlers.

Also the intend was concerning end users who mostly care about $bus->dispatch($whatCanIPutHere).

Would still be useful in this way :)

fabpot
fabpot previously requested changesApr 6, 2018
* file that was distributed with this source code.
*/

namespaceSymfony\Bundle\FrameworkBundle\Command;
Copy link
Member

Choose a reason for hiding this comment

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

Should be moved to the component like the other Messenger commands.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

@ro0NL
Copy link
ContributorAuthor

Latest version

image

andreybolonin reacted with hooray emoji

$tableRows =array();
foreach ($this->mappingas$message =>$handlers) {
$tableRows[] =array(sprintf('<fg=cyan>%s</fg=cyan>',$message));
foreach ($handlersas$handler) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that having the list of handlers in another column would make more sense and be more coherent with the rest of thedebug: commands as well.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

well.. i tookdebug:autowring for inspiration. IMHO that one reads well :)

Also with multiple columns we probably run into a spacing issue, assuming all service IDs are FQCN.

theofidry and sroze reacted with thumbs up emoji
$io =newSymfonyStyle($input,$output);

$io->title('Message Bus');
$io->text('The following classes can be dispatch:');
Copy link
Contributor

Choose a reason for hiding this comment

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

The following messages can be dispatched:

{
$io =newSymfonyStyle($input,$output);

$io->title('Message Bus');
Copy link
Contributor

Choose a reason for hiding this comment

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

Messenger

@weaverryan
Copy link
Member

Ido like the table layout mentioned above#26803 (comment) - it's just a bit easier to read.

I realize that it's possible for a message to have several handlers. This is an edge-case, and I think we could handle that like this:

 ----------------------------------------------------- -----------------   Command                                               Handler Service   ----------------------------------------------------- -----------------   League\Tactician\Bundle\Tests\Fake\FakeCommand        a.handler                                                                c.handler          League\Tactician\Bundle\Tests\Fake\OtherFakeCommand   b.handler         ----------------------------------------------------- -----------------

@sroze
Copy link
Contributor

This PR needs to be updated following#26864 :)

@ro0NL
Copy link
ContributorAuthor

Rebased.

@sroze we cant group messages per bus as there's no such concept, so it's still a single list of messages.

@weaverryan can you update the table example with handler services likeLeague\Tactician\Bundle\Tests\Fake\FakeCommandHandler and then tell me if 2 column layout works for you :)

@weaverryan
Copy link
Member

As we talked about, the table layout I suggested won’t work - class names are too long. So, the original format should be used, but probably with some added coloration to make it nice and clear :)

Copy link
Contributor

@srozesroze left a comment

Choose a reason for hiding this comment

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

Looks good. Just two minor comments.

<tagname="console.command"command="messenger:consume-messages" />
</service>

<serviceid="console.command.messenger_debug"class="Symfony\Component\Messenger\Command\DebugMessengerCommand">
Copy link
Contributor

Choose a reason for hiding this comment

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

All the commands are namedNameDebugCommand, notDebugNameCommand. Could you change it to be something consistent with the rest?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

All the commands exceptDebugAutowiringCommand.. which i took as a template 😅 now updated.

protectedfunctionconfigure()
{
$this
->setDescription('Lists classes you can dispatch using the message bus')
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest "message classes" or "messages" (as you say "The following messages [...]" in the output)

Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

Looks good. A functional test case would have been nice, maybe could you just share a screenshot of the final output?

@weaverryan
Copy link
Member

Here's a current screenshot, which I think looks quite good :).

screen shot 2018-05-03 at 9 06 01 am

We could perhaps do it in a different PR, but what about showing where each message is routed?

sroze and chalasr reacted with thumbs up emoji

weaverryan
weaverryan previously requested changesMay 3, 2018
$tableRows[] =array(sprintf(' handled by %s',$handler));
}
}
$io->table(array(),$tableRows);
Copy link
Member

Choose a reason for hiding this comment

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

Minor, but we should print some message here if there are NO messages, like:

No messages were found that have valid handlers.

yceruto and sroze reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

@ro0NL can you update this PR at some point? Will be for beta2 now but can still be in 4.1 :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

@srozesroze dismissedfabpot’sstale reviewMay 3, 2018 13:15

Changes have been made 20+ days ago :)

@nicolas-grekasnicolas-grekas changed the base branch frommaster to4.1May 7, 2018 15:06
Copy link
Member

@ycerutoyceruto left a comment

Choose a reason for hiding this comment

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

👍

*
* @experimental in 4.1
*/
class MessengerDebugCommandextends Command
Copy link
Member

@ycerutoycerutoMay 8, 2018
edited
Loading

Choose a reason for hiding this comment

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

Shouldn't it be namedDebugCommand like debug commands in other components?

ogizanagi reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Good point@yceruto, you are right. Commands within components' namespace are not prefixed with the component name, let's keep it this way :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Renamed 👍

@ro0NL
Copy link
ContributorAuthor

Thx@sroze .. still no clue about failing test :(

@ogizanagi
Copy link
Contributor

ogizanagi commentedMay 9, 2018
edited
Loading

@ro0NL :deps=high failure expected. Fordeps=low, try updating the Framework bundlecomposer.json file to requiresymfony/messenger~4.1-beta2

@ogizanagi
Copy link
Contributor

ogizanagi commentedMay 9, 2018
edited
Loading

The-beta2 part is important, asprefer-stable andprefer-lowest is used, so it selects the released beta1 first when using just@beta

@ro0NL
Copy link
ContributorAuthor

your're right. switched it to@dev. Not surebeta2 will resolve... :S should we try? 😓

@ogizanagi
Copy link
Contributor

That's usually what is done, so unless I'm missing something it should work:e81005e. It should resolve as far asminimum-stability allows it (which does)

ro0NL reacted with hooray emoji

@sroze
Copy link
Contributor

Yay, and tests are all green now. Thanks@ogizanagi for the hint.

@sroze
Copy link
Contributor

Thanks@ro0NL for working on this feature, this is much appreciated.

@srozesroze merged commit7f87309 intosymfony:4.1May 9, 2018
sroze added a commit that referenced this pull requestMay 9, 2018
…oze)This PR was merged into the 4.1 branch.Discussion----------[Messenger] Add debug:messenger CLI command| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->Adds a `debug:messenger` CLI command to expose message classes that can be dispatched. Heavily inspired by `debug:autowiring`.Commits-------7f87309 fix deps290c7eb Rename the command `DebugCommand`9847b83 [Messenger] Add debug:messenger CLI command
@ro0NLro0NL deleted the debug-messenger branchMay 10, 2018 15:16
@fabpotfabpot mentioned this pull requestMay 21, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ycerutoycerutoyceruto left review comments

@chalasrchalasrchalasr approved these changes

@fabpotfabpotfabpot left review comments

@weaverryanweaverryanweaverryan left review comments

+2 more reviewers

@ogizanagiogizanagiogizanagi left review comments

@srozesrozesroze approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

9 participants

@ro0NL@ogizanagi@weaverryan@sroze@fabpot@yceruto@chalasr@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp