public ManagedChannelBuilder<?> forAddress(String name, int port) { ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(name, port); if (this.customizers != null) { this.customizers.stream() .forEach(customizer -> customizer.customize(builder)); } return builder; }
/** Creates a {@link io.grpc.ManagedChannelBuilder} preconfigured for the emulator's port. */ private static ManagedChannelBuilder<?> newChannelBuilder(int port) { // NOTE: usePlaintext is currently @ExperimentalAPI. // See https://github.com/grpc/grpc-java/issues/1772 for discussion return ManagedChannelBuilder.forAddress("localhost", port).usePlaintext(); }
public ClientBase(String address, int port) { this(ManagedChannelBuilder.forAddress(address, port).usePlaintext()); }
public GraphQlGrpcClient(String host, int port) { this(ManagedChannelBuilder.forAddress(host, port).usePlaintext(true).build()); }
/** * Init client with specified target Etcd uri. * * @param uri target Etcd uri */ public EtcdV3Client(URI uri) { ManagedChannelBuilder mcb = ManagedChannelBuilder.forAddress(uri.getHost(), uri.getPort()); this.channel = mcb.usePlaintext(true).build(); kvStub = KVGrpc.newBlockingStub(channel); watchStub = WatchGrpc.newStub(channel); }
@Override protected void configure() { ManagedChannel channel = ManagedChannelBuilder.forAddress(HOST, PORT).usePlaintext(true).build(); bind(GreeterGrpc.GreeterBlockingStub.class).toInstance(GreeterGrpc.newBlockingStub(channel)); } }
@Override protected void configure() { ManagedChannel channel = ManagedChannelBuilder.forAddress(HOST, PORT).usePlaintext(true).build(); bind(StreamingGreeterGrpc.StreamingGreeterStub.class) .toInstance(StreamingGreeterGrpc.newStub(channel)); } }
/** * Provide a lazy {@link ManagedChannel} bean if none was already defined for communicating with the Genie server. * * @param serverArguments The server arguments to use * @return A {@link ManagedChannel} instance configured to use plain text over the wire */ @Bean @Lazy @ConditionalOnMissingBean(ManagedChannel.class) public ManagedChannel channel(final ArgumentDelegates.ServerArguments serverArguments) { return ManagedChannelBuilder .forAddress( serverArguments.getServerHost(), serverArguments.getServerPort() ) .usePlaintext(true) .build(); }
@Override protected void configure() { ManagedChannel channel = ManagedChannelBuilder.forAddress(HOST, PORT).usePlaintext(true).build(); bind(ShelfServiceGrpc.ShelfServiceFutureStub.class) .toInstance(ShelfServiceGrpc.newFutureStub(channel)); bind(ShelfServiceGrpc.ShelfServiceBlockingStub.class) .toInstance(ShelfServiceGrpc.newBlockingStub(channel)); } }
@Override protected void configure() { ManagedChannel channel = ManagedChannelBuilder.forAddress(HOST, PORT).usePlaintext(true).build(); bind(BookServiceGrpc.BookServiceFutureStub.class) .toInstance(BookServiceGrpc.newFutureStub(channel)); bind(BookServiceGrpc.BookServiceBlockingStub.class) .toInstance(BookServiceGrpc.newBlockingStub(channel)); } }
public boolean init() throws Exception { methodDescMap = GrpcUtil.getMethodDescriptorByAnnotation(interfaceClazz, url.getParameter(URLParamType.serialize.getName())); channel = ManagedChannelBuilder.forAddress(url.getHost(), url.getPort()).usePlaintext(true).build(); return true; }
@Before public void setup() { channel = ManagedChannelBuilder.forAddress("localhost", 7777) .usePlaintext() .build(); }
@Before public void setup() { channel = ManagedChannelBuilder.forAddress("localhost", 7777) .usePlaintext() .build(); }
private ManagedChannel createChannel(int port) { return ManagedChannelBuilder.forAddress("localhost", port) .usePlaintext() .maxInboundMessageSize(256 * 1024 * 1024) .build(); }
@BeforeClass public static void setUpChannel() { channel = ManagedChannelBuilder.forAddress("127.0.0.1", server.httpPort()) .usePlaintext() .build(); }
@Test public void noMaxMessageSize() { ManagedChannel channel = ManagedChannelBuilder.forAddress("127.0.0.1", serverWithNoMaxMessageSize.httpPort()) .usePlaintext() .build(); try { UnitTestServiceBlockingStub stub = UnitTestServiceGrpc.newBlockingStub(channel); assertThat(stub.staticUnaryCall(REQUEST_MESSAGE)).isEqualTo(RESPONSE_MESSAGE); } finally { channel.shutdownNow(); } }
@Test public void longMaxRequestLimit() { ManagedChannel channel = ManagedChannelBuilder.forAddress("127.0.0.1", serverWithLongMaxRequestLimit.httpPort()) .usePlaintext() .build(); try { UnitTestServiceBlockingStub stub = UnitTestServiceGrpc.newBlockingStub(channel); assertThat(stub.staticUnaryCall(REQUEST_MESSAGE)).isEqualTo(RESPONSE_MESSAGE); } finally { channel.shutdownNow(); } }
@Test public void uncompressedClient_compressedEndpoint() throws Exception { final ManagedChannel nonDecompressingChannel = ManagedChannelBuilder.forAddress("127.0.0.1", server.httpPort()) .decompressorRegistry( DecompressorRegistry.emptyInstance() .with(Codec.Identity.NONE, false)) .usePlaintext() .build(); final UnitTestServiceBlockingStub client = UnitTestServiceGrpc.newBlockingStub(nonDecompressingChannel); assertThat(client.staticUnaryCallSetsMessageCompression(REQUEST_MESSAGE)) .isEqualTo(RESPONSE_MESSAGE); nonDecompressingChannel.shutdownNow(); checkRequestLog((rpcReq, rpcRes, grpcStatus) -> { assertThat(rpcReq.method()).isEqualTo( "armeria.grpc.testing.UnitTestService/StaticUnaryCallSetsMessageCompression"); assertThat(rpcReq.params()).containsExactly(REQUEST_MESSAGE); assertThat(rpcRes.get()).isEqualTo(RESPONSE_MESSAGE); }); }
@Before public final void setupChannels() { if(gRpcServerProperties.isEnabled()) { channel = onChannelBuild(ManagedChannelBuilder.forAddress("localhost",getPort() ) .usePlaintext() ).build(); } if(StringUtils.hasText(gRpcServerProperties.getInProcessServerName())){ inProcChannel = onChannelBuild( InProcessChannelBuilder.forName(gRpcServerProperties.getInProcessServerName()) .usePlaintext() ).build(); } } protected int getPort(){
@Before public final void setupChannels() { if(gRpcServerProperties.isEnabled()) { channel = onChannelBuild(ManagedChannelBuilder.forAddress("localhost",getPort() ) .usePlaintext() ).build(); } if(StringUtils.hasText(gRpcServerProperties.getInProcessServerName())){ inProcChannel = onChannelBuild( InProcessChannelBuilder.forName(gRpcServerProperties.getInProcessServerName()) .usePlaintext() ).build(); } } protected int getPort(){