Class GrpcClientOptions
ClientOptions to control gRPC-specific behavior.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.linecorp.armeria.client.ClientOption<CallCredentials>Sets theCallCredentialsthat carries credential data that will be propagated to the server via request metadata.static final com.linecorp.armeria.client.ClientOption<Compressor>Sets theCompressorto use when compressing messages.static final com.linecorp.armeria.client.ClientOption<DecompressorRegistry>Sets theDecompressorRegistryto use when decompressing messages.static final com.linecorp.armeria.client.ClientOption<GrpcClientStubFactory>Sets theGrpcClientStubFactorythat creates a gRPC client stub.static final com.linecorp.armeria.client.ClientOption<Function<? super ServiceDescriptor,? extends GrpcJsonMarshaller>> Sets the factory that creates aGrpcJsonMarshallerthat serializes and deserializes request or response messages to and from JSON depending on theSerializationFormat.static final com.linecorp.armeria.client.ClientOption<Iterable<? extends ClientInterceptor>>Sets theClientInterceptors to the gRPC client stub.static final com.linecorp.armeria.client.ClientOption<Integer>The maximum size, in bytes, of messages coming in a response.static final com.linecorp.armeria.client.ClientOption<Integer>The maximum size, in bytes, of messages sent in a request.static final com.linecorp.armeria.client.ClientOption<Boolean>Enables unsafe retention of response buffers. -
Method Summary
-
Field Details
-
MAX_INBOUND_MESSAGE_SIZE_BYTES
public static final com.linecorp.armeria.client.ClientOption<Integer> MAX_INBOUND_MESSAGE_SIZE_BYTESThe maximum size, in bytes, of messages coming in a response. The default value is -1, which means 'useClientOptions.MAX_RESPONSE_LENGTH'. -
MAX_OUTBOUND_MESSAGE_SIZE_BYTES
public static final com.linecorp.armeria.client.ClientOption<Integer> MAX_OUTBOUND_MESSAGE_SIZE_BYTESThe maximum size, in bytes, of messages sent in a request. The default value is -1, which means unlimited. -
UNSAFE_WRAP_RESPONSE_BUFFERS
Enables unsafe retention of response buffers. Can improve performance when working with very large (i.e., several megabytes) payloads.DISCLAIMER: Do not use this if you don't know what you are doing. It is very easy to introduce memory leaks when using this method. You will probably spend much time debugging memory leaks during development if this is enabled. You will probably spend much time debugging memory leaks in production if this is enabled. You probably don't want to do this and should turn back now.
When enabled, the reference-counted buffer received from the server will be stored into
RequestContextinstead of being released. AllByteStringin a protobuf message will reference sections of this buffer instead of having their own copies. When done with a response message, callGrpcUnsafeBufferUtil.releaseBuffer(Object, RequestContext)with the message and the request's context to release the buffer. The message must be the same reference as what was passed to the client stub - a message with the same contents will not work. IfGrpcUnsafeBufferUtil.releaseBuffer(Object, RequestContext)is not called, the memory will be leaked.Note that this has no effect if the payloads are compressed or the
SerializationFormatisGrpcSerializationFormats.PROTO_WEB_TEXT. -
GRPC_JSON_MARSHALLER_FACTORY
public static final com.linecorp.armeria.client.ClientOption<Function<? super ServiceDescriptor,? extends GrpcJsonMarshaller>> GRPC_JSON_MARSHALLER_FACTORYSets the factory that creates aGrpcJsonMarshallerthat serializes and deserializes request or response messages to and from JSON depending on theSerializationFormat. The returnedGrpcJsonMarshallerfrom the factory replaces the built-inGrpcJsonMarshaller.This is commonly used to:
- Switch from the default of using lowerCamelCase for field names to using the field name from
the proto definition, by setting
MessageMarshaller.Builder.preservingProtoFieldNames(boolean)viaGrpcJsonMarshallerBuilder.jsonMarshallerCustomizer(Consumer).GrpcClients.builder(grpcServerUri) .jsonMarshallerFactory(serviceDescriptor -> { return GrpcJsonMarshaller.builder() .jsonMarshallerCustomizer(builder -> { builder.preservingProtoFieldNames(true); }) .build(serviceDescriptor); }) .build(); - Set a customer marshaller for non-
Messagetypes such asscalapb.GeneratedMessagefor Scala andpbandk.Messagefor Kotlin.
- Switch from the default of using lowerCamelCase for field names to using the field name from
the proto definition, by setting
-
GRPC_CLIENT_STUB_FACTORY
public static final com.linecorp.armeria.client.ClientOption<GrpcClientStubFactory> GRPC_CLIENT_STUB_FACTORYSets theGrpcClientStubFactorythat creates a gRPC client stub. If not specified, Armeria provides built-in factories for the following gRPC client stubs: -
INTERCEPTORS
public static final com.linecorp.armeria.client.ClientOption<Iterable<? extends ClientInterceptor>> INTERCEPTORSSets theClientInterceptors to the gRPC client stub. The specified interceptor(s) is/are executed in reverse order. -
COMPRESSOR
Sets theCompressorto use when compressing messages. If not set,Codec.Identity.NONEwill be used by default. -
DECOMPRESSOR_REGISTRY
public static final com.linecorp.armeria.client.ClientOption<DecompressorRegistry> DECOMPRESSOR_REGISTRYSets theDecompressorRegistryto use when decompressing messages. If not set, will use the default, which supports gzip only. -
CALL_CREDENTIALS
Sets theCallCredentialsthat carries credential data that will be propagated to the server via request metadata.
-