@@ -97,11 +97,15 @@ public abstract static class InternalLimitedInfoFactory extends Factory {}
9797 public static final class StreamInfo {
9898 private final Attributes transportAttrs ;
9999 private final CallOptions callOptions ;
100+ private final int previousAttempts ;
100101 private final boolean isTransparentRetry ;
101102
102- StreamInfo (Attributes transportAttrs , CallOptions callOptions , boolean isTransparentRetry ) {
103+ StreamInfo (
104+ Attributes transportAttrs , CallOptions callOptions , int previousAttempts ,
105+ boolean isTransparentRetry ) {
103106 this .transportAttrs = checkNotNull (transportAttrs , "transportAttrs" );
104107 this .callOptions = checkNotNull (callOptions , "callOptions" );
108+ this .previousAttempts = previousAttempts ;
105109 this .isTransparentRetry = isTransparentRetry ;
106110 }
107111
@@ -124,6 +128,15 @@ public CallOptions getCallOptions() {
124128 return callOptions ;
125129 }
126130
131+ /**
132+ * Returns the number of preceding attempts for the RPC.
133+ *
134+ * @since 1.40.0
135+ */
136+ public int getPreviousAttempts () {
137+ return previousAttempts ;
138+ }
139+
127140 /**
128141 * Whether the stream is a transparent retry.
129142 *
@@ -142,6 +155,7 @@ public Builder toBuilder() {
142155 return new Builder ()
143156 .setCallOptions (callOptions )
144157 .setTransportAttrs (transportAttrs )
158+ .setPreviousAttempts (previousAttempts )
145159 .setIsTransparentRetry (isTransparentRetry );
146160 }
147161
@@ -159,6 +173,7 @@ public String toString() {
159173 return MoreObjects .toStringHelper (this )
160174 .add ("transportAttrs" , transportAttrs )
161175 .add ("callOptions" , callOptions )
176+ .add ("previousAttempts" , previousAttempts )
162177 .add ("isTransparentRetry" , isTransparentRetry )
163178 .toString ();
164179 }
@@ -171,6 +186,7 @@ public String toString() {
171186 public static final class Builder {
172187 private Attributes transportAttrs = Attributes .EMPTY ;
173188 private CallOptions callOptions = CallOptions .DEFAULT ;
189+ private int previousAttempts ;
174190 private boolean isTransparentRetry ;
175191
176192 Builder () {
@@ -197,6 +213,16 @@ public Builder setCallOptions(CallOptions callOptions) {
197213 return this ;
198214 }
199215
216+ /**
217+ * Set the number of preceding attempts of the RPC.
218+ *
219+ * @since 1.40.0
220+ */
221+ public Builder setPreviousAttempts (int previousAttempts ) {
222+ this .previousAttempts = previousAttempts ;
223+ return this ;
224+ }
225+
200226 /**
201227 * Sets whether the stream is a transparent retry.
202228 *
@@ -211,7 +237,7 @@ public Builder setIsTransparentRetry(boolean isTransparentRetry) {
211237 * Builds a new StreamInfo.
212238 */
213239 public StreamInfo build () {
214- return new StreamInfo (transportAttrs , callOptions , isTransparentRetry );
240+ return new StreamInfo (transportAttrs , callOptions , previousAttempts , isTransparentRetry );
215241 }
216242 }
217243 }
0 commit comments