Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
### Changed

- 4cc83f1: Replace child process shutdown function and improve typings.
- d6ecf04: Rebrand library to `phpfork`.
  • Loading branch information
TheLevti committed Feb 2, 2020
2 parents 29109b7 + e2ba975 commit ce608b4
Show file tree
Hide file tree
Showing 44 changed files with 278 additions and 232 deletions.
2 changes: 1 addition & 1 deletion .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'src/Spork',
'src',
'vendor/symfony/event-dispatcher',
'vendor/symfony/event-dispatcher-contracts',
'vendor/symfony/var-dumper',
Expand Down
20 changes: 14 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.0.0] - 2020-02-02

### Changed

- 4cc83f1: Replace child process shutdown function and improve typings.
- d6ecf04: Rebrand library to `phpfork`.

## [2.0.2] - 2020-02-02

### Changed
Expand Down Expand Up @@ -65,9 +72,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added progress callbacks to Deferred.
- Added serializable objects for exit and error messages.

[Unreleased]: https://github.com/TheLevti/spork/compare/2.0.2...HEAD
[2.0.2]: https://github.com/TheLevti/spork/releases/2.0.2
[2.0.1]: https://github.com/TheLevti/spork/releases/2.0.1
[2.0.0]: https://github.com/TheLevti/spork/releases/2.0.0
[1.0.0]: https://github.com/TheLevti/spork/releases/1.0.0
[0.3.0]: https://github.com/TheLevti/spork/releases/0.3.0
[Unreleased]: https://github.com/TheLevti/phpfork/compare/3.0.0...HEAD
[3.0.0]: https://github.com/TheLevti/phpfork/releases/3.0.0
[2.0.2]: https://github.com/TheLevti/phpfork/releases/2.0.2
[2.0.1]: https://github.com/TheLevti/phpfork/releases/2.0.1
[2.0.0]: https://github.com/TheLevti/phpfork/releases/2.0.0
[1.0.0]: https://github.com/TheLevti/phpfork/releases/1.0.0
[0.3.0]: https://github.com/TheLevti/phpfork/releases/0.3.0
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
**[Installation](#installation)** |
**[Usage](#usage)**

# thelevti/spork
# thelevti/phpfork

[![Build Status](https://travis-ci.com/TheLevti/spork.svg?branch=master)](https://travis-ci.com/TheLevti/spork)
[![Build Status](https://travis-ci.com/TheLevti/phpfork.svg?branch=master)](https://travis-ci.com/TheLevti/phpfork)

PHP on a fork.

`thelevti/spork` follows semantic versioning. Read more on [semver.org][1].
`thelevti/phpfork` follows semantic versioning. Read more on [semver.org][1].

----

Expand All @@ -29,21 +29,21 @@ To use this library through [composer][5], run the following terminal command
inside your repository's root folder.

```sh
composer require "thelevti/spork"
composer require "thelevti/phpfork"
```

## Usage

This library uses the namespace `Spork`.
This library uses the namespace `Phpfork`.

```php
<?php

$manager = new Spork\ProcessManager();
$manager = new Phpfork\ProcessManager();
$manager->fork(function () {
// do something in another process!
return 'Hello from ' . getmypid();
})->then(function (Spork\Fork $fork) {
})->then(function (Phpfork\Fork $fork) {
// do something in the parent process when it's done!
echo "{$fork->getPid()} says '{$fork->getResult()}'\n";
});
Expand All @@ -60,7 +60,7 @@ multiple batches and spread them across many processes.
$files = new RecursiveDirectoryIterator('/path/to/images');
$files = new RecursiveIteratorIterator($files);

$manager = new Spork\ProcessManager();
$manager = new Phpfork\ProcessManager();
$manager->process($files, function(SplFileInfo $file) {
// upload this file
});
Expand Down Expand Up @@ -114,15 +114,15 @@ $callback = function ($value) use ($params) {
$parentConnection = Doctrine\DBAL\DriverManager::getConnection($params);
$parentConnection->connect();

$dispatcher = new Spork\EventDispatcher\EventDispatcher();
$dispatcher->addListener(Spork\EventDispatcher\Events::PRE_FORK, function () use ($parentConnection) {
$dispatcher = new Phpfork\EventDispatcher\EventDispatcher();
$dispatcher->addListener(Phpfork\EventDispatcher\Events::PRE_FORK, function () use ($parentConnection) {
$parentConnection->close();
});

$manager = new Spork\ProcessManager($dispatcher, null, true);
$manager = new Phpfork\ProcessManager($dispatcher, null, true);

/** @var Spork\Fork $fork */
$fork = $manager->process($dataArray, $callback, new Spork\Batch\Strategy\ChunkStrategy($forks));
/** @var Phpfork\Fork $fork */
$fork = $manager->process($dataArray, $callback, new Phpfork\Batch\Strategy\ChunkStrategy($forks));
$manager->wait();

$result = $fork->getResult();
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thelevti/spork",
"description": "PHP on a fork.",
"name": "thelevti/phpfork",
"description": "PHP process forking library.",
"type": "library",
"keywords": [
"php",
Expand All @@ -9,7 +9,7 @@
"async",
"shmop"
],
"homepage": "https://github.com/TheLevti/spork",
"homepage": "https://github.com/TheLevti/phpfork",
"readme": "README.md",
"license": "MIT",
"authors": [
Expand All @@ -28,11 +28,11 @@
],
"support": {
"email": "[email protected]",
"issues": "https://github.com/TheLevti/spork/issues",
"wiki": "https://github.com/TheLevti/spork/wiki",
"source": "https://github.com/TheLevti/spork",
"docs": "https://github.com/TheLevti/spork/blob/master/README.md",
"rss": "https://github.com/TheLevti/spork/commits/master.atom"
"issues": "https://github.com/TheLevti/phpfork/issues",
"wiki": "https://github.com/TheLevti/phpfork/wiki",
"source": "https://github.com/TheLevti/phpfork",
"docs": "https://github.com/TheLevti/phpfork/blob/master/README.md",
"rss": "https://github.com/TheLevti/phpfork/commits/master.atom"
},
"require": {
"php": "^7.2.0",
Expand All @@ -51,18 +51,18 @@
},
"autoload": {
"psr-4": {
"Spork\\": "src/Spork/"
"Phpfork\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Spork\\": "tests/Spork/"
"Phpfork\\": "tests/"
}
},
"suggest": {
"ext-pnctl": "To allow this library forking processes.",
"ext-posix": "To allow this library getting process information.",
"ext-shmop": "To allow this library doing interprocess communication."
"ext-shmop": "To allow this library doing inter-process communication."
},
"archive": {
"exclude": [
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
Expand All @@ -11,13 +11,13 @@
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Spork Test Suite">
<testsuite name="Phpfork Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/Spork</directory>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
16 changes: 9 additions & 7 deletions src/Spork/Batch/BatchJob.php → src/Batch/BatchJob.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Batch;
declare(strict_types=1);

use Spork\Batch\Strategy\ChunkStrategy;
use Spork\Batch\Strategy\StrategyInterface;
use Spork\Exception\UnexpectedTypeException;
use Spork\ProcessManager;
namespace Phpfork\Batch;

use Phpfork\Batch\Strategy\ChunkStrategy;
use Phpfork\Batch\Strategy\StrategyInterface;
use Phpfork\Exception\UnexpectedTypeException;
use Phpfork\ProcessManager;

class BatchJob
{
Expand Down
12 changes: 7 additions & 5 deletions src/Spork/Batch/BatchRunner.php → src/Batch/BatchRunner.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Batch;
declare(strict_types=1);

use Spork\Exception\UnexpectedTypeException;
use Spork\SharedMemory;
namespace Phpfork\Batch;

use Phpfork\Exception\UnexpectedTypeException;
use Phpfork\SharedMemory;

class BatchRunner
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Batch\Strategy;
declare(strict_types=1);

use Spork\Batch\BatchRunner;
namespace Phpfork\Batch\Strategy;

use Phpfork\Batch\BatchRunner;

abstract class AbstractStrategy implements StrategyInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Batch\Strategy;
declare(strict_types=1);

use Spork\Exception\UnexpectedTypeException;
namespace Phpfork\Batch\Strategy;

use Phpfork\Exception\UnexpectedTypeException;

class CallbackStrategy extends AbstractStrategy
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Batch\Strategy;
declare(strict_types=1);

use Spork\Exception\UnexpectedTypeException;
namespace Phpfork\Batch\Strategy;

use Phpfork\Exception\UnexpectedTypeException;

/**
* Creates the batch iterator using array_chunk().
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Batch\Strategy;
declare(strict_types=1);

namespace Phpfork\Batch\Strategy;

/**
* @see BatchJob::__invoke()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Batch\Strategy;
declare(strict_types=1);

use Spork\Util\ThrottleIterator;
namespace Phpfork\Batch\Strategy;

use Phpfork\Util\ThrottleIterator;

class ThrottleStrategy implements StrategyInterface
{
Expand Down
10 changes: 6 additions & 4 deletions src/Spork/Deferred/Deferred.php → src/Deferred/Deferred.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

/*
* This file is part of Spork, an OpenSky project.
* This file is part of the thelevti/phpfork package.
*
* (c) OpenSky Project Inc
* (c) Petr Levtonov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Spork\Deferred;
declare(strict_types=1);

use Spork\Exception\UnexpectedTypeException;
namespace Phpfork\Deferred;

use Phpfork\Exception\UnexpectedTypeException;

class Deferred implements DeferredInterface
{
Expand Down
Loading

0 comments on commit ce608b4

Please sign in to comment.