-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,205 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Swoft\Server; | ||
|
||
|
||
use Swoft\SwoftComponent; | ||
|
||
/** | ||
* Class AutoLoader | ||
* | ||
* @since 2.0 | ||
*/ | ||
class AutoLoader extends SwoftComponent | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function getPrefixDirs(): array | ||
{ | ||
return [ | ||
__NAMESPACE__ => __DIR__, | ||
]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function metadata(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Swoft\Server\Context; | ||
|
||
|
||
use ReflectionException; | ||
use Swoft\Bean\Concern\PrototypeTrait; | ||
use Swoft\Bean\Exception\ContainerException; | ||
use Swoft\Context\AbstractContext; | ||
use Swoole\Server as SwooleServer; | ||
use Swoft\Bean\Annotation\Mapping\Bean; | ||
|
||
/** | ||
* Class ShutdownContext | ||
* | ||
* @since 2.0 | ||
* | ||
* @Bean(scope=Bean::PROTOTYPE) | ||
*/ | ||
class ShutdownContext extends AbstractContext | ||
{ | ||
use PrototypeTrait; | ||
|
||
/** | ||
* @var SwooleServer | ||
*/ | ||
private $server; | ||
|
||
/** | ||
* @param SwooleServer $server | ||
* | ||
* @return ShutdownContext | ||
* @throws ContainerException | ||
* @throws ReflectionException | ||
*/ | ||
public static function new(SwooleServer $server): self | ||
{ | ||
$self = self::__instance(); | ||
|
||
$self->server = $server; | ||
|
||
return $self; | ||
} | ||
|
||
/** | ||
* @return SwooleServer | ||
*/ | ||
public function getSwooleServer(): SwooleServer | ||
{ | ||
return $this->server; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Swoft\Server\Context; | ||
|
||
|
||
use ReflectionException; | ||
use Swoft\Bean\Concern\PrototypeTrait; | ||
use Swoft\Bean\Exception\ContainerException; | ||
use Swoft\Context\AbstractContext; | ||
use Swoole\Server as SwooleServer; | ||
use Swoft\Bean\Annotation\Mapping\Bean; | ||
|
||
/** | ||
* Class StartContext | ||
* | ||
* @since 2.0 | ||
* | ||
* @Bean(scope=Bean::PROTOTYPE) | ||
*/ | ||
class StartContext extends AbstractContext | ||
{ | ||
use PrototypeTrait; | ||
|
||
/** | ||
* @var SwooleServer | ||
*/ | ||
private $server; | ||
|
||
/** | ||
* @param SwooleServer $server | ||
* | ||
* @return StartContext | ||
* @throws ContainerException | ||
* @throws ReflectionException | ||
*/ | ||
public static function new(SwooleServer $server): self | ||
{ | ||
$self = self::__instance(); | ||
|
||
$self->server = $server; | ||
|
||
return $self; | ||
} | ||
|
||
/** | ||
* @return SwooleServer | ||
*/ | ||
public function getSwooleServer(): SwooleServer | ||
{ | ||
return $this->server; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Swoft\Server\Context; | ||
|
||
|
||
use ReflectionException; | ||
use Swoft\Bean\Annotation\Mapping\Bean; | ||
use Swoft\Bean\Concern\PrototypeTrait; | ||
use Swoft\Bean\Exception\ContainerException; | ||
use Swoft\Context\AbstractContext; | ||
use Swoole\Server as SwooleServer; | ||
|
||
/** | ||
* Class WorkerErrorContext | ||
* | ||
* @since 2.0 | ||
* | ||
* @Bean(scope=Bean::PROTOTYPE) | ||
*/ | ||
class WorkerErrorContext extends AbstractContext | ||
{ | ||
use PrototypeTrait; | ||
|
||
/** | ||
* @var SwooleServer | ||
*/ | ||
private $server; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $workerId; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $workerPid; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $exitCode; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $sigal; | ||
|
||
/** | ||
* @param SwooleServer $server | ||
* @param int $workerId | ||
* | ||
* @param int $workerPid | ||
* @param int $exitCode | ||
* @param int $signal | ||
* | ||
* @return WorkerErrorContext | ||
* @throws ContainerException | ||
* @throws ReflectionException | ||
*/ | ||
public static function new(SwooleServer $server, int $workerId, int $workerPid, int $exitCode, int $signal): self | ||
{ | ||
$self = self::__instance(); | ||
|
||
$self->server = $server; | ||
$self->workerId = $workerId; | ||
$self->workerPid = $workerPid; | ||
$self->exitCode = $exitCode; | ||
$self->sigal = $signal; | ||
|
||
return $self; | ||
} | ||
|
||
/** | ||
* @return SwooleServer | ||
*/ | ||
public function getSwooleServer(): SwooleServer | ||
{ | ||
return $this->server; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getWorkerId(): int | ||
{ | ||
return $this->workerId; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getWorkerPid(): int | ||
{ | ||
return $this->workerPid; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getExitCode(): int | ||
{ | ||
return $this->exitCode; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getSigal(): int | ||
{ | ||
return $this->sigal; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Swoft\Server\Context; | ||
|
||
|
||
use ReflectionException; | ||
use Swoft\Bean\Concern\PrototypeTrait; | ||
use Swoft\Bean\Exception\ContainerException; | ||
use Swoft\Context\AbstractContext; | ||
use Swoole\Server as SwooleServer; | ||
use Swoft\Bean\Annotation\Mapping\Bean; | ||
|
||
/** | ||
* Class WorkerStartContext | ||
* | ||
* @since 2.0 | ||
* | ||
* @Bean(scope=Bean::PROTOTYPE) | ||
*/ | ||
class WorkerStartContext extends AbstractContext | ||
{ | ||
use PrototypeTrait; | ||
|
||
/** | ||
* @var SwooleServer | ||
*/ | ||
private $server; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $workerId; | ||
|
||
/** | ||
* @param SwooleServer $server | ||
* @param int $workerId | ||
* | ||
* @return WorkerStartContext | ||
* @throws ContainerException | ||
* @throws ReflectionException | ||
*/ | ||
public static function new(SwooleServer $server, int $workerId): self | ||
{ | ||
$self = self::__instance(); | ||
|
||
$self->server = $server; | ||
$self->workerId = $workerId; | ||
|
||
return $self; | ||
} | ||
|
||
/** | ||
* @return SwooleServer | ||
*/ | ||
public function getSwooleServer(): SwooleServer | ||
{ | ||
return $this->server; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getWorkerId(): int | ||
{ | ||
return $this->workerId; | ||
} | ||
} |
Oops, something went wrong.