ihsw / toxiproxy-php-client
shopify/toxiproxy 的 PHP 客户端
v2.0
2018-01-25 16:51 UTC
Requires
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpdocumentor/phpdocumentor: ^v2.9.0
- phpunit/phpunit: ^6.5.5
- react/socket: ^v0.8.2
- react/socket-client: ^v0.7.0
- squizlabs/php_codesniffer: ^3.2.2
This package is not auto-updated.
Last update: 2024-09-14 17:06:01 UTC
README
Toxiproxy 可以轻松测试网络条件,例如低带宽和高延迟情况。 toxiproxy-php-client
包含配置 Toxiproxy 上游连接和监听端点的所有必需内容。
注意: toxiproxy-php-client
目前与 toxiproxy-2.0+
兼容。
通过 Composer 安装
推荐通过 Composer 安装 toxiproxy-php-client
。
安装完成后,将 ihsw/toxiproxy-php-client
添加到您的 composer.json
配置中,您就可以要求自动加载器并开始使用该库。
以下是一个创建限制 Redis 连接至 1000KB/s 的代理的示例。
<?php require("./vendor/autoload.php"); use Ihsw\Toxiproxy\Toxiproxy; use Ihsw\Toxiproxy\ToxicTypes; use Ihsw\Toxiproxy\StreamDirections; $toxiproxy = new Toxiproxy("http://toxiproxy:8474"); $proxy = $toxiproxy->create("ihsw_example_redis_master", "127.0.0.1:6379"); $toxic = $proxy->create(ToxicTypes::BANDWIDTH, StreamDirections::UPSTREAM, 1.0, [ "rate" => 1000 ]); printf( "Listening on IP %s and port %s on behalf of 6379, with a connection that's limited to 1000KB/s\n", $proxy->getListenIp(), $proxy->getListenPort() ); $toxiproxy->delete($proxy);
文档
更多示例可以在 examples
目录中找到。