1
0
Fork 0
mirror of synced 2024-07-04 06:00:53 +12:00

Merge pull request #4607 from appwrite/feat-fixes-for-pools

Feat fixes for pools
This commit is contained in:
Christy Jacob 2022-11-07 15:58:58 +05:30 committed by GitHub
commit 9cf9b9b41f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 58 deletions

View file

@ -1003,7 +1003,7 @@ $collections = [
'$id' => ID::custom('secret'), '$id' => ID::custom('secret'),
'type' => Database::VAR_STRING, 'type' => Database::VAR_STRING,
'format' => '', 'format' => '',
'size' => 512, // var_dump of \bin2hex(\random_bytes(128)) => string(256) doubling for encryption 'size' => 512, // Output of \bin2hex(\random_bytes(128)) => string(256) doubling for encryption
'signed' => true, 'signed' => true,
'required' => true, 'required' => true,
'default' => null, 'default' => null,

View file

@ -1574,7 +1574,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
Query::equal('databaseInternalId', [$db->getInternalId()]) Query::equal('databaseInternalId', [$db->getInternalId()])
], 61); ], 61);
$limit = 64 - MariaDB::getCountOfDefaultIndexes(); $limit = $dbForProject->getLimitForIndexes();
if ($count >= $limit) { if ($count >= $limit) {
throw new Exception(Exception::INDEX_LIMIT_EXCEEDED, 'Index limit exceeded'); throw new Exception(Exception::INDEX_LIMIT_EXCEEDED, 'Index limit exceeded');

View file

@ -61,7 +61,6 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
$app = new App('UTC'); $app = new App('UTC');
go(function () use ($register, $app) { go(function () use ($register, $app) {
$pools = $register->get('pools'); /** @var Group $pools */ $pools = $register->get('pools'); /** @var Group $pools */
App::setResource('pools', fn() => $pools); App::setResource('pools', fn() => $pools);
@ -119,7 +118,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
/** /**
* Skip to prevent 0.16 migration issues. * Skip to prevent 0.16 migration issues.
*/ */
if (in_array($key, ['cache', 'variables']) && $dbForConsole->exists(App::getEnv('_APP_DB_SCHEMA', 'appwrite'), 'bucket_1')) { if (in_array($key, ['cache', 'variables']) && $dbForConsole->exists($dbForConsole->getDefaultDatabase(), 'bucket_1')) {
continue; continue;
} }
@ -155,7 +154,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
$dbForConsole->createCollection($key, $attributes, $indexes); $dbForConsole->createCollection($key, $attributes, $indexes);
} }
if ($dbForConsole->getDocument('buckets', 'default')->isEmpty() && !$dbForConsole->exists(App::getEnv('_APP_DB_SCHEMA', 'appwrite'), 'bucket_1')) { if ($dbForConsole->getDocument('buckets', 'default')->isEmpty() && !$dbForConsole->exists($dbForConsole->getDefaultDatabase(), 'bucket_1')) {
Console::success('[Setup] - Creating default bucket...'); Console::success('[Setup] - Creating default bucket...');
$dbForConsole->createDocument('buckets', new Document([ $dbForConsole->createDocument('buckets', new Document([
'$id' => ID::custom('default'), '$id' => ID::custom('default'),

View file

@ -65,7 +65,6 @@ use Utopia\Storage\Device\Wasabi;
use Utopia\Cache\Adapter\Redis as RedisCache; use Utopia\Cache\Adapter\Redis as RedisCache;
use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Adapter\Sharding;
use Utopia\Cache\Cache; use Utopia\Cache\Cache;
use Utopia\CLI\Console;
use Utopia\Database\Adapter\MariaDB; use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Adapter\MySQL; use Utopia\Database\Adapter\MySQL;
use Utopia\Pools\Group; use Utopia\Pools\Group;
@ -498,7 +497,6 @@ $register->set('logger', function () {
return new Logger($adapter); return new Logger($adapter);
}); });
$register->set('pools', function () { $register->set('pools', function () {
$group = new Group(); $group = new Group();
$fallbackForDB = AppwriteURL::unparse([ $fallbackForDB = AppwriteURL::unparse([
@ -634,7 +632,6 @@ $register->set('pools', function () {
default => null default => null
}; };
var_dump($dsn->getDatabase());
$adapter->setDefaultDatabase($dsn->getDatabase()); $adapter->setDefaultDatabase($dsn->getDatabase());
break; break;
@ -665,12 +662,6 @@ $register->set('pools', function () {
Config::setParam('pools-' . $key, $config); Config::setParam('pools-' . $key, $config);
} }
try {
$group->fill();
} catch (\Throwable $th) {
Console::error('Connection failure: ' . $th->getMessage());
}
return $group; return $group;
}); });
$register->set('influxdb', function () { $register->set('influxdb', function () {

View file

@ -35,7 +35,7 @@ foreach (
realpath(__DIR__ . '/../vendor/symfony'), realpath(__DIR__ . '/../vendor/symfony'),
realpath(__DIR__ . '/../vendor/mongodb'), realpath(__DIR__ . '/../vendor/mongodb'),
realpath(__DIR__ . '/../vendor/utopia-php/websocket'), // TODO: remove workerman autoload realpath(__DIR__ . '/../vendor/utopia-php/websocket'), // TODO: remove workerman autoload
realpath(__DIR__ . '/../vendor/utopia-php/cache'), // TODO: remove memcache autoload realpath(__DIR__ . '/../vendor/utopia-php/cache'), // TODO: remove memcached autoload
] as $key => $value ] as $key => $value
) { ) {
if ($value !== false) { if ($value !== false) {

View file

@ -32,7 +32,6 @@ require_once __DIR__ . '/init.php';
Runtime::enableCoroutine(SWOOLE_HOOK_ALL); Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
function getConsoleDB(): Database function getConsoleDB(): Database
{ {
global $register; global $register;

View file

@ -206,7 +206,7 @@ $cli
unset($models[$key]); unset($models[$key]);
} }
} }
// var_dump($models);
$arguments = [new App('UTC'), $services, $routes, $models, $keys[$platform], $authCounts[$platform] ?? 0]; $arguments = [new App('UTC'), $services, $routes, $models, $keys[$platform], $authCounts[$platform] ?? 0];
foreach (['swagger2', 'open-api3'] as $format) { foreach (['swagger2', 'open-api3'] as $format) {
$formatInstance = match ($format) { $formatInstance = match ($format) {

View file

@ -43,7 +43,7 @@
"ext-sockets": "*", "ext-sockets": "*",
"appwrite/php-clamav": "1.1.*", "appwrite/php-clamav": "1.1.*",
"appwrite/php-runtimes": "0.11.*", "appwrite/php-runtimes": "0.11.*",
"utopia-php/framework": "0.21.*", "utopia-php/framework": "0.23.*",
"utopia-php/logger": "0.3.*", "utopia-php/logger": "0.3.*",
"utopia-php/abuse": "0.16.*", "utopia-php/abuse": "0.16.*",
"utopia-php/analytics": "0.2.*", "utopia-php/analytics": "0.2.*",
@ -56,12 +56,12 @@
"utopia-php/registry": "0.5.*", "utopia-php/registry": "0.5.*",
"utopia-php/preloader": "0.2.*", "utopia-php/preloader": "0.2.*",
"utopia-php/domains": "1.1.*", "utopia-php/domains": "1.1.*",
"utopia-php/swoole": "0.3.*", "utopia-php/swoole": "0.5.*",
"utopia-php/storage": "0.11.*", "utopia-php/storage": "0.11.*",
"utopia-php/websocket": "0.1.0", "utopia-php/websocket": "0.1.0",
"utopia-php/image": "0.5.*", "utopia-php/image": "0.5.*",
"utopia-php/orchestration": "0.6.*", "utopia-php/orchestration": "0.6.*",
"utopia-php/pools": "0.1.*", "utopia-php/pools": "dev-feat-optimize-filling as 0.3.0",
"resque/php-resque": "1.3.6", "resque/php-resque": "1.3.6",
"matomo/device-detector": "6.0.0", "matomo/device-detector": "6.0.0",
"dragonmantank/cron-expression": "3.3.1", "dragonmantank/cron-expression": "3.3.1",

60
composer.lock generated
View file

@ -1879,24 +1879,24 @@
}, },
{ {
"name": "utopia-php/framework", "name": "utopia-php/framework",
"version": "0.21.1", "version": "0.23.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/framework.git", "url": "https://github.com/utopia-php/framework.git",
"reference": "c81789b87a917da2daf336738170ebe01f50ea18" "reference": "97f64aa1732af92b967c3576f16967dc762ad47b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/c81789b87a917da2daf336738170ebe01f50ea18", "url": "https://api.github.com/repos/utopia-php/framework/zipball/97f64aa1732af92b967c3576f16967dc762ad47b",
"reference": "c81789b87a917da2daf336738170ebe01f50ea18", "reference": "97f64aa1732af92b967c3576f16967dc762ad47b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.0" "php": ">=8.0.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.5.10", "phpunit/phpunit": "^9.5.25",
"vimeo/psalm": "4.13.1" "vimeo/psalm": "^4.27.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -1908,12 +1908,6 @@
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [
{
"name": "Eldad Fux",
"email": "eldad@appwrite.io"
}
],
"description": "A simple, light and advanced PHP framework", "description": "A simple, light and advanced PHP framework",
"keywords": [ "keywords": [
"framework", "framework",
@ -1922,9 +1916,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/framework/issues", "issues": "https://github.com/utopia-php/framework/issues",
"source": "https://github.com/utopia-php/framework/tree/0.21.1" "source": "https://github.com/utopia-php/framework/tree/0.23.4"
}, },
"time": "2022-09-07T09:56:28+00:00" "time": "2022-10-31T11:57:14+00:00"
}, },
{ {
"name": "utopia-php/image", "name": "utopia-php/image",
@ -2152,23 +2146,24 @@
}, },
{ {
"name": "utopia-php/pools", "name": "utopia-php/pools",
"version": "0.1.0", "version": "dev-feat-optimize-filling",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/pools.git", "url": "https://github.com/utopia-php/pools.git",
"reference": "5a467a569a80aefc846a97dc195b4adc2fd71805" "reference": "be603898142f55df9db5058f81a610ead7769d7d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/pools/zipball/5a467a569a80aefc846a97dc195b4adc2fd71805", "url": "https://api.github.com/repos/utopia-php/pools/zipball/be603898142f55df9db5058f81a610ead7769d7d",
"reference": "5a467a569a80aefc846a97dc195b4adc2fd71805", "reference": "be603898142f55df9db5058f81a610ead7769d7d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-mongodb": "*", "ext-mongodb": "*",
"ext-pdo": "*", "ext-pdo": "*",
"ext-redis": "*", "ext-redis": "*",
"php": ">=8.0" "php": ">=8.0",
"utopia-php/cli": "^0.13.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.4", "phpunit/phpunit": "^9.4",
@ -2199,9 +2194,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/pools/issues", "issues": "https://github.com/utopia-php/pools/issues",
"source": "https://github.com/utopia-php/pools/tree/0.1.0" "source": "https://github.com/utopia-php/pools/tree/feat-optimize-filling"
}, },
"time": "2022-10-11T19:31:07+00:00" "time": "2022-11-03T18:50:28+00:00"
}, },
{ {
"name": "utopia-php/preloader", "name": "utopia-php/preloader",
@ -2365,16 +2360,16 @@
}, },
{ {
"name": "utopia-php/swoole", "name": "utopia-php/swoole",
"version": "0.3.3", "version": "0.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/swoole.git", "url": "https://github.com/utopia-php/swoole.git",
"reference": "8312df69233b5dcd3992de88f131f238002749de" "reference": "c2a3a4f944a2f22945af3cbcb95b13f0769628b1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/swoole/zipball/8312df69233b5dcd3992de88f131f238002749de", "url": "https://api.github.com/repos/utopia-php/swoole/zipball/c2a3a4f944a2f22945af3cbcb95b13f0769628b1",
"reference": "8312df69233b5dcd3992de88f131f238002749de", "reference": "c2a3a4f944a2f22945af3cbcb95b13f0769628b1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2383,6 +2378,7 @@
"utopia-php/framework": "0.*.*" "utopia-php/framework": "0.*.*"
}, },
"require-dev": { "require-dev": {
"laravel/pint": "1.2.*",
"phpunit/phpunit": "^9.3", "phpunit/phpunit": "^9.3",
"swoole/ide-helper": "4.8.3", "swoole/ide-helper": "4.8.3",
"vimeo/psalm": "4.15.0" "vimeo/psalm": "4.15.0"
@ -2397,12 +2393,6 @@
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [
{
"name": "Eldad Fux",
"email": "team@appwrite.io"
}
],
"description": "An extension for Utopia Framework to work with PHP Swoole as a PHP FPM alternative", "description": "An extension for Utopia Framework to work with PHP Swoole as a PHP FPM alternative",
"keywords": [ "keywords": [
"framework", "framework",
@ -2415,9 +2405,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/swoole/issues", "issues": "https://github.com/utopia-php/swoole/issues",
"source": "https://github.com/utopia-php/swoole/tree/0.3.3" "source": "https://github.com/utopia-php/swoole/tree/0.5.0"
}, },
"time": "2022-01-20T09:58:43+00:00" "time": "2022-10-19T22:19:07+00:00"
}, },
{ {
"name": "utopia-php/system", "name": "utopia-php/system",
@ -5127,7 +5117,7 @@
], ],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"utopia-php/database": 20 "utopia-php/pools": 20
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
@ -5152,5 +5142,5 @@
"platform-overrides": { "platform-overrides": {
"php": "8.0" "php": "8.0"
}, },
"plugin-api-version": "2.2.0" "plugin-api-version": "2.3.0"
} }

View file

@ -84,7 +84,6 @@ services:
- ./public:/usr/src/code/public - ./public:/usr/src/code/public
- ./src:/usr/src/code/src - ./src:/usr/src/code/src
- ./dev:/usr/local/dev - ./dev:/usr/local/dev
- ./vendor/utopia-php/framework:/usr/src/code/vendor/utopia-php/framework
depends_on: depends_on:
- mariadb - mariadb
- redis - redis
@ -361,7 +360,6 @@ services:
volumes: volumes:
- ./app:/usr/src/code/app - ./app:/usr/src/code/app
- ./src:/usr/src/code/src - ./src:/usr/src/code/src
#- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
depends_on: depends_on:
- redis - redis
- mariadb - mariadb
@ -619,7 +617,6 @@ services:
volumes: volumes:
- ./app:/usr/src/code/app - ./app:/usr/src/code/app
- ./src:/usr/src/code/src - ./src:/usr/src/code/src
#- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
depends_on: depends_on:
- redis - redis
environment: environment: