Skip to content

Commit 4f8f2e9

Browse files
committed
Added some basic examples
1 parent 82294f9 commit 4f8f2e9

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

examples/connections-async.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
use ApiClients\Client\RabbitMQ\Management\AsyncClient;
4+
use function ApiClients\Foundation\resource_pretty_print;
5+
use ApiClients\Client\RabbitMQ\Management\Resource\ConnectionInterface;
6+
use React\EventLoop\Factory;
7+
use Rx\Observer\CallbackObserver;
8+
9+
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
10+
11+
$loop = Factory::create();
12+
$config = require 'resolve_config.php';
13+
14+
$client = AsyncClient::create($loop, $config['baseUrl'], $config['username'], $config['password']);
15+
$connections = $client->connections()->subscribe(new CallbackObserver(function (ConnectionInterface $connection) {
16+
resource_pretty_print($connection);
17+
}));
18+
19+
$loop->run();

examples/connections.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
3+
use ApiClients\Client\RabbitMQ\Management\Client;
4+
use function ApiClients\Foundation\resource_pretty_print;
5+
6+
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
7+
8+
$config = require 'resolve_config.php';
9+
10+
$client = Client::create($config['baseUrl'], $config['username'], $config['password']);
11+
$connections = $client->connections();
12+
13+
foreach ($connections as $connection) {
14+
resource_pretty_print($connection);
15+
}

examples/overview-async.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types=1);
2+
3+
use ApiClients\Client\RabbitMQ\Management\AsyncClient;
4+
use function ApiClients\Foundation\resource_pretty_print;
5+
use ApiClients\Client\RabbitMQ\Management\Resource\OverviewInterface;
6+
use React\EventLoop\Factory;
7+
8+
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
9+
10+
$loop = Factory::create();
11+
$config = require 'resolve_config.php';
12+
13+
$client = AsyncClient::create($loop, $config['baseUrl'], $config['username'], $config['password']);
14+
$overview = $client->overview()->then(function (OverviewInterface $overview) {
15+
resource_pretty_print($overview);
16+
});
17+
18+
$loop->run();

examples/overview.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
use ApiClients\Client\RabbitMQ\Management\Client;
4+
use function ApiClients\Foundation\resource_pretty_print;
5+
6+
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
7+
8+
$config = require 'resolve_config.php';
9+
10+
$client = Client::create($config['baseUrl'], $config['username'], $config['password']);
11+
$overview = $client->overview();
12+
13+
resource_pretty_print($overview);

examples/queues-async.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
use ApiClients\Client\RabbitMQ\Management\AsyncClient;
4+
use function ApiClients\Foundation\resource_pretty_print;
5+
use ApiClients\Client\RabbitMQ\Management\Resource\QueueInterface;
6+
use React\EventLoop\Factory;
7+
use Rx\Observer\CallbackObserver;
8+
9+
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
10+
11+
$loop = Factory::create();
12+
$config = require 'resolve_config.php';
13+
14+
$client = AsyncClient::create($loop, $config['baseUrl'], $config['username'], $config['password']);
15+
$queues = $client->queues()->subscribe(new CallbackObserver(function (QueueInterface $queue) {
16+
resource_pretty_print($queue);
17+
}));
18+
19+
$loop->run();

examples/queues.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
3+
use ApiClients\Client\RabbitMQ\Management\Client;
4+
use function ApiClients\Foundation\resource_pretty_print;
5+
6+
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
7+
8+
$config = require 'resolve_config.php';
9+
10+
$client = Client::create($config['baseUrl'], $config['username'], $config['password']);
11+
$queues = $client->queues();
12+
13+
foreach ($queues as $queue) {
14+
resource_pretty_print($queue);
15+
}

0 commit comments

Comments
 (0)