T3236
As part of mitigating the manual interventions involved in D14096 when the supplied Chronik instance keels over, this diff introduces a new FailoverProxy class exported from failoverProxy.ts which manages both regular and websocket endpoints, as well as the logic to cycle through an array of url/wsUrl endpoints should one become non-responsive.
As part of this refactor:
- FailoverProxy is instantiated by the ChronikClient constructor, and upon instantiation the FailoverProxy constructor uses appendWsUrls to build an array of type Endpoint[] consisting of url and wsUrls.
- _post, _get, _callAxios and _connect functions have all been moved into this FailoverProxy class in order to centralize all network handling logic and easily track the state of endpoint iteration.
- Whilst the array of endpoints is cycled through, the most recent working endpoint is tracked via its index in the array to ensure efficient iteration.
- All existing and future network related functions gets passed an instance of the same FailoverProxy class to ensure the regular and websocket endpoints are always sync'ed at all times.
- The main update to the websocket connection logic (connectWs) was to close the websocket upon the onerror call back, which allows the loop to iterate to the next wsUrl.