Browse Source

Update ubiquity (#5188)

* [ci skip] Move Ubiquity from pgsql to mysql

* [ci skip] Move Swoole from mysql to pgsql

* [ci skip] Remove unused template engine + 3x workers

* Remove unused mysqli
jcheron 5 years ago
parent
commit
8c46706f51

+ 1 - 1
frameworks/PHP/ubiquity/.ubiquity/_workerman.php

@@ -14,6 +14,6 @@ $config ["siteUrl"] = 'http://'.$address;
 require ROOT . './../vendor/autoload.php';
 $workerServer=new \Ubiquity\servers\workerman\WorkermanServer();
 $workerServer->init($config, __DIR__);
-$workerServer->setDefaultCount(2);
+$workerServer->setDefaultCount(3);
 require ROOT.'config/workerServices.php';
 $workerServer->run($sConfig['host'],$sConfig['port'],$sConfig['socket']??[]);

+ 3 - 5
frameworks/PHP/ubiquity/app/config/swooleServices.php

@@ -1,11 +1,9 @@
 <?php
 \Ubiquity\cache\CacheManager::startProd($config);
-\Ubiquity\controllers\Startup::$templateEngine = new \Ubiquity\views\engine\micro\MicroTemplateEngine();
 \Ubiquity\orm\DAO::setModelsDatabases([
-	"models\\Fortune" => "default",
-	"models\\World" => "default"
+	"models\\Fortune" => 'pgsql',
+	"models\\World" => 'pgsql'
 ]);
 $swooleServer->on('workerStart', function ($srv) use (&$config) {
-	\Ubiquity\orm\DAO::startDatabase($config, 'default');
+	\Ubiquity\orm\DAO::startDatabase($config, 'pgsql');
 });
-	

+ 0 - 1
frameworks/PHP/ubiquity/app/config/workerServices.php

@@ -1,6 +1,5 @@
 <?php
 \Ubiquity\cache\CacheManager::startProd($config);
-\Ubiquity\controllers\Startup::$templateEngine = new \Ubiquity\views\engine\micro\MicroTemplateEngine();
 \Ubiquity\orm\DAO::setModelsDatabases(["models\\Fortune"=>'pgsql',"models\\World"=>'pgsql']);
 $workerServer->onWorkerStart=function() use($config){
 	\Ubiquity\orm\DAO::startDatabase($config,'pgsql');

+ 2 - 3
frameworks/PHP/ubiquity/app/controllers/Db.php

@@ -12,7 +12,7 @@ class Db extends \Ubiquity\controllers\Controller {
 	public function initialize() {
 		\header('Content-Type: application/json');
 		\Ubiquity\cache\CacheManager::startProd(\Ubiquity\controllers\Startup::$config);
-		DAO::setModelDatabase(World::class, 'pgsql');
+		DAO::setModelDatabase(World::class);
 	}
 	
 	public function index() {
@@ -34,10 +34,9 @@ class Db extends \Ubiquity\controllers\Controller {
 		for ($i = 0; $i < $queries; ++ $i) {
 			$world = DAO::getById(World::class, \mt_rand(1, 10000), false);
 			$world->randomNumber = \mt_rand(1, 10000);
-			DAO::toUpdate($world);
+			DAO::update($world);
 			$worlds[] = $world->_rest;
 		}
-		DAO::flushUpdates();
 		echo \json_encode($worlds);
 	}
 }

+ 1 - 2
frameworks/PHP/ubiquity/app/controllers/Fortunes.php

@@ -9,8 +9,7 @@ class Fortunes extends \Ubiquity\controllers\Controller {
 
 	public function initialize() {
 		\Ubiquity\cache\CacheManager::startProd(Startup::$config);
-		Startup::$templateEngine = new \Ubiquity\views\engine\micro\MicroTemplateEngine();
-		DAO::setModelDatabase(Fortune::class, 'pgsql');
+		DAO::setModelDatabase(Fortune::class);
 	}
 
 	public function index() {

+ 2 - 1
frameworks/PHP/ubiquity/app/controllers/SwooleDb.php

@@ -36,9 +36,10 @@ class SwooleDb extends \Ubiquity\controllers\Controller
 		for ($i = 0; $i < $queries; ++ $i) {
 			$world = DAO::getById(World::class, \mt_rand(1, 10000), false);
 			$world->randomNumber = \mt_rand(1, 10000);
-			DAO::update($world);
+			DAO::toUpdate($world);
 			$worlds[] = $world->_rest;
 		}
+		DAO::flushUpdates();
 		echo \json_encode($worlds);
 	}
 }

+ 3 - 3
frameworks/PHP/ubiquity/benchmark_config.json

@@ -12,7 +12,7 @@
         "port": 8080,
         "approach": "Realistic",
         "classification": "Fullstack",
-        "database": "Postgres",
+        "database": "MySQL",
         "framework": "ubiquity",
         "language": "PHP",
         "flavor": "PHP7",
@@ -58,7 +58,7 @@
         "port": 8080,
         "approach": "Realistic",
         "classification": "Fullstack",
-        "database": "MySQL",
+        "database": "Postgres",
         "framework": "ubiquity",
         "language": "PHP",
         "flavor": "PHP7",
@@ -67,7 +67,7 @@
         "webserver": "none",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ubiquity-swoole-mysql",
+        "display_name": "ubiquity-swoole-pgsql",
         "notes": "",
         "versus": "swoole"
       }

+ 5 - 1
frameworks/PHP/ubiquity/ubiquity-swoole.dockerfile

@@ -1,9 +1,13 @@
 FROM php:7.3
 
+RUN apt-get update
+
 RUN pecl install swoole-4.4.7 > /dev/null && \
     docker-php-ext-enable swoole
 
-RUN docker-php-ext-install pdo_mysql pcntl > /dev/null
+RUN apt-get install -y libpq-dev \
+    && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
+    && docker-php-ext-install pdo pdo_pgsql pgsql
 
 COPY deploy/conf/php-async.ini /usr/local/etc/php/
 

+ 1 - 1
frameworks/PHP/ubiquity/ubiquity-workerman.dockerfile

@@ -27,7 +27,7 @@ RUN deploy/run/install-composer.sh
 RUN apt-get update -yqq > /dev/null && \
     apt-get install -yqq git unzip > /dev/null
 
-RUN php composer.phar require phpmv/ubiquity-devtools:dev-techempower-benchmarks phpmv/ubiquity-workerman:dev-techempower-benchmarks phpmv/ubiquity-mysqli:dev-techempower-benchmarks --quiet
+RUN php composer.phar require phpmv/ubiquity-devtools:dev-techempower-benchmarks phpmv/ubiquity-workerman:dev-techempower-benchmarks --quiet
 
 RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 

+ 1 - 1
frameworks/PHP/ubiquity/ubiquity.dockerfile

@@ -5,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive
 RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
 RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq nginx git unzip php7.3 php7.3-common php7.3-cli php7.3-fpm php7.3-pgsql  > /dev/null
+    apt-get install -yqq nginx git unzip php7.3 php7.3-common php7.3-cli php7.3-fpm php7.3-mysql  > /dev/null
 
 RUN apt-get install -yqq composer > /dev/null