@Test public void toStringMatches_noDeadline_default() { String actual = allSet .withDeadline(null) .withExecutor(new SerializingExecutor(directExecutor())) .withCallCredentials(null) .withMaxInboundMessageSize(44) .withMaxOutboundMessageSize(55) .toString(); assertThat(actual).contains("deadline=null"); assertThat(actual).contains("authority=authority"); assertThat(actual).contains("callCredentials=null"); assertThat(actual).contains("executor=class io.grpc.internal.SerializingExecutor"); assertThat(actual).contains("compressorName=compressor"); assertThat(actual).contains("customOptions=[[option1, value1], [option2, value2]]"); assertThat(actual).contains("waitForReady=true"); assertThat(actual).contains("maxInboundMessageSize=44"); assertThat(actual).contains("maxOutboundMessageSize=55"); assertThat(actual).contains("streamTracerFactories=[tracerFactory1, tracerFactory2]"); }
OkHttpClientTransport(InetSocketAddress address, String authority, @Nullable String userAgent, Executor executor, @Nullable SSLSocketFactory sslSocketFactory, @Nullable HostnameVerifier hostnameVerifier, ConnectionSpec connectionSpec, int maxMessageSize, @Nullable InetSocketAddress proxyAddress, @Nullable String proxyUsername, @Nullable String proxyPassword, Runnable tooManyPingsRunnable, TransportTracer transportTracer) { this.address = Preconditions.checkNotNull(address, "address"); this.defaultAuthority = authority; this.maxMessageSize = maxMessageSize; this.executor = Preconditions.checkNotNull(executor, "executor"); serializingExecutor = new SerializingExecutor(executor); // Client initiated streams are odd, server initiated ones are even. Server should not need to // use it. We start clients at 3 to avoid conflicting with HTTP negotiation. nextStreamId = 3; this.sslSocketFactory = sslSocketFactory; this.hostnameVerifier = hostnameVerifier; this.connectionSpec = Preconditions.checkNotNull(connectionSpec, "connectionSpec"); this.stopwatchFactory = GrpcUtil.STOPWATCH_SUPPLIER; this.userAgent = GrpcUtil.getGrpcUserAgent("okhttp", userAgent); this.proxyAddress = proxyAddress; this.proxyUsername = proxyUsername; this.proxyPassword = proxyPassword; this.tooManyPingsRunnable = Preconditions.checkNotNull(tooManyPingsRunnable, "tooManyPingsRunnable"); this.transportTracer = Preconditions.checkNotNull(transportTracer); initTransportTracer(); }
/** * Create a transport connected to a fake peer for test. */ @VisibleForTesting OkHttpClientTransport( String userAgent, Executor executor, FrameReader frameReader, FrameWriter testFrameWriter, int nextStreamId, Socket socket, Supplier<Stopwatch> stopwatchFactory, @Nullable Runnable connectingCallback, SettableFuture<Void> connectedFuture, int maxMessageSize, Runnable tooManyPingsRunnable, TransportTracer transportTracer) { address = null; this.maxMessageSize = maxMessageSize; defaultAuthority = "notarealauthority:80"; this.userAgent = GrpcUtil.getGrpcUserAgent("okhttp", userAgent); this.executor = Preconditions.checkNotNull(executor, "executor"); serializingExecutor = new SerializingExecutor(executor); this.testFrameReader = Preconditions.checkNotNull(frameReader, "frameReader"); this.testFrameWriter = Preconditions.checkNotNull(testFrameWriter, "testFrameWriter"); this.socket = Preconditions.checkNotNull(socket, "socket"); this.nextStreamId = nextStreamId; this.stopwatchFactory = stopwatchFactory; this.connectionSpec = null; this.connectingCallback = connectingCallback; this.connectedFuture = Preconditions.checkNotNull(connectedFuture, "connectedFuture"); this.proxyAddress = null; this.proxyUsername = null; this.proxyPassword = null; this.tooManyPingsRunnable = Preconditions.checkNotNull(tooManyPingsRunnable, "tooManyPingsRunnable"); this.transportTracer = Preconditions.checkNotNull(transportTracer, "transportTracer"); initTransportTracer(); }
/** * Get the shared executor. */ public static Executor getSerializingExecutor() { return new SerializingExecutor(executor); }
public AsyncFrameWriter(OkHttpClientTransport transport, SerializingExecutor executor) { this.transport = transport; this.executor = executor; }