Skip to content

omniplay/edgegap API reference

Floor
Provider · Omniplay
Version
1.x
Conformance suite
not wired
Verified for real
Verified in part
Licence
MIT
composer require omniplay/edgegap:1.x-dev

Read from the package's own PHP files at the commit 71472e01669a: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Omniplay\Edgegap

  • AppVersion class

    What a server of one service runs on Edgegap, as the configuration gives it: the application and its version (made in Edgegap's dashboard: the image, its ports, its resources), the name of the version's port players connect to ("gameport"), the address they are given ("{ip}" the host's public IP, "{fqdn}" the deployment's name, "{port}" the external port Edgegap assigned), the server's own environment and tags.

    2 methods · 10 properties

  • EdgegapFactory class

    "edgegap": options services (by service name: application, version, port, address, env, internal_port, cpu_units, memory_mib, require_cached_locations, tags - see AppVersion), token (the reference of the API token: "EDGEGAP_API_TOKEN", read through the secrets given, the environment by default), regions (by name, the location a deployment of that region is placed near: a public IP, or [latitude, longitude]), api ("https://api.edgegap.com"), secret_env ("OMNIPLAY_TICKET_SECRET"), name_prefix ("omniplay-"), heartbeat_url (the application's heartbeat route, handed to each server as OMNIPLAY_HEARTBEAT_URL), wait (30 seconds for a deployment's address), poll_interval (1 second), user_agent.

    10 options · 1 method

  • EdgegapHosting class

    Game servers as Edgegap deployments, through its REST API: a server is a deployment of its service's application version (POST /v2/deployments), placed by Edgegap near the players it is given - their public IPs or their coordinates (near()) - or near the location of the region asked; its status is read (GET /v1/status/{request_id}) until Edgegap gives it a host and an external port, and it is stopped by its request id (DELETE /v1/stop/{request_id}).

    9 methods · 2 constants

Omniplay\Edgegap

AppVersion class

final readonly class AppVersion AppVersion.php:15

What a server of one service runs on Edgegap, as the configuration gives it: the application and its version (made in Edgegap's dashboard: the image, its ports, its resources), the name of the version's port players connect to ("gameport"), the address they are given ("{ip}" the host's public IP, "{fqdn}" the deployment's name, "{port}" the external port Edgegap assigned), the server's own environment and tags.

public string $application
public string $version
public string $port
public string $address
public array $env

the server's own variables (omniplay's are set after them)

public ?int $internalPort

the port the server listens on, handed as OMNIPLAY_PORT; not handed when null (Edgegap hands ARBITRIUM_PORT_<NAME>_INTERNAL)

public ?int $cpuUnits

overrides the version's (1024 units: one vCPU), with $memoryMib

public ?int $memoryMib
public bool $requireCachedLocations
public array $tags

the deployment's tags besides omniplay's

AppVersion::__construct()

public function __construct(public string $application, public string $version, public string $port = 'gameport', public string $address = '{ip}:{port}', public array $env = [], public ?int $internalPort = null, public ?int $cpuUnits = null, public ?int $memoryMib = null, public bool $requireCachedLocations = false, public array $tags = [])
$env

the server's own variables (omniplay's are set after them)

$internalPort

the port the server listens on, handed as OMNIPLAY_PORT; not handed when null (Edgegap hands ARBITRIUM_PORT_<NAME>_INTERNAL)

$cpuUnits

overrides the version's (1024 units: one vCPU), with $memoryMib

$tags

the deployment's tags besides omniplay's

AppVersion::fromArray()

public static function fromArray(string $service, array $values): self

A service's entry of the "services" option.

EdgegapFactory class

final class EdgegapFactory extends ProviderFactory EdgegapFactory.php:28

