fix(realtime): class and phpdocs
This commit is contained in:
parent
82b3a56d26
commit
7adcdf916f
1 changed files with 46 additions and 0 deletions
|
@ -2,10 +2,14 @@
|
||||||
|
|
||||||
namespace Appwrite\Realtime;
|
namespace Appwrite\Realtime;
|
||||||
|
|
||||||
|
use Appwrite\Database\Database;
|
||||||
|
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
|
||||||
|
use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
||||||
use Appwrite\Event\Event;
|
use Appwrite\Event\Event;
|
||||||
use Appwrite\Network\Validator\Origin;
|
use Appwrite\Network\Validator\Origin;
|
||||||
use Appwrite\Utopia\Response;
|
use Appwrite\Utopia\Response;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Swoole\Coroutine\Redis;
|
||||||
use Swoole\Http\Request;
|
use Swoole\Http\Request;
|
||||||
use Swoole\Http\Response as SwooleResponse;
|
use Swoole\Http\Response as SwooleResponse;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
|
@ -17,6 +21,7 @@ use Utopia\Abuse\Abuse;
|
||||||
use Utopia\Abuse\Adapters\TimeLimit;
|
use Utopia\Abuse\Adapters\TimeLimit;
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\CLI\Console;
|
use Utopia\CLI\Console;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Exception as UtopiaException;
|
use Utopia\Exception as UtopiaException;
|
||||||
use Utopia\Registry\Registry;
|
use Utopia\Registry\Registry;
|
||||||
use Utopia\Swoole\Request as SwooleRequest;
|
use Utopia\Swoole\Request as SwooleRequest;
|
||||||
|
@ -24,10 +29,46 @@ use Utopia\Swoole\Request as SwooleRequest;
|
||||||
|
|
||||||
class Server
|
class Server
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Container scoped Registry.
|
||||||
|
* @var Registry
|
||||||
|
*/
|
||||||
public Registry $register;
|
public Registry $register;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container scoped Swoole Server.
|
||||||
|
* @var SwooleServer
|
||||||
|
*/
|
||||||
public SwooleServer $server;
|
public SwooleServer $server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container scoped Table.
|
||||||
|
* @var Table
|
||||||
|
*/
|
||||||
public Table $stats;
|
public Table $stats;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container scoped Database connection.
|
||||||
|
* @var Database
|
||||||
|
*/
|
||||||
|
public Database $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container scoped Redis connection.
|
||||||
|
* @var Redis
|
||||||
|
*/
|
||||||
|
public Redis $cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Worker scoped subscription.
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public array $subscriptions;
|
public array $subscriptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Worker scoped connections.
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public array $connections;
|
public array $connections;
|
||||||
|
|
||||||
public function __construct(Registry &$register, $host = '0.0.0.0', $port = 80, $config = [])
|
public function __construct(Registry &$register, $host = '0.0.0.0', $port = 80, $config = [])
|
||||||
|
@ -43,6 +84,11 @@ class Server
|
||||||
$this->stats->column('messages', Table::TYPE_INT);
|
$this->stats->column('messages', Table::TYPE_INT);
|
||||||
$this->stats->create();
|
$this->stats->create();
|
||||||
|
|
||||||
|
$this->db = new Database();
|
||||||
|
$this->db->setAdapter(new RedisAdapter(new MySQLAdapter($this->register), $this->register));
|
||||||
|
$this->db->setNamespace('app_console');
|
||||||
|
$this->db->setMocks(Config::getParam('collections', []));
|
||||||
|
|
||||||
$this->server = new SwooleServer($host, $port, SWOOLE_PROCESS);
|
$this->server = new SwooleServer($host, $port, SWOOLE_PROCESS);
|
||||||
$this->server->set($config);
|
$this->server->set($config);
|
||||||
$this->server->on('start', [$this, 'onStart']);
|
$this->server->on('start', [$this, 'onStart']);
|
||||||
|
|
Loading…
Reference in a new issue