Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Renames RequestHandlerSwooleRunner to SwooleRequestHandlerRunner
Browse files Browse the repository at this point in the history
The base name is `RequestHandlerRunner`; `Swoole` is the specific
variation.
  • Loading branch information
weierophinney committed Aug 29, 2018
1 parent 8ff24fd commit 6d400b6
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/book/how_it_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using the `on(string $name, callable $action)` method.
The request handler implemented in zend-expressive-swoole is a runner that
enables the execution of an Expressive application inside the `on('request')`
event of `Swoole\Http\Server`. This runner is implemented in the
`Zend\Expressive\Swoole\RequestHandlerSwooleRunner` class.
`Zend\Expressive\Swoole\SwooleRequestHandlerRunner` class.

The basic implementation looks similar to the following:

Expand Down
8 changes: 4 additions & 4 deletions docs/book/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ log application details. All logs we emit use `Psr\Log\LogLevel::INFO`.

To substitute your own logger, you have two options.

If you are manually instantiating a `Zend\Expressive\Swoole\RequestHandlerSwooleRunner`
If you are manually instantiating a `Zend\Expressive\Swoole\SwooleRequestHandlerRunner`
instance, you may provide it as the sixth argument to the constructor:

```php
use Zend\Expressive\Swoole\RequestHandlerSwooleRunner;
use Zend\Expressive\Swoole\SwooleRequestHandlerRunner;

$runner = new RequestHandlerSwooleRunner(
$runner = new SwooleRequestHandlerRunner(
$application,
$serverRequestFactory,
$serverRequestErrorResponseGenerator,
Expand All @@ -37,6 +37,6 @@ $runner = new RequestHandlerSwooleRunner(
);
```

If using the provided factory (`RequestHandlerSwooleRunnerFactory`) & which
If using the provided factory (`SwooleRequestHandlerRunnerFactory`) & which
is the default when using the functionality with Expressive & you can
provide the logger via the `Psr\Log\LoggerInterface` service.
8 changes: 3 additions & 5 deletions docs/book/static-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ filesystem. zend-expressive-swoole provides that capability as well.

To enable this, the package provides an alternate
[`RequestHandlerRunner`](https://docs.zendframework.com/zend-httphandlerrunner/runner/)
implementation via the class `Zend\Expressive\Swoole\RequestHandlerSwooleRunner`
implementation via the class `Zend\Expressive\Swoole\SwooleRequestHandlerRunner`
that performs two duties:

- If a static resource is matched, it serves that.
- Otherwise, it passes off handling to the composed application pipeline.

Internally, the `RequestHandlerSwooleRunner` composes another class, a
Internally, the `SwooleRequestHandlerRunner` composes another class, a
`Zend\Expressive\Swoole\StaticResourceHandlerInterface` instance. This instance
is first queried to determine if a static resource was matched, and, if so, then
invoked in order to serve it.
Expand Down Expand Up @@ -105,7 +105,6 @@ The following demonstrates all currently available configuration options:

```php
// config/autoload/swoole.local.php
use Zend\Expressive\Swoole\RequestHandlerSwooleRunner;

return [
'zend-expressive-swoole' => [
Expand Down Expand Up @@ -196,7 +195,6 @@ The example which follows provides the following options:

```php
// config/autoload/swoole.local.php
use Zend\Expressive\Swoole\RequestHandlerSwooleRunner;

return [
'zend-expressive-swoole' => [
Expand Down Expand Up @@ -348,7 +346,7 @@ potentially disable returning the response body (via `disableContent()`).
## Alternative static resource handlers

As noted at the beginning of this chapter, the the `RequestHandlerSwooleRunner`
As noted at the beginning of this chapter, the the `SwooleRequestHandlerRunner`
composes a `StaticResourceHandlerInterface` instance in order to determine if a
resource was matched by the request, and then to serve it.

Expand Down
2 changes: 1 addition & 1 deletion src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getDependencies() : array
return [
'factories' => [
PidManager::class => PidManagerFactory::class,
RequestHandlerRunner::class => RequestHandlerSwooleRunnerFactory::class,
RequestHandlerRunner::class => SwooleRequestHandlerRunnerFactory::class,
ServerFactory::class => ServerFactoryFactory::class,
ServerRequestInterface::class => ServerRequestSwooleFactory::class,
StaticResourceHandlerInterface::class => StaticResourceHandlerFactory::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* then the runner will use the composed error response generator to generate a
* response, based on the exception or throwable raised.
*/
class RequestHandlerSwooleRunner extends RequestHandlerRunner
class SwooleRequestHandlerRunner extends RequestHandlerRunner
{
/**
* Keep CWD in daemon mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Zend\Expressive\ApplicationPipeline;
use Zend\Expressive\Response\ServerRequestErrorResponseGenerator;

class RequestHandlerSwooleRunnerFactory
class SwooleRequestHandlerRunnerFactory
{
public function __invoke(ContainerInterface $container) : RequestHandlerSwooleRunner
public function __invoke(ContainerInterface $container) : SwooleRequestHandlerRunner
{
$staticResourceHandler = $container->has(StaticResourceHandlerInterface::class)
? $container->get(StaticResourceHandlerInterface::class)
Expand All @@ -26,7 +26,7 @@ public function __invoke(ContainerInterface $container) : RequestHandlerSwooleRu
? $container->get(LoggerInterface::class)
: null;

return new RequestHandlerSwooleRunner(
return new SwooleRequestHandlerRunner(
$container->get(ApplicationPipeline::class),
$container->get(ServerRequestInterface::class),
$container->get(ServerRequestErrorResponseGenerator::class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
use Zend\Expressive\Response\ServerRequestErrorResponseGenerator;
use Zend\Expressive\Swoole\Exception\InvalidConfigException;
use Zend\Expressive\Swoole\PidManager;
use Zend\Expressive\Swoole\RequestHandlerSwooleRunner;
use Zend\Expressive\Swoole\RequestHandlerSwooleRunnerFactory;
use Zend\Expressive\Swoole\SwooleRequestHandlerRunner;
use Zend\Expressive\Swoole\SwooleRequestHandlerRunnerFactory;
use Zend\Expressive\Swoole\ServerFactory;
use Zend\Expressive\Swoole\StaticResourceHandlerInterface;
use Zend\Expressive\Swoole\StdoutLogger;

class RequestHandlerSwooleRunnerFactoryTest extends TestCase
class SwooleRequestHandlerRunnerFactoryTest extends TestCase
{
public function setUp()
{
Expand Down Expand Up @@ -88,9 +88,9 @@ public function testInvocationWithoutOptionalServicesConfiguresInstanceWithDefau
{
$this->configureAbsentStaticResourceHandler();
$this->configureAbsentLoggerService();
$factory = new RequestHandlerSwooleRunnerFactory();
$factory = new SwooleRequestHandlerRunnerFactory();
$runner = $factory($this->container->reveal());
$this->assertInstanceOf(RequestHandlerSwooleRunner::class, $runner);
$this->assertInstanceOf(SwooleRequestHandlerRunner::class, $runner);
$this->assertAttributeEmpty('staticResourceHandler', $runner);
$this->assertAttributeInstanceOf(StdoutLogger::class, 'logger', $runner);
}
Expand All @@ -105,9 +105,9 @@ public function testFactoryWillUseConfiguredPsr3LoggerWhenPresent()
->get(LoggerInterface::class)
->will([$this->logger, 'reveal']);

$factory = new RequestHandlerSwooleRunnerFactory();
$factory = new SwooleRequestHandlerRunnerFactory();
$runner = $factory($this->container->reveal());
$this->assertInstanceOf(RequestHandlerSwooleRunner::class, $runner);
$this->assertInstanceOf(SwooleRequestHandlerRunner::class, $runner);
$this->assertAttributeSame($this->logger->reveal(), 'logger', $runner);
}

Expand All @@ -121,9 +121,9 @@ public function testFactoryWillUseConfiguredStaticResourceHandlerWhenPresent()
->get(StaticResourceHandlerInterface::class)
->will([$this->staticResourceHandler, 'reveal']);

$factory = new RequestHandlerSwooleRunnerFactory();
$factory = new SwooleRequestHandlerRunnerFactory();
$runner = $factory($this->container->reveal());
$this->assertInstanceOf(RequestHandlerSwooleRunner::class, $runner);
$this->assertInstanceOf(SwooleRequestHandlerRunner::class, $runner);
$this->assertAttributeSame($this->staticResourceHandler->reveal(), 'staticResourceHandler', $runner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
use Zend\Diactoros\Response;
use Zend\Expressive\Response\ServerRequestErrorResponseGenerator;
use Zend\Expressive\Swoole\PidManager;
use Zend\Expressive\Swoole\RequestHandlerSwooleRunner;
use Zend\Expressive\Swoole\SwooleRequestHandlerRunner;
use Zend\Expressive\Swoole\ServerFactory;
use Zend\Expressive\Swoole\StaticResourceHandlerInterface;
use Zend\HttpHandlerRunner\RequestHandlerRunner;

class RequestHandlerSwooleRunnerTest extends TestCase
class SwooleRequestHandlerRunnerTest extends TestCase
{
public function setUp()
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public function setUp()

public function testConstructor()
{
$requestHandler = new RequestHandlerSwooleRunner(
$requestHandler = new SwooleRequestHandlerRunner(
$this->requestHandler->reveal(),
$this->serverRequestFactory,
$this->serverRequestError,
Expand All @@ -70,7 +70,7 @@ public function testConstructor()
$this->staticResourceHandler->reveal(),
$this->logger
);
$this->assertInstanceOf(RequestHandlerSwooleRunner::class, $requestHandler);
$this->assertInstanceOf(SwooleRequestHandlerRunner::class, $requestHandler);
$this->assertInstanceOf(RequestHandlerRunner::class, $requestHandler);
}

Expand All @@ -94,7 +94,7 @@ public function testRun()
->sendStaticResource(Argument::any())
->shouldNotBeCalled();

$requestHandler = new RequestHandlerSwooleRunner(
$requestHandler = new SwooleRequestHandlerRunner(
$this->requestHandler->reveal(),
$this->serverRequestFactory,
$this->serverRequestError,
Expand Down Expand Up @@ -122,7 +122,7 @@ public function testRun()

public function testOnStart()
{
$runner = new RequestHandlerSwooleRunner(
$runner = new SwooleRequestHandlerRunner(
$this->requestHandler->reveal(),
$this->serverRequestFactory,
$this->serverRequestError,
Expand Down Expand Up @@ -164,7 +164,7 @@ public function testOnRequestDelegatesToApplicationWhenNoStaticResourceHandlerPr
->end($content)
->shouldBeCalled();

$runner = new RequestHandlerSwooleRunner(
$runner = new SwooleRequestHandlerRunner(
$this->requestHandler->reveal(),
$this->serverRequestFactory,
$this->serverRequestError,
Expand Down Expand Up @@ -211,7 +211,7 @@ public function testOnRequestDelegatesToApplicationWhenStaticResourceHandlerDoes
->sendStaticResource(Argument::any())
->shouldNotBeCalled();

$runner = new RequestHandlerSwooleRunner(
$runner = new SwooleRequestHandlerRunner(
$this->requestHandler->reveal(),
$this->serverRequestFactory,
$this->serverRequestError,
Expand Down Expand Up @@ -248,7 +248,7 @@ public function testOnRequestDelegatesToStaticResourceHandlerOnMatch()
->sendStaticResource($request, $response)
->shouldBeCalled();

$runner = new RequestHandlerSwooleRunner(
$runner = new SwooleRequestHandlerRunner(
$this->requestHandler->reveal(),
$this->serverRequestFactory,
$this->serverRequestError,
Expand Down

0 comments on commit 6d400b6

Please sign in to comment.