"edgegap": options services (by service name: application, version, port, address, env, internal_port, cpu_units, memory_mib, require_cached_locations, tags - see AppVersion), token (the reference of the API token: "EDGEGAP_API_TOKEN", read through the secrets given, the environment by default), regions (by name, the location a deployment of that region is placed near: a public IP, or [latitude, longitude]), api ("https://api.edgegap.com"), secret_env ("OMNIPLAY_TICKET_SECRET"), name_prefix ("omniplay-"), heartbeat_url (the application's heartbeat route, handed to each server as OMNIPLAY_HEARTBEAT_URL), wait (30 seconds for a deployment's address), poll_interval (1 second), user_agent.

Options

OptionDefault
services[]required
token'EDGEGAP_API_TOKEN'required
regions[]
api'https://api.edgegap.com'
secret_env'OMNIPLAY_TICKET_SECRET'
name_prefix'omniplay-'
heartbeat_urlnull
wait30
poll_interval1
user_agent'omniplay/1.0 (+https://github.com/glitchr-omnisense/omniplay)'

EdgegapFactory::__construct()

public function __construct(readonly ?HttpClientInterface $http = null, readonly ?SecretsInterface $secrets = null, readonly ?\Closure $sleep = null)
$sleep

how a start waits between two reads of the status (usleep when null)

EdgegapHosting class

final class EdgegapHosting implements ProviderInterface, HostingInterface EdgegapHosting.php:40

Game servers as Edgegap deployments, through its REST API: a server is a deployment of its service's application version (POST /v2/deployments), placed by Edgegap near the players it is given - their public IPs or their coordinates (near()) - or near the location of the region asked; its status is read (GET /v1/status/{request_id}) until Edgegap gives it a host and an external port, and it is stopped by its request id (DELETE /v1/stop/{request_id}).

The deployment's environment holds its ticket secret (OMNIPLAY_TICKET_SECRET unless configured otherwise, sent hidden: is_hidden), its id - which is its tickets' room - (OMNIPLAY_SERVER_ID, OMNIPLAY_ROOM), its service, capacity, declared engine, the application's heartbeat route and, when configured, its port. The secret goes into the deployment and nowhere else: not into the Server returned, not into its tags. The API token is read by its reference at each call and sent as "Authorization: token ...".

Its tags (op:id=, op:svc=, op:cap=, op:reg=, op:eng=, op:tag=; Edgegap takes 40 characters at most) are what running() rebuilds the servers from.

const TAG = 'op:'
const TAG_LENGTH = 40

EdgegapHosting::__construct()

public function __construct(readonly JsonClient $json, readonly SecretsInterface $secrets, readonly string $token, readonly array $apps, readonly array $regions = [], readonly string $api = 'https://api.edgegap.com', readonly string $secretEnv = 'OMNIPLAY_TICKET_SECRET', readonly string $prefix = 'omniplay-', readonly ?string $heartbeatUrl = null, readonly int $wait = 30, readonly float $interval = 1.0, ?\Closure $sleep = null)
$token

the reference of the API token (an environment variable's name, a vault's key)

$apps

by service

$regions

the location each region deploys near, by name

$wait

seconds a start waits for Edgegap to give the deployment its address

$sleep

how it waits between two reads of the status (usleep when null)

EdgegapHosting::getName()

public function getName(): string

EdgegapHosting::getTitle()

public function getTitle(): string

EdgegapHosting::capabilities()

public function capabilities(): Capabilities

It starts servers when it knows where: near the players given (near()), in any region asked, or near a configured region's location.

EdgegapHosting::near()

public function near(array $players): self

The same provider, its deployments placed near these players: each a public IP ("203.0.113.7") or coordinates ([45.5, -73.56], or ['latitude' => 45.5, 'longitude' => -73.56]). What a seat's Seating is given, with the players of the match.

EdgegapHosting::start()

public function start(Service $service, string $secret, ?string $region = null, array $tags = []): Server

EdgegapHosting::stop()

public function stop(Server $server): void

EdgegapHosting::running()

public function running(?string $service = null): array

EdgegapHosting::location()

public static function location(mixed $location, string $what): array

A location of Edgegap's "users": a public IP, or coordinates.