Skip to content

Commit

Permalink
Filestructure changes. Mark some classes as Internal
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Sep 29, 2024
1 parent 0fdc4dc commit fd42aea
Show file tree
Hide file tree
Showing 81 changed files with 300 additions and 231 deletions.
3 changes: 3 additions & 0 deletions src/Internal/ArrayContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal;

/**
* @internal
*/
final class ArrayContainer implements Container
{
private array $container = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Console/App.php → src/Internal/Console/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Console;
namespace Luzrain\PHPStreamServer\Internal\Console;

use Luzrain\PHPStreamServer\Internal\Functions;
use Luzrain\PHPStreamServer\Server;

/**
* @internal
*/
final class App
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Console;
namespace Luzrain\PHPStreamServer\Internal\Console;

/**
* @internal
*/
final class Colorizer
{
/**
Expand Down
7 changes: 5 additions & 2 deletions src/Console/Command.php → src/Internal/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Console;
namespace Luzrain\PHPStreamServer\Internal\Console;

use Luzrain\PHPStreamServer\Internal\MasterProcess;
use Luzrain\PHPStreamServer\MasterProcess;

/**
* @internal
*/
abstract class Command
{
protected const COMMAND = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Console;
namespace Luzrain\PHPStreamServer\Internal\Console;

/**
* @internal
*/
final readonly class OptionDefinition
{
public function __construct(
Expand Down
5 changes: 4 additions & 1 deletion src/Console/Options.php → src/Internal/Console/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Console;
namespace Luzrain\PHPStreamServer\Internal\Console;

/**
* @internal
*/
final class Options
{
private array $parsedOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Console;
namespace Luzrain\PHPStreamServer\Internal\Console;

/**
* Handler for redirect standard output to custom stream
* @internal
*/
final class StdoutHandler
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Table.php → src/Internal/Console/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Console;
namespace Luzrain\PHPStreamServer\Internal\Console;

/**
* @internal
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal;

/**
* @internal
*/
interface Container
{
public function set(string $id, mixed $value): void;
Expand Down
31 changes: 0 additions & 31 deletions src/Internal/JsonSerializible.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Internal/Logger/Logger.php → src/Internal/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\Internal\Logger;
namespace Luzrain\PHPStreamServer\Internal;

use Psr\Log\LoggerInterface;
use Psr\Log\LoggerTrait;
Expand Down
12 changes: 0 additions & 12 deletions src/Internal/MessageBus/Message.php

This file was deleted.

4 changes: 4 additions & 0 deletions src/Internal/MessageBus/MessageBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
namespace Luzrain\PHPStreamServer\Internal\MessageBus;

use Amp\Future;
use Luzrain\PHPStreamServer\Message;

/**
* @internal
*/
interface MessageBus
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Internal/MessageBus/MessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

namespace Luzrain\PHPStreamServer\Internal\MessageBus;

use Luzrain\PHPStreamServer\Message;

/**
* @internal
*/
interface MessageHandler
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Internal/MessageBus/SocketFileMessageBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
use Amp\Socket\DnsSocketConnector;
use Amp\Socket\SocketConnector;
use Amp\Socket\StaticSocketConnector;
use Luzrain\PHPStreamServer\Message;
use function Amp\async;
use function Amp\delay;

/**
* @internal
*/
final class SocketFileMessageBus implements MessageBus
{
private SocketConnector $connector;
Expand Down
4 changes: 4 additions & 0 deletions src/Internal/MessageBus/SocketFileMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
use Amp\Future;
use Amp\Socket\ResourceServerSocket;
use Amp\Socket\ResourceServerSocketFactory;
use Luzrain\PHPStreamServer\Message;
use Revolt\EventLoop;
use function Amp\async;

/**
* @internal
*/
final class SocketFileMessageHandler implements MessageHandler, MessageBus
{
private ResourceServerSocket $socket;
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/ProcessTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

use Amp\Future;
use Luzrain\PHPStreamServer\Exception\UserChangeException;
use Luzrain\PHPStreamServer\Internal\MessageBus\Message;
use Luzrain\PHPStreamServer\Message;
use Luzrain\PHPStreamServer\ProcessInterface;
use Psr\Log\LoggerInterface;
use Revolt\EventLoop;

/**
* @internal
* @psalm-require-implements ProcessInterface
* @internal
*/
trait ProcessTrait
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\ReloadStrategy;
namespace Luzrain\PHPStreamServer\Internal\ReloadStrategy;

use Luzrain\PHPStreamServer\ReloadStrategy\ReloadStrategyInterface;

/**
* @internal
*/
interface ReloadStrategyAwareInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

declare(strict_types=1);

namespace Luzrain\PHPStreamServer\ReloadStrategy;
namespace Luzrain\PHPStreamServer\Internal\ReloadStrategy;

use Luzrain\PHPStreamServer\ReloadStrategy\ReloadStrategyInterface;
use Luzrain\PHPStreamServer\ReloadStrategy\TimerReloadStrategyInterface;
use Revolt\EventLoop;

/**
* @internal
*/
final class ReloadStrategyTrigger
{
/** @var list<ReloadStrategyInterface> */
Expand All @@ -28,6 +33,9 @@ public function addReloadStrategy(ReloadStrategyInterface ...$reloadStrategies):
}
}

/**
* @param mixed $event any value that checked by reload strategies. Could be exception, request etc.
*/
public function emitEvent(mixed $event): void
{
foreach ($this->reloadStrategies as $reloadStrategy) {
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/SIGCHLDHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Revolt\EventLoop;

/**
* @internal
*/
final class SIGCHLDHandler
{
private static bool $isRegistered = false;
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/Scheduler/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Revolt\EventLoop\Suspension;
use function Amp\weakClosure;

/**
* @internal
*/
final class Scheduler
{
private WorkerPool $pool;
Expand Down
7 changes: 6 additions & 1 deletion src/Internal/Scheduler/Trigger/CronExpressionTrigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* @psalm-suppress UndefinedClass
* @internal
*/
final class CronExpressionTrigger implements TriggerInterface
{
Expand Down Expand Up @@ -35,6 +36,10 @@ public function getNextRunDate(\DateTimeImmutable $now): \DateTimeImmutable|null
{
$next = $this->expression->getNextRunDate($now);

return $next instanceof \DateTime ? \DateTimeImmutable::createFromMutable($next) : $next;
if ($next instanceof \DateTime) {
$next = \DateTimeImmutable::createFromMutable($next);
}

return $next;
}
}
3 changes: 3 additions & 0 deletions src/Internal/Scheduler/Trigger/DateTimeTrigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal\Scheduler\Trigger;

/**
* @internal
*/
final class DateTimeTrigger implements TriggerInterface
{
private \DateTimeImmutable $date;
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/Scheduler/Trigger/JitterTrigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal\Scheduler\Trigger;

/**
* @internal
*/
final class JitterTrigger implements TriggerInterface
{
public function __construct(private readonly TriggerInterface $trigger, private readonly int $jitter)
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/Scheduler/Trigger/PeriodicalTrigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal\Scheduler\Trigger;

/**
* @internal
*/
final class PeriodicalTrigger implements TriggerInterface
{
private \DateInterval $interval;
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/Scheduler/Trigger/TriggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal\Scheduler\Trigger;

/**
* @internal
*/
final class TriggerFactory
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/Scheduler/Trigger/TriggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal\Scheduler\Trigger;

/**
* @internal
*/
interface TriggerInterface extends \Stringable
{
public function getNextRunDate(\DateTimeImmutable $now): \DateTimeImmutable|null;
Expand Down
3 changes: 3 additions & 0 deletions src/Internal/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Luzrain\PHPStreamServer\Internal;

/**
* @internal
*/
enum Status
{
case STARTING;
Expand Down
10 changes: 5 additions & 5 deletions src/Internal/Supervisor/Supervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use Amp\DeferredFuture;
use Amp\Future;
use Luzrain\PHPStreamServer\Exception\PHPStreamServerException;
use Luzrain\PHPStreamServer\Internal\MasterProcess;
use Luzrain\PHPStreamServer\Internal\Message\ProcessBlockedEvent;
use Luzrain\PHPStreamServer\Internal\Message\ProcessDetachedEvent;
use Luzrain\PHPStreamServer\Internal\Message\ProcessHeartbeatEvent;
use Luzrain\PHPStreamServer\Internal\Message\ProcessExitedEvent;
use Luzrain\PHPStreamServer\Internal\SIGCHLDHandler;
use Luzrain\PHPStreamServer\Internal\Status;
use Luzrain\PHPStreamServer\MasterProcess;
use Luzrain\PHPStreamServer\Message\ProcessBlockedEvent;
use Luzrain\PHPStreamServer\Message\ProcessDetachedEvent;
use Luzrain\PHPStreamServer\Message\ProcessExitedEvent;
use Luzrain\PHPStreamServer\Message\ProcessHeartbeatEvent;
use Luzrain\PHPStreamServer\WorkerProcessInterface;
use Psr\Log\LoggerInterface;
use Revolt\EventLoop;
Expand Down
Loading

0 comments on commit fd42aea

Please sign in to comment.