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

[Messenger] Add a new time limit receiver #27130

Merged
merged 1 commit into from May 4, 2018

Conversation

Projects
None yet
6 participants
@sdelicata
Contributor

sdelicata commented May 2, 2018

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)

This comment has been minimized.

@Tobion

Tobion May 2, 2018

Member

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));

This comment has been minimized.

@Tobion

Tobion May 2, 2018

Member

unit seconds missing

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

This comment has been minimized.

@nicolas-grekas

nicolas-grekas May 2, 2018

Member

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:

This comment has been minimized.

@sroze

sroze May 3, 2018

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

sroze approved these changes May 4, 2018

@Tobion

Tobion approved these changes May 4, 2018

@sroze

This comment has been minimized.

Member

sroze commented May 4, 2018

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

@sdelicata

This comment has been minimized.

Contributor

sdelicata commented May 4, 2018

@sroze Done !

@sroze

This comment has been minimized.

Member

sroze commented May 4, 2018

Thank you @sdelicata.

@sroze sroze merged commit 5536ee1 into symfony:master May 4, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

sroze added a commit that referenced this pull request May 4, 2018

feature #27130 [Messenger] Add a new time limit receiver (sdelicata)
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 referenced this pull request May 7, 2018

Merged

Release v4.1.0-BETA1 #27181

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));

This comment has been minimized.

@lucchese-pd

lucchese-pd May 11, 2018

use short array syntax

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