Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Add a new time limit receiver #27130

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

Merged
merged 1 commit into from
May 4, 2018

Conversation

sdelicata
Copy link
Contributor

Q A
Branch? master for features
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

New feature to add a time limit option to the ConsumeMessagesCommand.

bin/console messenger:consume-messages <receiver-name> -t 3600

private $timeLimit;
private $logger;

public function __construct(ReceiverInterface $decoratedReceiver, int $timeLimit, LoggerInterface $logger = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

please name the variable like $timeLimitInSeconds to make it clear what unit this is in

if ($endTime < time()) {
$this->stop();
if (null !== $this->logger) {
$this->logger->info('Receiver stopped due to time limit of {timeLimit} reached', array('timeLimit' => $this->timeLimit));
Copy link
Contributor

Choose a reason for hiding this comment

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

unit seconds missing


$timeoutReceiver = new StopWhenTimeLimitIsReachedReceiver($decoratedReceiver, 1, $logger);
$timeoutReceiver->receive(function () {
sleep(2);
Copy link
Member

Choose a reason for hiding this comment

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

in order to not really wait for 2s during tests, the test case should be @group time-sensitive

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone May 2, 2018
@sroze sroze added the Messenger label May 3, 2018
@@ -70,6 +72,10 @@ protected function configure(): void
Use the --memory-limit option to stop the worker if it exceeds a given memory usage limit. You can use shorthand byte values [K, M or G]:

<info>php %command.full_name% <receiver-name> --memory-limit=128M</info>

Use the --time-limit option to stop the worker if it the given time limit is reached:
Copy link
Contributor

Choose a reason for hiding this comment

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

- if it
+ when
- given time limit
+ given time limit (in seconds)

@sroze
Copy link
Contributor

sroze commented May 4, 2018

@sdelicata your commits have multiple authors: could you squash them into one for us please?

@sdelicata
Copy link
Contributor Author

@sroze Done !

@sroze
Copy link
Contributor

sroze commented May 4, 2018

Thank you @sdelicata.

@sroze sroze merged commit 5536ee1 into symfony:master May 4, 2018
sroze added a commit that referenced this pull request May 4, 2018
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Messenger] Add a new time limit receiver

| Q             | A
| ------------- | ---
| Branch?       | master for features
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

New feature to add a time limit option to the ConsumeMessagesCommand.
```
bin/console messenger:consume-messages <receiver-name> -t 3600
```

Commits
-------

5536ee1 Add a new time limit receiver
@fabpot fabpot mentioned this pull request May 7, 2018
if ($endTime < time()) {
$this->stop();
if (null !== $this->logger) {
$this->logger->info('Receiver stopped due to time limit of {timeLimit}s reached', array('timeLimit' => $this->timeLimitInSeconds));

Choose a reason for hiding this comment

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

use short array syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants