-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
----------------------------------------------------- ----------------- Would be great to have messages <-> handlers too here. |
{ | ||
$this | ||
->setDefinition(array( | ||
new InputArgument('search', InputArgument::OPTIONAL, 'A search filter'), |
There was a problem hiding this comment.
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 simple grep
is enough for this for now.
A message can have multiple handlers .. 🤔 Also the intend was concerning end users who mostly care about |
Wasn't the case with tactician, but it's not a problem here. Just show all associated handlers.
Would still be useful in this way :) |
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Command; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
$tableRows = array(); | ||
foreach ($this->mapping as $message => $handlers) { | ||
$tableRows[] = array(sprintf('<fg=cyan>%s</fg=cyan>', $message)); | ||
foreach ($handlers as $handler) { |
There was a problem hiding this comment.
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 the debug:
commands as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well.. i took debug: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.
$io = new SymfonyStyle($input, $output); | ||
|
||
$io->title('Message Bus'); | ||
$io->text('The following classes can be dispatch:'); |
There was a problem hiding this comment.
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 = new SymfonyStyle($input, $output); | ||
|
||
$io->title('Message Bus'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messenger
I do 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
----------------------------------------------------- ----------------- |
This PR needs to be updated following #26864 :) |
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 like |
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 :) |
There was a problem hiding this 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.
@@ -77,6 +77,11 @@ | |||
<tag name="console.command" command="messenger:consume-messages" /> | |||
</service> | |||
|
|||
<service id="console.command.messenger_debug" class="Symfony\Component\Messenger\Command\DebugMessengerCommand"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the commands are named NameDebugCommand
, not DebugNameCommand
. Could you change it to be something consistent with the rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the commands except DebugAutowiringCommand
.. which i took as a template 😅 now updated.
protected function configure() | ||
{ | ||
$this | ||
->setDescription('Lists classes you can dispatch using the message bus') |
There was a problem hiding this comment.
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)
There was a problem hiding this 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?
$tableRows[] = array(sprintf(' handled by %s', $handler)); | ||
} | ||
} | ||
$io->table(array(), $tableRows); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this 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 MessengerDebugCommand extends Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be named DebugCommand
like debug commands in other components?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed 👍
Thx @sroze .. still no clue about failing test :( |
@ro0NL : |
The |
your're right. switched it to |
That's usually what is done, so unless I'm missing something it should work: e81005e. It should resolve as far as |
Yay, and tests are all green now. Thanks @ogizanagi for the hint. |
Thanks @ro0NL for working on this feature, this is much appreciated. |
…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 <!-- see https://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 deps 290c7eb Rename the command `DebugCommand` 9847b83 [Messenger] Add debug:messenger CLI command
Adds a
debug:messenger
CLI command to expose message classes that can be dispatched. Heavily inspired bydebug:autowiring
.