File tree Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -512,6 +512,7 @@ private static Builder toBuilder(CallOptions other) {
512
512
builder .waitForReady = other .waitForReady ;
513
513
builder .maxInboundMessageSize = other .maxInboundMessageSize ;
514
514
builder .maxOutboundMessageSize = other .maxOutboundMessageSize ;
515
+ builder .onReadyThreshold = other .onReadyThreshold ;
515
516
return builder ;
516
517
}
517
518
@@ -527,6 +528,7 @@ public String toString() {
527
528
.add ("waitForReady" , isWaitForReady ())
528
529
.add ("maxInboundMessageSize" , maxInboundMessageSize )
529
530
.add ("maxOutboundMessageSize" , maxOutboundMessageSize )
531
+ .add ("onReadyThreshold" , onReadyThreshold )
530
532
.add ("streamTracerFactories" , streamTracerFactories )
531
533
.toString ();
532
534
}
Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ public void withAndWithoutWaitForReady() {
81
81
.isFalse ();
82
82
}
83
83
84
+ @ Test
85
+ public void withOnReadyThreshold () {
86
+ int onReadyThreshold = 1024 ;
87
+ CallOptions callOptions = CallOptions .DEFAULT .withOnReadyThreshold (onReadyThreshold );
88
+ callOptions = callOptions .withWaitForReady ();
89
+ assertThat (callOptions .getOnReadyThreshold ()).isEqualTo (onReadyThreshold );
90
+ callOptions = callOptions .clearOnReadyThreshold ();
91
+ assertThat (callOptions .getOnReadyThreshold ()).isNull ();
92
+ }
93
+
84
94
@ Test
85
95
public void allWiths () {
86
96
assertThat (allSet .getAuthority ()).isSameInstanceAs (sampleAuthority );
@@ -148,6 +158,7 @@ public void toStringMatches_noDeadline_default() {
148
158
.withCallCredentials (null )
149
159
.withMaxInboundMessageSize (44 )
150
160
.withMaxOutboundMessageSize (55 )
161
+ .withOnReadyThreshold (1024 )
151
162
.toString ();
152
163
153
164
assertThat (actual ).contains ("deadline=null" );
@@ -159,6 +170,7 @@ public void toStringMatches_noDeadline_default() {
159
170
assertThat (actual ).contains ("waitForReady=true" );
160
171
assertThat (actual ).contains ("maxInboundMessageSize=44" );
161
172
assertThat (actual ).contains ("maxOutboundMessageSize=55" );
173
+ assertThat (actual ).contains ("onReadyThreshold=1024" );
162
174
assertThat (actual ).contains ("streamTracerFactories=[tracerFactory1, tracerFactory2]" );
163
175
}
164
176
Original file line number Diff line number Diff line change @@ -252,6 +252,16 @@ public final S withMaxOutboundMessageSize(int maxSize) {
252
252
return build (channel , callOptions .withMaxOutboundMessageSize (maxSize ));
253
253
}
254
254
255
+ /**
256
+ * Returns a new stub that limits the maximum number of bytes per stream in the queue.
257
+ *
258
+ * @since 1.1.0
259
+ */
260
+ @ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/11021" )
261
+ public final S withOnReadyThreshold (int numBytes ) {
262
+ return build (channel , callOptions .withOnReadyThreshold (numBytes ));
263
+ }
264
+
255
265
/**
256
266
* A factory class for stub.
257
267
*
Original file line number Diff line number Diff line change 16
16
17
17
package io .grpc .stub ;
18
18
19
+ import static com .google .common .truth .Truth .assertThat ;
19
20
import static org .junit .Assert .assertEquals ;
20
21
import static org .junit .Assert .assertFalse ;
21
22
import static org .junit .Assert .assertNull ;
@@ -90,4 +91,16 @@ public void withExecutor() {
90
91
91
92
assertEquals (callOptions .getExecutor (), executor );
92
93
}
94
+
95
+ @ Test
96
+ public void withOnReadyThreshold () {
97
+ T stub = create (channel );
98
+ CallOptions callOptions = stub .getCallOptions ();
99
+ assertNull (callOptions .getOnReadyThreshold ());
100
+
101
+ int onReadyThreshold = 1024 ;
102
+ stub = stub .withOnReadyThreshold (onReadyThreshold );
103
+ callOptions = stub .getCallOptions ();
104
+ assertThat (callOptions .getOnReadyThreshold ()).isEqualTo (onReadyThreshold );
105
+ }
93
106
}
You can’t perform that action at this time.
0 commit comments