HttpTransport.
Not public API. Exporting it would make "call any mirror node REST endpoint" a supported feature forever; the decision is one-way by design, since a later release can export it and no release can unexport it.
It owns nothing. One transport can back several instances, which is what lets a single connection pool serve several mirror nodes.
This class blocks the calling thread. Queries call it from the Client's executor, matching
how every other mirror node REST query in this SDK is executed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classThe one budget that spans a whole call, every page and every backoff included. -
Method Summary
Modifier and TypeMethodDescription(package private) static MirrorNodeHttpClientcreate(String baseUrl, HttpTransport transport, MirrorNodeHttpRetryPolicy retryPolicy, Map<String, String> requestHeaders, BooleanSupplier clientClosed) Build an adapter bound to one mirror node for the whole of one call.(package private) HttpResponseget(MirrorNodeRestPath path, Cancellation cancellation, MirrorNodeHttpClient.CallDeadline deadline) Perform aGET, retrying per the policy.(package private) StringExtract the mirror node this adapter is pinned to.(package private) MirrorNodeHttpRetryPolicyExtract the resolved retry budget.(package private) HttpResponsepost(MirrorNodeRestPath path, String contentType, byte[] body, Cancellation cancellation, MirrorNodeHttpClient.CallDeadline deadline) Perform aPOST, retrying per the policy.(package private) static DurationresolveTotalDeadline(MirrorNodeHttpRetryPolicy policy, Duration clientRequestTimeout, @Nullable Duration explicitTimeout) Resolve the one bound that spans a whole call.
-
Method Details
-
create
static MirrorNodeHttpClient create(String baseUrl, HttpTransport transport, MirrorNodeHttpRetryPolicy retryPolicy, Map<String, String> requestHeaders, BooleanSupplier clientClosed) Build an adapter bound to one mirror node for the whole of one call.- Parameters:
baseUrl- the mirror node REST base URL, pinned for every attempt and every page of the calltransport- the transport to exchange through; never closed by this classretryPolicy- the resolved budget, whose total deadline must already be positiverequestHeaders- the caller headers fromMirrorNodeHttpConfigclientClosed- whether the owning client has shut down- Returns:
- the new adapter
-
resolveTotalDeadline
static Duration resolveTotalDeadline(MirrorNodeHttpRetryPolicy policy, Duration clientRequestTimeout, @Nullable Duration explicitTimeout) Resolve the one bound that spans a whole call.A total deadline of zero on the policy means "inherit the client's request timeout" rather than "no bound": merged SDK policy already defines
requestTimeoutas the overall execution duration of a query including retries, backoff and node rotation, and a mirror node REST query is a query. An explicit per-call timeout argument overrides both.- Parameters:
policy- the resolved retry policyclientRequestTimeout- the client's request timeoutexplicitTimeout- the timeout the caller passed toexecute, or null- Returns:
- the budget for the whole call
-
getBaseUrl
String getBaseUrl()Extract the mirror node this adapter is pinned to.- Returns:
- the base URL
-
getRetryPolicy
MirrorNodeHttpRetryPolicy getRetryPolicy()Extract the resolved retry budget.- Returns:
- the policy
-
get
HttpResponse get(MirrorNodeRestPath path, Cancellation cancellation, MirrorNodeHttpClient.CallDeadline deadline) Perform aGET, retrying per the policy.- Parameters:
path- the path below the base URLcancellation- the caller's cancellation, passed through unwrapped to every attemptdeadline- the call's remaining budget tracker- Returns:
- the response on any status the policy does not retry, including 4xx
-
post
HttpResponse post(MirrorNodeRestPath path, String contentType, byte[] body, Cancellation cancellation, MirrorNodeHttpClient.CallDeadline deadline) Perform aPOST, retrying per the policy.A
POSTis retried like aGET: every mirror node REST endpoint in scope is read-only, so the method is not a reason to suppress a retry. The body is replayed byte for byte on each attempt.- Parameters:
path- the path below the base URLcontentType- the body's media typebody- the request bodycancellation- the caller's cancellation, passed through unwrapped to every attemptdeadline- the call's remaining budget tracker- Returns:
- the response on any status the policy does not retry, including 4xx
-