mirror of https://github.com/grpc/grpc-java.git
api: expose if waitForReady has been set on CallOptions
This commit is contained in:
parent
ce6358e57f
commit
53a3f12666
|
|
@ -69,7 +69,8 @@ public final class CallOptions {
|
||||||
/**
|
/**
|
||||||
* Opposite to fail fast.
|
* Opposite to fail fast.
|
||||||
*/
|
*/
|
||||||
private boolean waitForReady;
|
@Nullable
|
||||||
|
private Boolean waitForReady;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Integer maxInboundMessageSize;
|
private Integer maxInboundMessageSize;
|
||||||
|
|
@ -154,7 +155,7 @@ public final class CallOptions {
|
||||||
*/
|
*/
|
||||||
public CallOptions withWaitForReady() {
|
public CallOptions withWaitForReady() {
|
||||||
CallOptions newOptions = new CallOptions(this);
|
CallOptions newOptions = new CallOptions(this);
|
||||||
newOptions.waitForReady = true;
|
newOptions.waitForReady = Boolean.TRUE;
|
||||||
return newOptions;
|
return newOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,7 +165,7 @@ public final class CallOptions {
|
||||||
*/
|
*/
|
||||||
public CallOptions withoutWaitForReady() {
|
public CallOptions withoutWaitForReady() {
|
||||||
CallOptions newOptions = new CallOptions(this);
|
CallOptions newOptions = new CallOptions(this);
|
||||||
newOptions.waitForReady = false;
|
newOptions.waitForReady = Boolean.FALSE;
|
||||||
return newOptions;
|
return newOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -369,6 +370,10 @@ public final class CallOptions {
|
||||||
* calls and 'wait for ready' is the opposite to it.
|
* calls and 'wait for ready' is the opposite to it.
|
||||||
*/
|
*/
|
||||||
public boolean isWaitForReady() {
|
public boolean isWaitForReady() {
|
||||||
|
return Boolean.TRUE.equals(waitForReady);
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean getWaitForReady() {
|
||||||
return waitForReady;
|
return waitForReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019 The gRPC Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.grpc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal accessor for {@link CallOptions}.
|
||||||
|
*/
|
||||||
|
@Internal
|
||||||
|
public final class InternalCallOptions {
|
||||||
|
private InternalCallOptions() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the waitForReady bit or {@code null} if it was never set.
|
||||||
|
*/
|
||||||
|
public static Boolean getWaitForReady(CallOptions callOptions) {
|
||||||
|
return callOptions.getWaitForReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,8 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
@ -234,6 +236,13 @@ public class CallOptionsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWaitForReady() {
|
||||||
|
assertNull(CallOptions.DEFAULT.getWaitForReady());
|
||||||
|
assertSame(CallOptions.DEFAULT.withWaitForReady().getWaitForReady(), Boolean.TRUE);
|
||||||
|
assertSame(CallOptions.DEFAULT.withoutWaitForReady().getWaitForReady(), Boolean.FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
// Only used in noStrayModifications()
|
// Only used in noStrayModifications()
|
||||||
// TODO(carl-mastrangelo): consider making a CallOptionsSubject for Truth.
|
// TODO(carl-mastrangelo): consider making a CallOptionsSubject for Truth.
|
||||||
private static boolean equal(CallOptions o1, CallOptions o2) {
|
private static boolean equal(CallOptions o1, CallOptions o2) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue