Record Class UpstreamFailure
java.lang.Object
java.lang.Record
ai.redouble.nucleo.harness.errors.http.UpstreamFailure
- Record Components:
statusCode- HTTP status, or 0 when the request never got a responseservice- the upstream the limiter is protecting, e.g.PubMeddetail- the service's own error text, including endpoint and response bodyretryAfterSeconds- the server's own instruction, or 0 when it did not give one
public record UpstreamFailure(int statusCode, String service, String detail, int retryAfterSeconds)
extends Record
What an upstream service actually said when a request failed: the HTTP status and the
response detail, carried together so a
RateLimiter can record them.
A limiter reacting to upstream pressure needs more than a retry hint. It records this alongside its throttle and circuit state and quotes it back when a circuit opens, so a tool that has been disabled names the upstream response responsible instead of leaving it to be reconstructed from surrounding log lines.
- Since:
- 0.1 (2026-08-17)
- Author:
- Andrey Santrosyan
-
Constructor Summary
ConstructorsConstructorDescriptionUpstreamFailure(int statusCode, String service, String detail, int retryAfterSeconds) Creates an instance of aUpstreamFailurerecord class. -
Method Summary
Modifier and TypeMethodDescriptiondetail()Returns the value of thedetailrecord component.final booleanIndicates whether some other object is "equal to" this one.static UpstreamFailureReads what the server actually said, wherever it sits in the cause chain.final inthashCode()Returns a hash code value for this object.intReturns the value of theretryAfterSecondsrecord component.service()Returns the value of theservicerecord component.intReturns the value of thestatusCoderecord component.summary()Compact one-line form for log lines, event reasons, and LLM-facing error messages.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
UpstreamFailure
Creates an instance of aUpstreamFailurerecord class.- Parameters:
statusCode- the value for thestatusCoderecord componentservice- the value for theservicerecord componentdetail- the value for thedetailrecord componentretryAfterSeconds- the value for theretryAfterSecondsrecord component
-
-
Method Details
-
from
Reads what the server actually said, wherever it sits in the cause chain. A status exists only when the failure was raised from an HTTP response, anHttpErrorResponsecarrier; a tool that wrapped that carrier with its service and step (LLMReadableCheckedException.wrapWithContext) still has it as a cause, so the status and the server's detail are read off the first carrier in the chain, and the retry-after off the firstUpstreamThrottleException. Both are 0 only when no carrier is anywhere in the chain: a transport failure - connection refused, read timeout, unparseable body - genuinely has no status, and 0 records that rather than guessing. The service is the outermost exception's, the one the tool named. -
summary
Compact one-line form for log lines, event reasons, and LLM-facing error messages. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
statusCode
public int statusCode()Returns the value of thestatusCoderecord component.- Returns:
- the value of the
statusCoderecord component
-
service
-
detail
-
retryAfterSeconds
public int retryAfterSeconds()Returns the value of theretryAfterSecondsrecord component.- Returns:
- the value of the
retryAfterSecondsrecord component
-