1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00
appwrite/app/workers/database.php

74 lines
1.7 KiB
PHP
Raw Normal View History

2021-06-18 06:22:06 +12:00
<?php
use Appwrite\Database\Validator\Authorization;
use Appwrite\Resque\Worker;
use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\TimeLimit;
use Utopia\Audit\Audit;
use Utopia\Cache\Cache;
2021-06-18 07:30:03 +12:00
use Utopia\Cache\Adapter\Redis as RedisCache;
use Utopia\CLI\Console;
use Utopia\Config\Config;
use Utopia\Database\Database;
use Utopia\Database\Document;
2021-06-18 06:22:06 +12:00
use Utopia\Database\Adapter\MariaDB;
2021-06-18 07:30:03 +12:00
use Utopia\Storage\Device\Local;
2021-06-18 06:22:06 +12:00
require_once __DIR__.'/../init.php';
Console::title('Database V1 Worker');
Console::success(APP_NAME.' database worker v1 has started'."\n");
2021-06-18 09:58:35 +12:00
class DatabaseV1 extends Worker
2021-06-18 06:22:06 +12:00
{
public $args = [];
public function init(): void
{
}
public function run(): void
{
2021-06-18 09:58:35 +12:00
$collections = Config::getParam('collections2');
var_dump($collections);
2021-06-18 06:22:06 +12:00
}
public function shutdown(): void
{
}
/**
* @param string $projectId
*
* @return Database
*/
protected function getInternalDB($projectId): Database
{
global $register;
$cache = new Cache(new RedisCache($register->get('cache')));
$dbForInternal = new Database(new MariaDB($register->get('db')), $cache);
$dbForInternal->setNamespace('project_'.$projectId.'_internal'); // Main DB
return $dbForInternal;
}
/**
* @param string $projectId
*
* @return Database
*/
protected function getExternalDB($projectId): Database
{
global $register;
$cache = new Cache(new RedisCache($register->get('cache')));
$dbForExternal = new Database(new MariaDB($register->get('db')), $cache);
$dbForExternal->setNamespace('project_'.$projectId.'_external'); // Main DB
return $dbForExternal;
}
2021-06-18 06:22:06 +12:00
}