ES
games/xencenter-xenadmin-xcp-jumphp / src / Xapi / Fake / FakeHostTransport.php · commit fb1b7c9
<?phpnamespace App\Xapi\Fake;use App\Xapi\FakeXapi;use App\Xapi\Transport;use JumPHP\Async\Task;/** * The demo pool reached at one of its hosts (not the master): what a real request to that host's own XAPI gets. Only /rrd_updates * differs (each host has the figures of itself and of the VMs it runs); the FakeXapi itself is polled by the pool's connection. */final class FakeHostTransport implements Transport{    public function __construct(private FakeXapi $fake, private string $hostUuid, private string $address)    {    }    public function request(string $method, string $path, string $body = '', array $headers = [], string $channel = 'calls'): Task    {        if (str_starts_with($path, '/rrd_updates')) {            $path .= '&xc_host=' . rawurlencode($this->hostUuid);        }        return $this->fake->request($method, $path, $body, $headers, $channel);    }    public function poll(float $dt): void    {    }    public function close(): void    {    }    public function describe(): string    {        return 'Demo host ' . $this->address;    }}