title: sgns::PriceHttpClient summary: Price-fetch facade over the status-aware sgns::HTTPClient transport (02-02): applies the status-before-parse gate (LPM-05), CoinGecko-friendly UA and 5s timeouts (LPM-06, D-08/D-10), the transient-only retry schedule with 429 hold-off (LPM-07, D-11..D-13), and produces PriceQuote objects with fetch-time timestamps (D-14).
sgns::PriceHttpClient¶
Price-fetch facade over the status-aware sgns::HTTPClient transport (02-02): applies the status-before-parse gate (LPM-05), CoinGecko-friendly UA and 5s timeouts (LPM-06, D-08/D-10), the transient-only retry schedule with 429 hold-off (LPM-07, D-11..D-13), and produces PriceQuote objects with fetch-time timestamps (D-14).
#include <PriceHttpClient.hpp>
Public Functions¶
| Name | |
|---|---|
| PriceHttpClient(std::string baseUrl, RetryConfig retryConfig ={}, std::chrono::seconds holdOffDuration =std::chrono::seconds(60), RateLimitHoldOff::Clock clock =[] { return std::chrono::system_clock::now();}, std::chrono::milliseconds requestTimeout =std::chrono::milliseconds(5000), ResponseFormat responseFormat =ResponseFormat::CoinGeckoSimplePrice) Construct a price client against a base URL. |
|
| PriceResult< std::vector< PriceQuote > > | FetchPrices(std::shared_ptr< boost::asio::io_context > ioc, const std::vector< std::string > & tokenIds, const std::string & currency ="usd") Fetch current prices for the given CoinGecko ids. |
| int | AttemptsLastFetch() const Attempts made by the most recent FetchPrices call (test-visible retry accounting). |
Public Attributes¶
| Name | |
|---|---|
| constexpr const char * | kUserAgent The CoinGecko-friendly UA this facade sends (LPM-06/D-08). |
Public Functions Documentation¶
function PriceHttpClient¶
PriceHttpClient(
std::string baseUrl,
RetryConfig retryConfig ={},
std::chrono::seconds holdOffDuration =std::chrono::seconds(60),
RateLimitHoldOff::Clock clock =[] { return std::chrono::system_clock::now();},
std::chrono::milliseconds requestTimeout =std::chrono::milliseconds(5000),
ResponseFormat responseFormat =ResponseFormat::CoinGeckoSimplePrice
)
Construct a price client against a base URL.
Parameters:
- baseUrl e.g. "https://api.coingecko.com" (TLS on, pinned CA via SGNS_DEFAULT_CACERT_PATH) or "http://127.0.0.1:
" (TLS off — how tests redirect; also D-07's construction-time override) - retryConfig Retry schedule; tests inject zero backoff
- holdOffDuration 429 hold-off window (D-13, >= 60s default)
- clock Injectable clock for hermetic hold-off tests
- requestTimeout Per-request connect/handshake/read timeout (LPM-06 default 5000ms; tests may shorten to force timeouts)
- responseFormat Wire format this instance speaks (03-03): CoinGeckoSimplePrice (tier 1, default) or GnusEnvelope (tier 2 — same retry/hold-off/status machinery, different target builder and parser)
function FetchPrices¶
PriceResult< std::vector< PriceQuote > > FetchPrices(
std::shared_ptr< boost::asio::io_context > ioc,
const std::vector< std::string > & tokenIds,
const std::string & currency ="usd"
)
Fetch current prices for the given CoinGecko ids.
Parameters:
- ioc Caller-supplied io_context (D-09 — the caller owns the executor and the run-loop)
- tokenIds CoinGecko asset ids, e.g. {"genius-ai"}
- currency Target currency, default "usd"
Return: One PriceQuote per id the source returned (unknown ids are absent, not errors — Phase-1 D-09 semantics), or a status-bearing PriceFetchFailure
function AttemptsLastFetch¶
Attempts made by the most recent FetchPrices call (test-visible retry accounting).
Public Attributes Documentation¶
variable kUserAgent¶
static constexpr const char * kUserAgent = "SGNS-PriceClient/1.0 (+https://gnus.ai; SuperGenius node price fetch)";
The CoinGecko-friendly UA this facade sends (LPM-06/D-08).
Updated on 2026-10-09 at 04:02:48 +0000