io.grpc.protobuf.lite.ProtoLiteUtils#io.grpc.ExperimentalApi源码实例Demo

下面列出了io.grpc.protobuf.lite.ProtoLiteUtils#io.grpc.ExperimentalApi 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: grpc-nebula-java   文件: GrpcSslContexts.java
/**
 * Set ciphers and APN appropriate for gRPC. Precisely what is set is permitted to change, so if
 * an application requires particular settings it should override the options set here.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1784")
@CanIgnoreReturnValue
public static SslContextBuilder configure(SslContextBuilder builder, SslProvider provider) {
  switch (provider) {
    case JDK:
    {
      Provider jdkProvider = findJdkProvider();
      if (jdkProvider == null) {
        throw new IllegalArgumentException(
            "Could not find Jetty NPN/ALPN or Conscrypt as installed JDK providers");
      }
      return configure(builder, jdkProvider);
    }
    case OPENSSL:
    {
      ApplicationProtocolConfig apc;
      if (OpenSsl.isAlpnSupported()) {
        apc = NPN_AND_ALPN;
      } else {
        apc = NPN;
      }
      return builder
          .sslProvider(SslProvider.OPENSSL)
          .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
          .applicationProtocolConfig(apc);
    }
    default:
      throw new IllegalArgumentException("Unsupported provider: " + provider);
  }
}
 
源代码2 项目: grpc-nebula-java   文件: TestMethodDescriptors.java
/**
 * Creates a new method descriptor that always creates zero length messages, and always parses to
 * null objects.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2600")
public static MethodDescriptor<Void, Void> voidMethod() {
  return MethodDescriptor.<Void, Void>newBuilder()
      .setType(MethodType.UNARY)
      .setFullMethodName(MethodDescriptor.generateFullMethodName("service_foo", "method_bar"))
      .setRequestMarshaller(TestMethodDescriptors.voidMarshaller())
      .setResponseMarshaller(TestMethodDescriptors.voidMarshaller())
      .build();
}
 
源代码3 项目: rapid   文件: Cluster.java
/**
 * Set static application-specific metadata that is associated with the node being instantiated.
 * This may include tags like "role":"frontend".
 *
 * @param metadata A map specifying a set of key-value tags.
 */
@ExperimentalApi
public Builder setMetadata(final Map<String, ByteString> metadata) {
    Objects.requireNonNull(metadata);
    this.metadata = Metadata.newBuilder().putAllMetadata(metadata).build();
    return this;
}
 
源代码4 项目: rapid   文件: Cluster.java
/**
 * Set a link failure detector to use for observers to watch their subjects.
 *
 * @param edgeFailureDetector A link failure detector used as input for Rapid's failure detection.
 */
@ExperimentalApi
public Builder setEdgeFailureDetectorFactory(final IEdgeFailureDetectorFactory edgeFailureDetector) {
    Objects.requireNonNull(edgeFailureDetector);
    this.edgeFailureDetector = edgeFailureDetector;
    return this;
}
 
源代码5 项目: rapid   文件: Cluster.java
/**
 * This is used to register subscriptions for different events
 */
@ExperimentalApi
public Builder addSubscription(final ClusterEvents event,
                               final BiConsumer<Long, List<NodeStatusChange>> callback) {
    this.subscriptions.computeIfAbsent(event, k -> new ArrayList<>());
    this.subscriptions.get(event).add(callback);
    return this;
}
 
