public GraphQlGrpcClient(String host, int port) { this(ManagedChannelBuilder.forAddress(host, port).usePlaintext(true).build()); }
public static void main(String... args) throws IOException { ManagedChannel channel = ManagedChannelBuilder.forTarget(hostport).usePlaintext().build(); try { TransportChannelProvider channelProvider =
private ManagedChannel createChannel(int port) { return ManagedChannelBuilder.forAddress("localhost", port) .usePlaintext() .maxInboundMessageSize(256 * 1024 * 1024) .build(); }
/** 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 synchronized ManagedChannel getDataChannel() { if (isStopped) { throw new IllegalStateException("Emulator is not running"); } if (dataChannel == null) { dataChannel = newChannelBuilder(port).maxInboundMessageSize(256 * 1024 * 1024).build(); } return dataChannel; }
|| NoCredentials.getInstance().equals(options.getCredentials())) { ManagedChannel managedChannel = ManagedChannelBuilder.forTarget(options.getHost()) .usePlaintext(true) .executor(executor) .build(); TransportChannel transportChannel = GrpcTransportChannel.create(managedChannel); clientContext =
throw new IllegalArgumentException("portForward", new IllegalStateException("portForward.getLocalAddress().getHostAddress() == null")); return ManagedChannelBuilder.forAddress(hostAddress, portForward.getLocalPort()) .idleTimeout(5L, TimeUnit.SECONDS) .keepAliveTime(30L, TimeUnit.SECONDS) .maxInboundMessageSize(MAX_MESSAGE_SIZE) .usePlaintext(true) .build();
public static void main(String[] args) throws Exception { String host = args[0]; int port = Integer.parseInt(args[1]); String abstractName = "mesh://timeService"; // Open a channel to the server Channel channel = ManagedChannelBuilder .forTarget(abstractName) .nameResolverFactory(StaticResolver.factory(new InetSocketAddress(host, port))) .usePlaintext(true) .build(); // Create a CompletableFuture-based stub TimeServiceGrpc8.TimeServiceCompletableFutureStub stub = TimeServiceGrpc8.newCompletableFutureStub(channel); // Call the service CompletableFuture<TimeReply> completableFuture = stub.getTime(Empty.getDefaultInstance()); TimeReply timeReply = completableFuture.get(); // Convert to JDK8 types Instant now = MoreTimestamps.toInstantUtc(timeReply.getTime()); System.out.println("The time is " + now); } }
GrpcClientImpl(final String targetUrl) { this(ManagedChannelBuilder .forTarget(targetUrl.replaceFirst("^(http[s]?://www\\.|http[s]?://|www\\.)","")) .usePlaintext() .keepAliveWithoutCalls(true) .build() ); }
public ClientBase(ManagedChannelBuilder<?> builder) { channel = builder.build(); }
/** * <p>createNettyChannel.</p> * * @param host a {@link String} object. * @param options a {@link BigtableOptions} object. * @return a {@link ManagedChannel} object. * @throws SSLException if any. */ public static ManagedChannel createNettyChannel(String host, BigtableOptions options, ClientInterceptor ... interceptors) throws SSLException { // Ideally, this should be ManagedChannelBuilder.forAddress(...) rather than an explicit // call to NettyChannelBuilder. Unfortunately, that doesn't work for shaded artifacts. ManagedChannelBuilder<?> builder = ManagedChannelBuilder .forAddress(host, options.getPort()); if (options.usePlaintextNegotiation()) { // NOTE: usePlaintext(true) is deprecated in newer versions of grpc (1.11.0). // usePlantxext() is the preferred approach, but won't work with older versions. // This means that plaintext negotiation can't be used with Beam. builder.usePlaintext(); } return builder .idleTimeout(Long.MAX_VALUE, TimeUnit.SECONDS) .maxInboundMessageSize(MAX_MESSAGE_SIZE) .userAgent(BigtableVersionInfo.CORE_USER_AGENT + "," + options.getUserAgent()) .intercept(interceptors) .build(); }
@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); }); }
private static void prepareKmsKeys() throws IOException { String projectId = remoteStorageHelper.getOptions().getProjectId(); GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); ManagedChannel kmsChannel = ManagedChannelBuilder.forTarget("cloudkms.googleapis.com:443").build(); KeyManagementServiceBlockingStub kmsStub = KeyManagementServiceGrpc.newBlockingStub(kmsChannel) .withCallCredentials(MoreCallCredentials.from(credentials)); IAMPolicyGrpc.IAMPolicyBlockingStub iamStub = IAMPolicyGrpc.newBlockingStub(kmsChannel) .withCallCredentials(MoreCallCredentials.from(credentials)); ensureKmsKeyRingExistsForTests(kmsStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME); ensureKmsKeyRingIamPermissionsForTests( iamStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME); kmsKeyOneResourcePath = ensureKmsKeyExistsForTests( kmsStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME, KMS_KEY_ONE_NAME); kmsKeyTwoResourcePath = ensureKmsKeyExistsForTests( kmsStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME, KMS_KEY_TWO_NAME); }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(getHostname(), getPort()); builder.executor(getServerExecutor()); builder.usePlaintext().intercept(getTenantTokenInterceptor()).intercept(getJwtInterceptor()); if (isUseTracingInterceptor()) { builder.intercept(getTracingInterceptor()); } this.channel = builder.build(); this.blockingStub = createBlockingStub(); this.asyncStub = createAsyncStub(); }
public Node buildNode(String id) { String[] split = id.split(":"); Node node = new Node(id, split[0], Integer.parseInt(split[1])); node.setInBoundChannel(ManagedChannelBuilder.forAddress(node.getAddress(), node.getPort()) .compressorRegistry(CompressorRegistry.getDefaultInstance()).usePlaintext(true).build()); logger.info("New connection to:" + id); return node; }
ManagedChannelBuilder.forAddress(serviceAddress, port) .intercept(headerInterceptor) .intercept(metadataHandlerInterceptor) .userAgent(headerInterceptor.getUserAgentHeader()) .executor(executor); builder.maxInboundMetadataSize(maxInboundMetadataSize); builder.maxInboundMessageSize(maxInboundMessageSize); builder.keepAliveTime(keepAliveTime.toMillis(), TimeUnit.MILLISECONDS); builder.keepAliveTimeout(keepAliveTimeout.toMillis(), TimeUnit.MILLISECONDS); builder.keepAliveWithoutCalls(keepAliveWithoutCalls); builder.intercept(interceptorProvider.getInterceptors()); return builder.build();
builder.maxInboundMetadataSize(maxInboundMetadataSize); builder.maxInboundMessageSize(maxInboundMessageSize); builder.keepAliveTime(keepAliveTime.toMillis(), TimeUnit.MILLISECONDS); builder.keepAliveTimeout(keepAliveTimeout.toMillis(), TimeUnit.MILLISECONDS); builder.keepAliveWithoutCalls(keepAliveWithoutCalls); builder.intercept(interceptorProvider.getInterceptors()); return builder.build();
/** * @deprecated use {@link #usePlaintext()} instead. */ @Override @Deprecated public T usePlaintext(boolean skipNegotiation) { delegate().usePlaintext(skipNegotiation); return thisT(); }