Skip to content

Commit f4f2172

Browse files
authored
Extract parallel execution into a dedicated class (#86)
A design issue with the current `Parallelization` trait is that: - it relies on the Container for which the behaviour changed - it provides little way to by-pass the Container which is a problem in a non Symfony App context - it provides private code but it is actually not protected due to being in a trait - a lot of verbose code has been added to accommodate the diversity of setups, which is reflected in the number of parameters passed - the piece of code is a nightmare to test - in the future we also want to provide a command instead of the trait. The trait can stay as it is handy and extending commands is sometimes awkward/impossible, but the UX could be made better via a command. However the current trait implementation does not play well with it. I'm proposing to extract it into a dedicated class. The current implementation simply ported all the code as-is. I do plan to rework it to make easier to use.
1 parent 15ae551 commit f4f2172

File tree

4 files changed

+435
-219
lines changed

4 files changed

+435
-219
lines changed

phpstan.neon.dist

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ parameters:
1717
- path: tests/Integration/ParallelizationIntegrationTest.php
1818
message: '#ParallelizationIntegrationTest::\$noSubProcessCommand#'
1919

20+
- path: src/ParallelExecutor.php
21+
message: '#Call to method reset\(\) on an unknown class .*ResettableContainerInterface#'
22+
2023
- path: tests/ChunkedItemsIteratorTest.php
2124
message: '#Parameter \#2 \$fetchItems of static method .+ChunkedItemsIterator::fromItemOrCallable\(\) expects callable\(\)#'
22-
23-
- '#unknown class Symfony\\Component\\DependencyInjection\\ResettableContainerInterface#'

src/Logger/LoggerFactory.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Webmozarts Console Parallelization package.
5+
*
6+
* (c) Webmozarts GmbH <office@webmozarts.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Webmozarts\Console\Parallelization\Logger;
15+
16+
use Symfony\Component\Console\Output\OutputInterface;
17+
18+
interface LoggerFactory
19+
{
20+
public function create(OutputInterface $output): Logger;
21+
}

0 commit comments

Comments
 (0)