mirror of https://github.com/grpc/grpc-java.git
Make all transport factories package-private in favor of channel builders.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=79367593
This commit is contained in:
parent
776ff86687
commit
a71d887661
|
@ -3,8 +3,8 @@ package com.google.net.stubby.examples;
|
||||||
import com.google.common.util.concurrent.SettableFuture;
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
import com.google.net.stubby.ChannelImpl;
|
import com.google.net.stubby.ChannelImpl;
|
||||||
import com.google.net.stubby.stub.StreamObserver;
|
import com.google.net.stubby.stub.StreamObserver;
|
||||||
|
import com.google.net.stubby.transport.netty.NegotiationType;
|
||||||
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
|
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
|
||||||
import com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
|
|
||||||
import com.google.protos.net.stubby.examples.CalcGrpc;
|
import com.google.protos.net.stubby.examples.CalcGrpc;
|
||||||
import com.google.protos.net.stubby.examples.CalcGrpc.CalcBlockingStub;
|
import com.google.protos.net.stubby.examples.CalcGrpc.CalcBlockingStub;
|
||||||
import com.google.protos.net.stubby.examples.CalcGrpc.CalcStub;
|
import com.google.protos.net.stubby.examples.CalcGrpc.CalcStub;
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.google.net.stubby.examples;
|
||||||
|
|
||||||
import com.google.net.stubby.ChannelImpl;
|
import com.google.net.stubby.ChannelImpl;
|
||||||
import com.google.net.stubby.stub.StreamObserver;
|
import com.google.net.stubby.stub.StreamObserver;
|
||||||
|
import com.google.net.stubby.transport.netty.NegotiationType;
|
||||||
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
|
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
|
||||||
import com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
|
|
||||||
import com.google.protos.net.stubby.examples.StockGrpc;
|
import com.google.protos.net.stubby.examples.StockGrpc;
|
||||||
import com.google.protos.net.stubby.examples.StockGrpc.StockBlockingStub;
|
import com.google.protos.net.stubby.examples.StockGrpc.StockBlockingStub;
|
||||||
import com.google.protos.net.stubby.examples.StockGrpc.StockStub;
|
import com.google.protos.net.stubby.examples.StockGrpc.StockStub;
|
||||||
|
|
|
@ -1,26 +1,13 @@
|
||||||
package com.google.net.stubby.testing.integration;
|
package com.google.net.stubby.testing.integration;
|
||||||
|
|
||||||
import static com.google.net.stubby.testing.integration.Messages.PayloadType.COMPRESSABLE;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.net.stubby.ChannelImpl;
|
import com.google.net.stubby.ChannelImpl;
|
||||||
import com.google.net.stubby.stub.StreamRecorder;
|
import com.google.net.stubby.transport.netty.NegotiationType;
|
||||||
import com.google.net.stubby.testing.integration.Messages.SimpleRequest;
|
|
||||||
import com.google.net.stubby.testing.integration.Messages.SimpleResponse;
|
|
||||||
import com.google.net.stubby.testing.integration.Messages.StreamingOutputCallRequest;
|
|
||||||
import com.google.net.stubby.testing.integration.Messages.StreamingOutputCallResponse;
|
|
||||||
import com.google.net.stubby.testing.integration.TestServiceGrpc.TestService;
|
|
||||||
import com.google.net.stubby.transport.okhttp.OkHttpChannelBuilder;
|
|
||||||
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
|
import com.google.net.stubby.transport.netty.NettyChannelBuilder;
|
||||||
import com.google.net.stubby.transport.netty.NettyClientTransportFactory;
|
import com.google.net.stubby.transport.okhttp.OkHttpChannelBuilder;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application that starts a client for the {@link TestServiceGrpc.TestService} and runs through a
|
* Application that starts a client for the {@link TestServiceGrpc.TestService} and runs through a
|
||||||
|
@ -38,14 +25,14 @@ public class TestServiceClient {
|
||||||
@Override
|
@Override
|
||||||
public ChannelImpl createChannel(String serverHost, int serverPort) {
|
public ChannelImpl createChannel(String serverHost, int serverPort) {
|
||||||
return NettyChannelBuilder.forAddress(serverHost, serverPort)
|
return NettyChannelBuilder.forAddress(serverHost, serverPort)
|
||||||
.negotiationType(NettyClientTransportFactory.NegotiationType.PLAINTEXT).build();
|
.negotiationType(NegotiationType.PLAINTEXT).build();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NETTY_TLS {
|
NETTY_TLS {
|
||||||
@Override
|
@Override
|
||||||
public ChannelImpl createChannel(String serverHost, int serverPort) {
|
public ChannelImpl createChannel(String serverHost, int serverPort) {
|
||||||
return NettyChannelBuilder.forAddress(serverHost, serverPort)
|
return NettyChannelBuilder.forAddress(serverHost, serverPort)
|
||||||
.negotiationType(NettyClientTransportFactory.NegotiationType.TLS).build();
|
.negotiationType(NegotiationType.TLS).build();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
OKHTTP {
|
OKHTTP {
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.google.net.stubby.transport.netty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies the negotiation used for starting up HTTP/2.
|
||||||
|
*/
|
||||||
|
public enum NegotiationType {
|
||||||
|
/**
|
||||||
|
* Uses TLS ALPN/NPN negotiation, assumes an SSL connection.
|
||||||
|
*/
|
||||||
|
TLS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the HTTP UPGRADE protocol for a plaintext (non-SSL) upgrade from HTTP/1.1 to HTTP/2.
|
||||||
|
*/
|
||||||
|
PLAINTEXT_UPGRADE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just assume the connection is plaintext (non-SSL) and the remote endpoint supports HTTP/2
|
||||||
|
* directly without an upgrade.
|
||||||
|
*/
|
||||||
|
PLAINTEXT
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import com.google.common.util.concurrent.Service;
|
||||||
import com.google.net.stubby.AbstractChannelBuilder;
|
import com.google.net.stubby.AbstractChannelBuilder;
|
||||||
import com.google.net.stubby.SharedResourceHolder;
|
import com.google.net.stubby.SharedResourceHolder;
|
||||||
import com.google.net.stubby.transport.ClientTransportFactory;
|
import com.google.net.stubby.transport.ClientTransportFactory;
|
||||||
import com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
|
|
||||||
|
|
||||||
import io.netty.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.google.net.stubby.transport.AbstractClientTransport;
|
||||||
import com.google.net.stubby.transport.ClientStream;
|
import com.google.net.stubby.transport.ClientStream;
|
||||||
import com.google.net.stubby.transport.ClientStreamListener;
|
import com.google.net.stubby.transport.ClientStreamListener;
|
||||||
import com.google.net.stubby.transport.ClientTransport;
|
import com.google.net.stubby.transport.ClientTransport;
|
||||||
import com.google.net.stubby.transport.netty.NettyClientTransportFactory.NegotiationType;
|
|
||||||
import com.google.net.stubby.util.ssl.SslContextFactory;
|
import com.google.net.stubby.util.ssl.SslContextFactory;
|
||||||
|
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
|
|
|
@ -10,28 +10,7 @@ import java.net.InetSocketAddress;
|
||||||
/**
|
/**
|
||||||
* Factory that manufactures instances of {@link NettyClientTransport}.
|
* Factory that manufactures instances of {@link NettyClientTransport}.
|
||||||
*/
|
*/
|
||||||
public class NettyClientTransportFactory implements ClientTransportFactory {
|
class NettyClientTransportFactory implements ClientTransportFactory {
|
||||||
|
|
||||||
/**
|
|
||||||
* Identifies the negotiation used for starting up HTTP/2.
|
|
||||||
*/
|
|
||||||
public enum NegotiationType {
|
|
||||||
/**
|
|
||||||
* Uses TLS ALPN/NPN negotiation, assumes an SSL connection.
|
|
||||||
*/
|
|
||||||
TLS,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use the HTTP UPGRADE protocol for a plaintext (non-SSL) upgrade from HTTP/1.1 to HTTP/2.
|
|
||||||
*/
|
|
||||||
PLAINTEXT_UPGRADE,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Just assume the connection is plaintext (non-SSL) and the remote endpoint supports HTTP/2
|
|
||||||
* directly without an upgrade.
|
|
||||||
*/
|
|
||||||
PLAINTEXT
|
|
||||||
}
|
|
||||||
|
|
||||||
private final InetSocketAddress address;
|
private final InetSocketAddress address;
|
||||||
private final NegotiationType negotiationType;
|
private final NegotiationType negotiationType;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.concurrent.ExecutorService;
|
||||||
/**
|
/**
|
||||||
* Factory that manufactures instances of {@link OkHttpClientTransport}.
|
* Factory that manufactures instances of {@link OkHttpClientTransport}.
|
||||||
*/
|
*/
|
||||||
public class OkHttpClientTransportFactory implements ClientTransportFactory {
|
class OkHttpClientTransportFactory implements ClientTransportFactory {
|
||||||
private final InetSocketAddress address;
|
private final InetSocketAddress address;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue