Skip to content

Commit

Permalink
Add composer.json file for examples, update bandwidth example with ne…
Browse files Browse the repository at this point in the history
…w intended usage.
  • Loading branch information
ihsw committed Jan 25, 2018
1 parent 3852984 commit e0cae55
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
/vendor
composer.lock
/_reports
/_docs
/_docs
/examples/vendor
11 changes: 7 additions & 4 deletions examples/bandwidth.php
Expand Up @@ -2,15 +2,18 @@

require("./vendor/autoload.php");

use GuzzleHttp\Client as HttpClient;
use Ihsw\Toxiproxy\Toxiproxy;
use Ihsw\Toxiproxy\ToxicTypes;

// hooking up to toxiproxy and starting a bandwidth proxy
$toxiproxy = new Toxiproxy(new HttpClient(["base_url" => "http://127.0.0.1:8474"]));
$toxiproxy = new Toxiproxy("http://toxiproxy:8474");
$proxy = $toxiproxy->create("ihsw_example_redis_master", "127.0.0.1:6379");
$proxy->updateDownstream("bandwidth", ["enabled" => true, "rate" => 1000]);
$toxic = $proxy->create(ToxicTypes::BANDWIDTH, "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);
14 changes: 14 additions & 0 deletions examples/composer.json
@@ -0,0 +1,14 @@
{
"name": "ihsw/toxiproxy-php-client-examples",
"type": "project",
"require": {
"ihsw/toxiproxy-php-client": "^v2.0"
},
"license": "MIT",
"authors": [
{
"name": "Adrian Parker",
"email": "iamhiddensomewhere@gmail.com"
}
]
}

0 comments on commit e0cae55

Please sign in to comment.