Appearance
Region Identifier Service
Identify Region
This is used to "ping" the servers to see the closest edge cluster available from the available regions for a user. This is used because the Konnect platform prefers latency delivery of geo-locationality.
Method
GET
Request Path Publicly Available
https://<base-url>/api/regionidentifier/identifyregion
NOTE
Where <base-url> is the base URL for a region identified in the GetRegions call
Javascript pseudo code
js
const pingRegion = async (region) => {
let regionUri = region.uris.find((x) => x.type === 3);
if (!regionUri) return null;
let pings = [];
let pingCount = 5;
let pingsToTake = 3;
for (let i = 0; i < pingCount; i++) {
let ping = performance.now();
await fetch(`${regionUri.uri}api/regionidentifier/identifyregion`, {
mode: "no-cors",
})
ping = performance.now() - ping;
pings.push(ping);
}
let topPings = pings.slice(-pingsToTake);
return {
regionId: region.regionId,
ping: topPings.reduce((a, b) => a + b, 0) / pingsToTake,
uri: regionUri.uri
};
};Response
The response is the
regionId, the goal here is to measure the response time in milliseconds to be able to average it out and detect the closest streaming region by latency
json
"df3154e8-5a1f-4902-a2eb-f6191b589589"