[Chronik] Implement FailoverProxy structure when interacting with Chronik in rust
Summary:
This diff adds failover.rs into bitcoinsuite-chronik-client. This file contains logic so that when we create a ChronikClient struct, it only contains one field: failover. This failover stores our client, our endpoints and working index. This allows us to keep track of multiple different endpoints that are accessible, so that in the future we can cycle to them upon downtime of one endpoint. The working index keeps track of which endpoint we are currently connected to. By having separate functions for FailoverProxy and ChronikClient, we are able to seperate the logic between the two, so that the FailoverProxy can focus on failover recovery, whereas the ChronikClient can focus on client functionality.
The cycling of endpoints upon endpoint failure will be added in a future diff.
Test Plan:
Please set BUILD_DIR env to export BUILD_DIR="/path/to/build_dir
UNIX: ./contrib/teamcity/build-configurations.py build-bitcoinsuite-chronik-client
run cargo test -- --nocapture in bitcoin-abc/modules/bitcoinsuite-chronik-client/tests
Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Subscribers: alitayin, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18318