HostRing
Round-robin ring over a list of ArangoDB server endpoints.
Used by HttpTransport to spread requests across cluster coordinators and to fail over to a different endpoint on transient errors. The ring is stateful: each call to next() advances the internal cursor (wrapping around at the end of the list).
Endpoint URLs are normalised at construction time so that ArangoDB's legacy scheme spellings keep working:
tcp://host:port→http://host:portssl://host:port/tls://→https://host:port
Other schemes (http://, https://, unix://, …) are returned as-is.
Tags
Table of Contents
Constants
- SCHEME_HTTP : string = 'http://'
- Canonical HTTP scheme prefix used as a replacement for the legacy `tcp://` scheme.
- SCHEME_HTTPS : string = 'https://'
- Canonical HTTPS scheme prefix used as a replacement for the legacy `ssl://` and `tls://` schemes.
Properties
- $endpoints : array<string|int, string>
- Normalised endpoint list (ArangoDB legacy schemes converted to http/https).
- $cursor : int
- Internal cursor pointing at the current endpoint.
Methods
- __construct() : mixed
- current() : string
- Returns the endpoint currently pointed at by the ring cursor.
- next() : string
- Advances the ring cursor by one position (wrapping around at the end of the list) and returns the new current endpoint.
- normalize() : string
- Normalises a single endpoint URL by translating ArangoDB legacy schemes to their HTTP equivalents.
- size() : int
- Returns the number of endpoints managed by the ring.
Constants
SCHEME_HTTP
Canonical HTTP scheme prefix used as a replacement for the legacy `tcp://` scheme.
public
string
SCHEME_HTTP
= 'http://'
SCHEME_HTTPS
Canonical HTTPS scheme prefix used as a replacement for the legacy `ssl://` and `tls://` schemes.
public
string
SCHEME_HTTPS
= 'https://'
Properties
$endpoints read-only
Normalised endpoint list (ArangoDB legacy schemes converted to http/https).
public
array<string|int, string>
$endpoints
$cursor
Internal cursor pointing at the current endpoint.
private
int
$cursor
= 0
Methods
__construct()
public
__construct(array<string|int, string> $endpoints) : mixed
Parameters
- $endpoints : array<string|int, string>
-
Ordered list of endpoint URLs (at least one).
Tags
current()
Returns the endpoint currently pointed at by the ring cursor.
public
current() : string
Return values
stringnext()
Advances the ring cursor by one position (wrapping around at the end of the list) and returns the new current endpoint.
public
next() : string
Return values
stringnormalize()
Normalises a single endpoint URL by translating ArangoDB legacy schemes to their HTTP equivalents.
public
static normalize(string $endpoint) : string
Parameters
- $endpoint : string
Return values
stringsize()
Returns the number of endpoints managed by the ring.
public
size() : int