源代码6 项目: grpc-java   文件: GrpcSslContexts.java
/**
 * Set ciphers and APN appropriate for gRPC. Precisely what is set is permitted to change, so if
 * an application requires particular settings it should override the options set here.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1784")
@CanIgnoreReturnValue
public static SslContextBuilder configure(SslContextBuilder builder, SslProvider provider) {
  switch (provider) {
    case JDK:
    {
      Provider jdkProvider = findJdkProvider();
      if (jdkProvider == null) {
        throw new IllegalArgumentException(
            "Could not find Jetty NPN/ALPN or Conscrypt as installed JDK providers");
      }
      return configure(builder, jdkProvider);
    }
    case OPENSSL:
    {
      ApplicationProtocolConfig apc;
      if (OpenSsl.isAlpnSupported()) {
        apc = NPN_AND_ALPN;
      } else {
        apc = NPN;
      }
      return builder
          .sslProvider(SslProvider.OPENSSL)
          .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
          .applicationProtocolConfig(apc);
    }
    default:
      throw new IllegalArgumentException("Unsupported provider: " + provider);
  }
}
 
源代码7 项目: grpc-java   文件: TestMethodDescriptors.java
/**
 * Creates a new method descriptor that always creates zero length messages, and always parses to
 * null objects.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2600")
public static MethodDescriptor<Void, Void> voidMethod() {
  return MethodDescriptor.<Void, Void>newBuilder()
      .setType(MethodType.UNARY)
      .setFullMethodName(MethodDescriptor.generateFullMethodName("service_foo", "method_bar"))
      .setRequestMarshaller(TestMethodDescriptors.voidMarshaller())
      .setResponseMarshaller(TestMethodDescriptors.voidMarshaller())
      .build();
}
 
源代码8 项目: grpc-nebula-java   文件: MutableHandlerRegistry.java
/**
 *  Note: This does not necessarily return a consistent view of the map.
 */
@Override
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222")
public List<ServerServiceDefinition> getServices() {
  return Collections.unmodifiableList(new ArrayList<>(services.values()));
}
 
源代码9 项目: grpc-java   文件: AndroidChannelBuilder.java
/**
 * Creates a new builder, which delegates to the given ManagedChannelBuilder.
 *
 * @deprecated Use {@link #usingBuilder(ManagedChannelBuilder)} instead.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/6043")
@Deprecated
public static AndroidChannelBuilder fromBuilder(ManagedChannelBuilder<?> builder) {
  return usingBuilder(builder);
}
 
源代码10 项目: grpc-java   文件: MutableHandlerRegistry.java
/**
 *  Note: This does not necessarily return a consistent view of the map.
 */
@Override
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222")
public List<ServerServiceDefinition> getServices() {
  return Collections.unmodifiableList(new ArrayList<>(services.values()));
}
 
