8000 [Messenger] Allow to define batch size when using `BatchHandlerTrait` with `getBatchSize()` by alexandre-daubois · Pull Request #49428 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Allow to define batch size when using BatchHandlerTrait with getBatchSize() #49428

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Messenger] Allow to define batch size when using BatchHandlerTrait
… with `getBatchSize()`
  • Loading branch information
alexandre-daubois committed Feb 17, 2023
commit 421b46cb816f137adeffaaccf693d8940a4ff74a
1 change: 1 addition & 0 deletions src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CHANGELOG
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransport` and
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory`
* Allow passing a string instead of an array in `TransportNamesStamp`
* Allow to define batch size when using `BatchHandlerTrait` with `getBatchSize()`

6.2
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private function handle(object $message, ?Acknowledger $ack): mixed

private function shouldFlush(): bool
{
return 10 <= \count($this->jobs);
return $this->getBatchSize() <= \count($this->jobs);
}

/**
Expand All @@ -64,4 +64,9 @@ private function shouldFlush(): bool
* @list<array{0: object, 1: Acknowledger}> $jobs A list of pairs of messages and their corresponding acknowledgers
*/
abstract private function process(array $jobs): void;

private function getBatchSize(): int
{
return 10;
}
}
7311
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ public function __invoke(DummyMessage $message, Acknowledger $ack = null)
return $this->handle($message, $ack);
}

private function shouldFlush()
private function getBatchSize(): int
{
return 2 <= \count($this->jobs);
return 2;
}

private function process(array $jobs): void
Expand Down
0