$ composer require ejtj3/nats-monitoring jms/serializer
use EJTJ3\NatsMonitoring\Jms\Serializer\Handler\NatsDateImmutableHandler;
use EJTJ3\NatsMonitoring\Jms\Serializer\Handler\NatsDateIntervalHandler;
use EJTJ3\NatsMonitoring\Model\ConnectionRequest;
use EJTJ3\NatsMonitoring\NatsMonitoringClient;
use JMS\Serializer\Handler\HandlerRegistry;
use JMS\Serializer\SerializerBuilder;
use Symfony\Component\HttpClient\Psr18Client;
// build serializer
$serializerBuilder = new SerializerBuilder();
$serializerBuilder->configureHandlers(static function (HandlerRegistry $registry): void {
$registry->registerSubscribingHandler(new NatsDateIntervalHandler());
$registry->registerSubscribingHandler(new NatsDateImmutableHandler());
});
$serializer = $serializerBuilder->build();
$client = new NatsMonitoringClient(
serializer: $serializer,
client: new Psr18Client(),
);
$requestOptions = new ConnectionRequest();
$requestOptions->setAuth(true);
$connections = $client->getConnections('https://demo.nats.io:8222', $requestOptions);
Name | Route | Method |
---|---|---|
General | /varz | $client->getGeneralSettings('https://demo.nats.io:8222') |
Jetstream | /jsz | $client->getJetstream('https://demo.nats.io:8222') |
Connections | /connz | $client->getConnections('https://demo.nats.io:8222') |
Accounts | /accountz | $client->getAccounts('https://demo.nats.io:8222') |
Account stats | /accstatz | $client->getAccountStats('https://demo.nats.io:8222') |
Subscriptions | /subsz | $client->getSubscriptions('https://demo.nats.io:8222') |
Routes | /routez | $client->getRoutez('https://demo.nats.io:8222') |
Leafnodes | /leafz | $client->getLeafnodes('https://demo.nats.io:8222') |
Gateways | /gatewayz | Not yet implemented |
HealthProbe | /leafz | $client->getHealth('https://demo.nats.io:8222') |