Refactoring, logging improvements

This commit is contained in:
2024-03-12 02:21:42 +01:00
parent 69fd46b73a
commit e10fd6c471
10 changed files with 38 additions and 16 deletions

View File

@ -1,12 +0,0 @@
<?php
namespace NoccyLabs\Mercureact\Http\Exception;
use Exception;
class RequestException extends Exception
{
const ERR_BAD_REQUEST = 51001;
const ERR_BAD_REQUEST_DATA = 51002;
const ERR_INVALID_REQUEST_DATA = 51003;
}

View File

@ -1,11 +0,0 @@
<?php
namespace NoccyLabs\Mercureact\Http\Exception;
use Exception;
class SecurityException extends Exception
{
const ERR_ACCESS_DENIED = 50001;
const ERR_NO_PERMISSION = 50002;
}

View File

@ -6,8 +6,8 @@ use NoccyLabs\Mercureact\Broker\Message;
use NoccyLabs\Mercureact\Broker\SseSubscriber;
use NoccyLabs\Mercureact\Broker\TopicManager;
use NoccyLabs\Mercureact\Configuration;
use NoccyLabs\Mercureact\Http\Exception\RequestException;
use NoccyLabs\Mercureact\Http\Exception\SecurityException;
use NoccyLabs\Mercureact\Exception\RequestException;
use NoccyLabs\Mercureact\Exception\SecurityException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use React\EventLoop\Loop;

View File

@ -3,7 +3,7 @@
namespace NoccyLabs\Mercureact\Http\Middleware;
use NoccyLabs\Mercureact\Configuration;
use NoccyLabs\Mercureact\Http\Exception\SecurityException;
use NoccyLabs\Mercureact\Exception\SecurityException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;

View File

@ -3,7 +3,7 @@
namespace NoccyLabs\Mercureact\Http\Middleware;
use NoccyLabs\Mercureact\Configuration;
use NoccyLabs\Mercureact\Http\Exception\SecurityException;
use NoccyLabs\Mercureact\Exception\SecurityException;
use NoccyLabs\SimpleJWT\JWTToken;
use NoccyLabs\SimpleJWT\Key\JWTPlaintextKey;
use NoccyLabs\SimpleJWT\Validator\JWTValidator;

View File

@ -54,8 +54,13 @@ class Server
$this->config = $config;
$this->logger = $logger ?? new NullLogger();
if ($logger instanceof Logger) {
$topicLogger = $logger->withName("broker");
} else {
$topicLogger = $this->logger;
}
$this->topicManager = new TopicManager();
$this->topicManager = new TopicManager($topicLogger);
$this->loop->addPeriodicTimer(30, function () {
$this->topicManager->garbageCollect();
});