源代码11 项目: grpc-nebula-java   文件: MetadataUtils.java
/**
 * Captures the last received metadata for a stub. Useful for testing
 *
 * @param stub to capture for
 * @param headersCapture to record the last received headers
 * @param trailersCapture to record the last received trailers
 * @return an implementation of the stub that allows to access the last received call's
 *         headers and trailers via {@code headersCapture} and {@code trailersCapture}.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789")
public static <T extends AbstractStub<T>> T captureMetadata(
    T stub,
    AtomicReference<Metadata> headersCapture,
    AtomicReference<Metadata> trailersCapture) {
  return stub.withInterceptors(
      newCaptureMetadataInterceptor(headersCapture, trailersCapture));
}
 
源代码12 项目: grpc-java   文件: MetadataUtils.java
/**
 * Captures the last received metadata for a stub. Useful for testing
 *
 * @param stub to capture for
 * @param headersCapture to record the last received headers
 * @param trailersCapture to record the last received trailers
 * @return an implementation of the stub that allows to access the last received call's
 *         headers and trailers via {@code headersCapture} and {@code trailersCapture}.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789")
public static <T extends AbstractStub<T>> T captureMetadata(
    T stub,
    AtomicReference<Metadata> headersCapture,
    AtomicReference<Metadata> trailersCapture) {
  return stub.withInterceptors(
      newCaptureMetadataInterceptor(headersCapture, trailersCapture));
}
 
源代码13 项目: grpc-nebula-java   文件: ProtoUtils.java
/**
 * Sets the global registry for proto marshalling shared across all servers and clients.
 *
 * <p>Warning:  This API will likely change over time.  It is not possible to have separate
 * registries per Process, Server, Channel, Service, or Method.  This is intentional until there
 * is a more appropriate API to set them.
 *
 * <p>Warning:  Do NOT modify the extension registry after setting it.  It is thread safe to call
 * {@link #setExtensionRegistry}, but not to modify the underlying object.
 *
 * <p>If you need custom parsing behavior for protos, you will need to make your own
 * {@code MethodDescriptor.Marshaller} for the time being.
 *
 * @since 1.16.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1787")
public static void setExtensionRegistry(ExtensionRegistry registry) {
  ProtoLiteUtils.setExtensionRegistry(registry);
}
 
源代码14 项目: grpc-nebula-java   文件: ProtoUtils.java
/**
 * Produce a metadata marshaller for a protobuf type.
 * 
 * @since 1.13.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4477")
public static <T extends Message> Metadata.BinaryMarshaller<T> metadataMarshaller(T instance) {
  return ProtoLiteUtils.metadataMarshaller(instance);
}
 
源代码15 项目: grpc-nebula-java   文件: ProtoLiteUtils.java
/**
 * Sets the global registry for proto marshalling shared across all servers and clients.
 *
 * <p>Warning:  This API will likely change over time.  It is not possible to have separate
 * registries per Process, Server, Channel, Service, or Method.  This is intentional until there
 * is a more appropriate API to set them.
 *
 * <p>Warning:  Do NOT modify the extension registry after setting it.  It is thread safe to call
 * {@link #setExtensionRegistry}, but not to modify the underlying object.
 *
 * <p>If you need custom parsing behavior for protos, you will need to make your own
 * {@code MethodDescriptor.Marshaller} for the time being.
 *
 * @since 1.0.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1787")
public static void setExtensionRegistry(ExtensionRegistryLite newRegistry) {
  globalRegistry = checkNotNull(newRegistry, "newRegistry");
}
 
源代码16 项目: grpc-nebula-java   文件: TestMethodDescriptors.java
/**
 * Creates a new marshaller that does nothing.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2600")
public static MethodDescriptor.Marshaller<Void> voidMarshaller() {
  return new NoopMarshaller();
}
 
源代码17 项目: grpc-nebula-java   文件: MetadataUtils.java
/**
 * Attaches a set of request headers to a stub.
 *
 * @param stub to bind the headers to.
 * @param extraHeaders the headers to be passed by each call on the returned stub.
 * @return an implementation of the stub with {@code extraHeaders} bound to each call.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789")
public static <T extends AbstractStub<T>> T attachHeaders(T stub, Metadata extraHeaders) {
  return stub.withInterceptors(newAttachHeadersInterceptor(extraHeaders));
}
 
源代码18 项目: grpc-nebula-java   文件: AbstractStub.java
/**
 *  Set's the compressor name to use for the call.  It is the responsibility of the application
 *  to make sure the server supports decoding the compressor picked by the client.  To be clear,
 *  this is the compressor used by the stub to compress messages to the server.  To get
 *  compressed responses from the server, set the appropriate {@link io.grpc.DecompressorRegistry}
 *  on the {@link io.grpc.ManagedChannelBuilder}.
 *
 * @since 1.0.0
 * @param compressorName the name (e.g. "gzip") of the compressor to use.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
public final S withCompression(String compressorName) {
  return build(channel, callOptions.withCompression(compressorName));
}
 
源代码19 项目: grpc-nebula-java   文件: AbstractStub.java
/**
 * Sets a custom option to be passed to client interceptors on the channel
 * {@link io.grpc.ClientInterceptor} via the CallOptions parameter.
 *
 * @since 1.0.0
 * @param key the option being set
 * @param value the value for the key
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869")
public final <T> S withOption(CallOptions.Key<T> key, T value) {
  return build(channel, callOptions.withOption(key, value));
}
 
源代码20 项目: grpc-nebula-java   文件: AbstractStub.java
/**
 * Returns a new stub that limits the maximum acceptable message size from a remote peer.
 *
 * <p>If unset, the {@link ManagedChannelBuilder#maxInboundMessageSize(int)} limit is used.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563")
public final S withMaxInboundMessageSize(int maxSize) {
  return build(channel, callOptions.withMaxInboundMessageSize(maxSize));
}
 
源代码21 项目: grpc-nebula-java   文件: AbstractStub.java
/**
 * Returns a new stub that limits the maximum acceptable message size to send a remote peer.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563")
public final S withMaxOutboundMessageSize(int maxSize) {
  return build(channel, callOptions.withMaxOutboundMessageSize(maxSize));
}
 
源代码22 项目: grpc-java   文件: ProtoUtils.java
/**
 * Sets the global registry for proto marshalling shared across all servers and clients.
 *
 * <p>Warning:  This API will likely change over time.  It is not possible to have separate
 * registries per Process, Server, Channel, Service, or Method.  This is intentional until there
 * is a more appropriate API to set them.
 *
 * <p>Warning:  Do NOT modify the extension registry after setting it.  It is thread safe to call
 * {@link #setExtensionRegistry}, but not to modify the underlying object.
 *
 * <p>If you need custom parsing behavior for protos, you will need to make your own
 * {@code MethodDescriptor.Marshaller} for the time being.
 *
 * @since 1.16.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1787")
public static void setExtensionRegistry(ExtensionRegistry registry) {
  ProtoLiteUtils.setExtensionRegistry(registry);
}
 
源代码23 项目: grpc-java   文件: ProtoUtils.java
/**
 * Produce a metadata marshaller for a protobuf type.
 * 
 * @since 1.13.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4477")
public static <T extends Message> Metadata.BinaryMarshaller<T> metadataMarshaller(T instance) {
  return ProtoLiteUtils.metadataMarshaller(instance);
}
 
源代码24 项目: grpc-java   文件: ProtoLiteUtils.java
/**
 * Sets the global registry for proto marshalling shared across all servers and clients.
 *
 * <p>Warning:  This API will likely change over time.  It is not possible to have separate
 * registries per Process, Server, Channel, Service, or Method.  This is intentional until there
 * is a more appropriate API to set them.
 *
 * <p>Warning:  Do NOT modify the extension registry after setting it.  It is thread safe to call
 * {@link #setExtensionRegistry}, but not to modify the underlying object.
 *
 * <p>If you need custom parsing behavior for protos, you will need to make your own
 * {@code MethodDescriptor.Marshaller} for the time being.
 *
 * @since 1.0.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1787")
public static void setExtensionRegistry(ExtensionRegistryLite newRegistry) {
  globalRegistry = checkNotNull(newRegistry, "newRegistry");
}
 
源代码25 项目: grpc-java   文件: TestMethodDescriptors.java
/**
 * Creates a new marshaller that does nothing.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2600")
public static MethodDescriptor.Marshaller<Void> voidMarshaller() {
  return new NoopMarshaller();
}
 
源代码26 项目: grpc-java   文件: MetadataUtils.java
/**
 * Attaches a set of request headers to a stub.
 *
 * @param stub to bind the headers to.
 * @param extraHeaders the headers to be passed by each call on the returned stub.
 * @return an implementation of the stub with {@code extraHeaders} bound to each call.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789")
public static <T extends AbstractStub<T>> T attachHeaders(T stub, Metadata extraHeaders) {
  return stub.withInterceptors(newAttachHeadersInterceptor(extraHeaders));
}
 
源代码27 项目: grpc-java   文件: AbstractStub.java
/**
 *  Set's the compressor name to use for the call.  It is the responsibility of the application
 *  to make sure the server supports decoding the compressor picked by the client.  To be clear,
 *  this is the compressor used by the stub to compress messages to the server.  To get
 *  compressed responses from the server, set the appropriate {@link io.grpc.DecompressorRegistry}
 *  on the {@link io.grpc.ManagedChannelBuilder}.
 *
 * @since 1.0.0
 * @param compressorName the name (e.g. "gzip") of the compressor to use.
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
public final S withCompression(String compressorName) {
  return build(channel, callOptions.withCompression(compressorName));
}
 
源代码28 项目: grpc-java   文件: AbstractStub.java
/**
 * Sets a custom option to be passed to client interceptors on the channel
 * {@link io.grpc.ClientInterceptor} via the CallOptions parameter.
 *
 * @since 1.0.0
 * @param key the option being set
 * @param value the value for the key
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869")
public final <T> S withOption(CallOptions.Key<T> key, T value) {
  return build(channel, callOptions.withOption(key, value));
}
 
源代码29 项目: grpc-java   文件: AbstractStub.java
/**
 * Returns a new stub that limits the maximum acceptable message size from a remote peer.
 *
 * <p>If unset, the {@link ManagedChannelBuilder#maxInboundMessageSize(int)} limit is used.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563")
public final S withMaxInboundMessageSize(int maxSize) {
  return build(channel, callOptions.withMaxInboundMessageSize(maxSize));
}
 
源代码30 项目: grpc-java   文件: AbstractStub.java
/**
 * Returns a new stub that limits the maximum acceptable message size to send a remote peer.
 *
 * @since 1.1.0
 */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563")
public final S withMaxOutboundMessageSize(int maxSize) {
  return build(channel, callOptions.withMaxOutboundMessageSize(maxSize));
}