Browse Source

[php/sw-sf-less] Remove sw-sf-less (#9781)

sw-sf-less has been tagged as broken for 2 years.
The repo hasn't been updated in 3 years:
https://github.com/luoxiaojun1992/sw-fw-less

There also is a 5 year old open issue about abandoned dependencies:
https://github.com/luoxiaojun1992/sw-fw-less/issues/6
Petrik de Heus 4 months ago
parent
commit
ff97e784ea

+ 0 - 8
frameworks/PHP/sw-fw-less/.env

@@ -1,8 +0,0 @@
-## MySQL
-MYSQL_DSN="mysql:dbname=hello_world;host=tfb-database;port=3306"
-MYSQL_USERNAME=benchmarkdbuser
-MYSQL_PASSWD=benchmarkdbpass
-MYSQL_POOL_SIZE=10
-MYSQL_SWITCH=1
-MYSQL_POOL_CHANGE_EVENT=0
-MYSQL_REPORT_POOL_CHANGE=0

+ 0 - 6
frameworks/PHP/sw-fw-less/.gitignore

@@ -1,6 +0,0 @@
-/vendor/
-/.idea
-/.idea/
-/runtime
-/runtime/
-/composer.lock

+ 0 - 51
frameworks/PHP/sw-fw-less/README.md

@@ -1,51 +0,0 @@
-# [Sw-Fw-Less](https://github.com/luoxiaojun1992/sw-fw-less) Benchmarking Test
-
-This is the [Sw-Fw-Less](https://github.com/luoxiaojun1992/sw-fw-less) portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
-
-### JSON Encoding Test
-
-* [JSON test source](app/services/TestService.php)
-
-### Plaintext Test
-
-* [Plaintext test source](app/services/TestService.php)
-
-### Data-Store/Database Mapping Test
-
-* [DB test controller](app/services/TestService.php)
-* [DB test model](app/models/World.php)
-
-### Fortunes Test
-* [Fortunes test controller](app/services/TestService.php)
-* [Fortunes test model](app/models/Fortune.php)
-
-
-## Infrastructure Software Versions
-The tests were run with:
-* [PHP 7.4](https://www.php.net/)
-* [Swoole v4.5.6](https://www.swoole.com/)
-
-## Test URLs
-### JSON Encoding Test
-
-http://localhost:9501/json
-
-### Plaintext Test
-
-http://localhost:9501/plaintext
-
-### Data-Store/Database Mapping Test
-
-http://localhost:9501/db
-
-### Variable Query Test
-
-http://localhost:9501/queries/2
-
-### Data Updates Test
-
-http://localhost:9501/updates/2
-
-### Fortunes Test
-
-http://localhost:9501/fortunes

+ 0 - 10
frameworks/PHP/sw-fw-less/app/models/Fortune.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace App\models;
-
-use SwFwLess\models\AbstractMysqlModel;
-
-class Fortune extends AbstractMysqlModel
-{
-    protected static $table = 'Fortune';
-}

+ 0 - 10
frameworks/PHP/sw-fw-less/app/models/World.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace App\models;
-
-use SwFwLess\models\AbstractMysqlModel;
-
-class World extends AbstractMysqlModel
-{
-    protected static $table = 'World';
-}

+ 0 - 121
frameworks/PHP/sw-fw-less/app/services/TestService.php

@@ -1,121 +0,0 @@
-<?php
-
-namespace App\services;
-
-use App\models\Fortune;
-use App\models\World;
-use SwFwLess\components\http\Response;
-use SwFwLess\services\BaseService;
-
-class TestService extends BaseService
-{
-    public function json()
-    {
-        return ['message' => 'Hello, World!'];
-    }
-
-    public function db()
-    {
-        $world = World::select()->cols(['*'])->where('`id` = :id')
-            ->bindValue(':id', random_int(1, 10000))
-            ->first();
-
-        return $world ? $world->toArray() : [];
-    }
-
-    public function queries($queries = 1)
-    {
-        $queries = $this->clamp($queries);
-
-        $rows = [];
-        while ($queries--) {
-            $row = World::select()->cols(['*'])->where('`id` = :id')
-                ->bindValue(':id', random_int(1, 10000))
-                ->first();
-            $rows[] = $row ? $row->toArray() : [];
-        }
-
-        return $rows;
-    }
-
-    public function fortunes()
-    {
-        $rows = Fortune::select()->cols(['*'])->get();
-
-        $insert = new Fortune();
-        $insert->id = 0;
-        $insert->message = 'Additional fortune added at request time.';
-
-        $rows[] = $insert;
-
-        usort($rows, function ($left, $right) {
-            return strcmp($left->message, $right->message);
-        });
-
-        return Response::output($this->renderFortunes($rows), 200, ['Content-Type' => 'text/html;charset=utf-8']);
-    }
-
-    private function renderFortunes($fortunes)
-    {
-        $html = <<<EOF
-<!DOCTYPE html>
-<html>
-<head><title>Fortunes</title></head>
-<body>
-<table>
-	<tr><th>id</th><th>message</th></tr>
-
-	%s
-</table>
-</body>
-</html>
-EOF;
-
-        $fortuneRows = '';
-        foreach ($fortunes as $fortune) {
-            $fortuneRows .= '	<tr><td>' . htmlspecialchars($fortune->id) .
-                '</td><td>' . htmlspecialchars($fortune->message) . '</td></tr>' . PHP_EOL;
-        }
-
-        return sprintf($html, $fortuneRows);
-    }
-
-    public function updates($queries = 1)
-    {
-        $queries = $this->clamp($queries);
-
-        $rows = [];
-
-        while ($queries--) {
-            $row = World::select()->cols(['*'])->where('`id` = :id')
-                ->bindValue(':id', random_int(1, 10000))
-                ->first();
-            if ($row) {
-                $row->randomNumber = random_int(1, 10000);
-                $row->save();
-
-                $rows[] = $row->toArray();
-            } else {
-                $rows[] = [];
-            }
-        }
-
-        return $rows;
-    }
-
-    public function plaintext()
-    {
-        return Response::output('Hello, World!', 200, ['Content-Type' => 'text/plain']);
-    }
-
-    private function clamp($value): int
-    {
-        if (! is_numeric($value) || $value < 1) {
-            return 1;
-        }
-        if ($value > 500) {
-            return 500;
-        }
-        return (int)$value;
-    }
-}

+ 0 - 31
frameworks/PHP/sw-fw-less/benchmark_config.json

@@ -1,31 +0,0 @@
-{
-    "framework": "sw-fw-less",
-    "tests": [
-        {
-            "default": {
-                "json_url": "/json",
-                "db_url": "/db",
-                "query_url": "/queries/",
-                "fortune_url": "/fortunes",
-                "update_url": "/updates/",
-                "plaintext_url": "/plaintext",
-                "port": 9501,
-                "approach": "Realistic",
-                "classification": "Micro",
-                "database": "MySQL",
-                "framework": "Sw-Fw-Less",
-                "language": "PHP",
-                "flavor": "None",
-                "orm": "Full",
-                "platform": "swoole",
-                "webserver": "None",
-                "os": "Linux",
-                "database_os": "Linux",
-                "display_name": "Sw-Fw-Less",
-                "notes": "",
-                "versus": "swoole",
-                "tags": ["broken"]
-            }
-        }
-    ]
-}

+ 0 - 44
frameworks/PHP/sw-fw-less/composer.json

@@ -1,44 +0,0 @@
-{
-    "name": "luoxiaojun/sw-fw-less-app",
-    "description": "Swoole Http Server App",
-    "type": "project",
-    "keywords": [
-        "swoole",
-        "framework",
-        "coroutine",
-        "php",
-        "app"
-    ],
-    "require": {
-        "php": ">=7.1",
-        "ext-json": "*",
-        "ext-pdo": "*",
-        "ext-swoole": ">=4.4.0",
-        "luoxiaojun/sw-fw-less": "dev-master"
-    },
-    "suggest": {
-        "ext-redis": "*"
-    },
-    "license": "apache-2.0",
-    "authors": [
-        {
-            "name": "luoxiaojun",
-            "email": "[email protected]"
-        }
-    ],
-    "autoload": {
-        "psr-4": {"App\\": "app/"}
-    },
-    "scripts": {
-        "post-root-package-install": [
-            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
-        ]
-    },
-    "config": {
-        "sort-packages": true,
-        "optimize-autoloader": true,
-        "preferred-install": "dist"
-    },
-    "minimum-stability": "dev",
-    "prefer-stable": true
-}

+ 0 - 19
frameworks/PHP/sw-fw-less/config.toml

@@ -1,19 +0,0 @@
-[framework]
-name = "sw-fw-less"
-
-[main]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-urls.db = "/db"
-urls.query = "/queries/"
-urls.update = "/updates/"
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Micro"
-database = "MySQL"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "swoole"
-webserver = "None"
-versus = "swoole"

+ 0 - 88
frameworks/PHP/sw-fw-less/config/app.php

@@ -1,88 +0,0 @@
-<?php
-
-return [
-    //Cors
-    'cors' => [
-        'origin' => env('CORS_ORIGIN', ''),
-        'switch' => envInt('CORS_SWITCH', 0),
-    ],
-
-    //Timezone
-    'timezone' => env('TIMEZONE', null),
-
-    //Monitor
-    'monitor' => [
-        'switch' => envInt('MONITOR_SWITCH', 0),
-    ],
-
-    //Throttle
-    'throttle' => [
-        'metric' => function(\SwFwLess\components\http\Request $request){
-            return $request->getRoute();
-        },
-        'period' => envInt('THROTTLE_PERIOD', 60),
-        'throttle' => envInt('THROTTLE_THROTTLE', 10000),
-    ],
-
-    //RedLock
-    'red_lock' => [
-        'connection' => env('RED_LOCK_CONNECTION', 'red_lock'),
-    ],
-
-    //RateLimit
-    'rate_limit' => [
-        'connection' => env('RATE_LIMIT_CONNECTION', 'rate_limit'),
-    ],
-
-    //Cache
-    'cache' => [
-        'connection' => env('CACHE_CONNECTION', 'cache'), //redis connection
-        'update_lock_ttl' => envInt('CACHE_UPDATE_LOCK_TTL', 10),
-    ],
-
-    //Hot Reload
-    'hot_reload' => [
-        'switch' => envInt('HOT_RELOAD_SWITCH', 0),
-        'watch_dirs' => [
-            __DIR__ . '/',
-            __DIR__ . '/../app/',
-            __DIR__ . '/../vendor/',
-            __DIR__ . '/../',
-        ],
-        'excluded_dirs' => [],
-        'watch_suffixes' => ['.php', '.env'],
-        'driver' => env('HOT_RELOAD_DRIVER', \Kwf\FileWatcher\Watcher::class), //HuangYi\Watcher\Watcher::class is another choice
-    ],
-
-    //Error handler
-    'error_handler' => [
-        'err_formatter' => function (\Throwable $e) {
-            return nl2br($e->getMessage() . PHP_EOL . $e->getTraceAsString());
-        },
-    ],
-
-    //Ip Restriction
-    'ip_restriction' => [
-        'ips' => env('IP_RESTRICTION_IPS'),
-        'api_prefix' => env('IP_RESTRICTION_API_PREFIX'),
-    ],
-
-    //Scheduler
-    'scheduler' => [
-//        [
-//            'schedule' => '* * * * *',
-//            'jobs' => function () {
-//                echo 'Every minute', PHP_EOL;
-//            },
-//        ],
-//        [
-//            'schedule' => '*/2 * * * *',
-//            'jobs' => function () {
-//                echo 'Every two minutes', PHP_EOL;
-//            },
-//        ],
-    ],
-
-    //You can turn off the switch to improve the performance
-    'route_di_switch' => envBool('ROUTE_DI_SWITCH', false),
-];

+ 0 - 6
frameworks/PHP/sw-fw-less/config/coroutine.php

@@ -1,6 +0,0 @@
-<?php
-
-return [
-    'enable_preemptive_scheduler' => envInt('COROUTINE_PREEMPTIVE_SCHEDULER', 0),
-    'hook_flags' => SWOOLE_HOOK_ALL,
-];

+ 0 - 40
frameworks/PHP/sw-fw-less/config/events.php

@@ -1,40 +0,0 @@
-<?php
-
-return [
-    \SwFwLess\components\redis\RedisPool::EVENT_REDIS_POOL_CHANGE => [
-        function (\Cake\Event\Event $event) {
-            $count = $event->getData('count');
-
-            if (\SwFwLess\components\Config::get('redis.report_pool_change')) {
-                \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:redis', $count);
-            }
-        },
-    ],
-    \SwFwLess\components\mysql\MysqlPool::EVENT_MYSQL_POOL_CHANGE => [
-        function (\Cake\Event\Event $event) {
-            $count = $event->getData('count');
-
-            if (\SwFwLess\components\Config::get('mysql.report_pool_change')) {
-                \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:mysql', $count);
-            }
-        },
-    ],
-    \SwFwLess\components\amqp\ConnectionPool::EVENT_AMQP_POOL_CHANGE => [
-        function (\Cake\Event\Event $event) {
-            $count = $event->getData('count');
-
-            if (\SwFwLess\components\Config::get('amqp.report_pool_change')) {
-                \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:amqp', $count);
-            }
-        },
-    ],
-    \SwFwLess\components\hbase\HbasePool::EVENT_HBASE_POOL_CHANGE => [
-        function (\Cake\Event\Event $event) {
-            $count = $event->getData('count');
-
-            if (\SwFwLess\components\Config::get('hbase.report_pool_change')) {
-                \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:hbase', $count);
-            }
-        },
-    ],
-];

+ 0 - 11
frameworks/PHP/sw-fw-less/config/log.php

@@ -1,11 +0,0 @@
-<?php
-
-return [
-    'path' => env('LOG_PATH', __DIR__ . '/../runtime/logs/app-{date}.log'),
-    'level' => envInt('LOG_LEVEL', \Monolog\Logger::DEBUG),
-    'pool_size' => envInt('LOG_POOL_SIZE', 100),
-    'buffer_max_size' => envInt('LOG_BUFFER_MAX_SIZE', 10),
-    'name' => env('LOG_NAME', 'sw-fw-less'),
-    'reserve_days' => envInt('LOG_RESERVE_DAYS', 3),
-    'switch' => envInt('LOG_SWITCH', 0),
-];

+ 0 - 18
frameworks/PHP/sw-fw-less/config/middleware.php

@@ -1,18 +0,0 @@
-<?php
-
-return [
-    'middleware' => [
-//        \SwFwLess\components\zipkin\Middleware::class,
-//        \SwFwLess\components\chaos\Middleware::class,
-//        \SwFwLess\middlewares\Cors::class,
-//        \SwFwLess\components\auth\Middleware::class,
-//        \SwFwLess\middlewares\IpRestriction::class,
-    ],
-    'routeMiddleware' => [
-//        \SwFwLess\components\ratelimit\Middleware::class,
-    ],
-    'aliases' => [
-        'cors' => \SwFwLess\middlewares\Cors::class,
-        'auth' => \SwFwLess\components\auth\Middleware::class,
-    ],
-];

+ 0 - 23
frameworks/PHP/sw-fw-less/config/mysql.php

@@ -1,23 +0,0 @@
-<?php
-
-return [
-    'default' => env('MYSQL_DEFAULT', 'default'),
-    'connections' => [
-        env('MYSQL_DEFAULT', 'default') => [
-            'dsn' => env('MYSQL_DSN', 'mysql:dbname=sw_test;host=127.0.0.1'),
-            'username' => env('MYSQL_USERNAME', 'root'),
-            'passwd' => env('MYSQL_PASSWD', null),
-            'options' => [
-                \PDO::ATTR_CASE => \PDO::CASE_NATURAL,
-                \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
-                \PDO::ATTR_ORACLE_NULLS => \PDO::NULL_NATURAL,
-                \PDO::ATTR_STRINGIFY_FETCHES => false,
-                \PDO::ATTR_EMULATE_PREPARES => false,
-            ],
-            'pool_size' => envInt('MYSQL_POOL_SIZE', 5),
-        ],
-    ],
-    'switch' => envInt('MYSQL_SWITCH', 0),
-    'pool_change_event' => envInt('MYSQL_POOL_CHANGE_EVENT', 0),
-    'report_pool_change' => envInt('MYSQL_REPORT_POOL_CHANGE', 0),
-];

+ 0 - 30
frameworks/PHP/sw-fw-less/config/providers.php

@@ -1,30 +0,0 @@
-<?php
-
-return [
-    //Common Providers
-    \SwFwLess\components\swoole\counter\CounterProvider::class,
-//    \SwFwLess\components\redis\RedisProvider::class,
-
-    //App Providers
-    \SwFwLess\components\swoole\SwooleProvider::class,
-//    \SwFwLess\components\chaos\ChaosProvider::class,
-
-    //Worker Providers
-    \SwFwLess\components\datetime\DatetimeProvider::class,
-    \SwFwLess\components\event\EventProvider::class,
-    \SwFwLess\components\log\LogProvider::class,
-//    \SwFwLess\components\ratelimit\RatelimitProvider::class,
-//    \SwFwLess\components\cache\CacheProvider::class,
-    \SwFwLess\components\mysql\MysqlProvider::class,
-//    \SwFwLess\components\es\EsProvider::class,
-//    \SwFwLess\components\storage\StorageProvider::class,
-//    \SwFwLess\components\amqp\AmqpProvider::class,
-//    \SwFwLess\components\hbase\HbaseProvider::class,
-    \SwFwLess\components\di\ContainerProvider::class,
-//    \SwFwLess\components\auth\jwt\JwtProvider::class,
-
-    //Request Providers
-
-    //Shutdown Providers
-    \SwFwLess\components\swoole\coresource\CoroutineResProvider::class,
-];

+ 0 - 15
frameworks/PHP/sw-fw-less/config/router.php

@@ -1,15 +0,0 @@
-<?php
-
-use App\services\TestService;
-
-return [
-    'single' => [
-        ['GET', '/json', [TestService::class, 'json']],
-        ['GET', '/db', [TestService::class, 'db']],
-        ['GET', '/queries/[{queries}]', [TestService::class, 'queries']],
-        ['GET', '/fortunes', [TestService::class, 'fortunes']],
-        ['GET', '/updates/[{queries}]', [TestService::class, 'updates']],
-        ['GET', '/plaintext', [TestService::class, 'plaintext']],
-    ],
-    'group' => [],
-];

+ 0 - 23
frameworks/PHP/sw-fw-less/config/server.php

@@ -1,23 +0,0 @@
-<?php
-
-$serverConfig = [
-    'host' => env('SERVER_HOST', '0.0.0.0'),
-    'port' => envInt('SERVER_PORT', 9501),
-    'worker_num' => envInt('SERVER_WORKER_NUM', swoole_cpu_num() * 2),
-    'daemonize' => envBool('SERVER_DAEMONIZE', false),
-    'backlog' => envInt('SERVER_BACKLOG', 128),
-    'max_request' => envInt('SERVER_MAX_REQUEST', 0),
-    'dispatch_mode' => envInt('SERVER_DISPATCH_MODE', 2),
-    'open_http2_protocol' => envBool('SERVER_OPEN_HTTP2', false),
-    'task_worker_num' => envInt('SERVER_TASK_WORKER_NUM', 0),
-    'task_enable_coroutine' => envBool('SERVER_TASK_ENABLE_COROUTINE', false),
-    'open_tcp_nodelay' => envBool('SERVER_OPEN_TCP_NODELAY', true),
-    'max_coroutine' => envInt('SERVER_MAX_COROUTINE', 1000000),
-    'socket_buffer_size' => envInt('SERVER_SOCKET_BUFFER_SIZE', 2 * 1024 * 1024),
-];
-
-if (!empty($pidFile = env('SERVER_PID_FILE'))) {
-    $serverConfig['pid_file'] = $pidFile;
-}
-
-return $serverConfig;

+ 0 - 12
frameworks/PHP/sw-fw-less/start.php

@@ -1,12 +0,0 @@
-<?php
-
-!defined('APP_BASE_PATH') && define('APP_BASE_PATH', __DIR__ . '/');
-
-if (extension_loaded('jsonnet')) {
-    !defined('CONFIG_FORMAT') && define('CONFIG_FORMAT', 'array,jsonnet');
-}
-
-require_once __DIR__ . '/vendor/autoload.php';
-
-//This app supports hot reload and shutdown triggered by SIGTERM
-(new \SwFwLess\bootstrap\App())->run();

+ 0 - 33
frameworks/PHP/sw-fw-less/sw-fw-less.dockerfile

@@ -1,33 +0,0 @@
-FROM php:7.4
-
-RUN pecl install swoole > /dev/null && \
-    docker-php-ext-enable swoole
-
-RUN docker-php-ext-install pdo_mysql > /dev/null
-
-RUN apt -yqq update > /dev/null && \
-    apt -yqq install git unzip > /dev/null
-
-# Composer
-RUN curl -sS https://getcomposer.org/installer | php \
-    && mv composer.phar /usr/local/bin/composer \
-    && composer self-update --clean-backups
-
-# Bcmath extension required by amqp composer package
-RUN docker-php-ext-install bcmath > /dev/null
-
-# Sockets extension
-RUN docker-php-ext-install sockets > /dev/null
-
-ADD . /var/www/sw-fw-less
-
-WORKDIR /var/www/sw-fw-less
-
-RUN composer install --no-dev --quiet > /dev/null \
-    && composer dump-autoload -o
-
-EXPOSE 9501
-
-ENTRYPOINT ["php", "/var/www/sw-fw-less/start.php"]
-
-LABEL luoxiaojun1992 <[email protected]>