Class GrpcClientOptions
ClientOption
s to control gRPC-specific behavior.-
Field Summary
Modifier and TypeFieldDescriptionstatic final ClientOption<CallCredentials>
Sets theCallCredentials
that carries credential data that will be propagated to the server via request metadata.static final ClientOption<Compressor>
Sets theCompressor
to use when compressing messages.static final ClientOption<DecompressorRegistry>
Sets theDecompressorRegistry
to use when decompressing messages.static final ClientOption<GrpcClientStubFactory>
Sets theGrpcClientStubFactory
that creates a gRPC client stub.static final ClientOption<Function<? super ServiceDescriptor,
? extends GrpcJsonMarshaller>> Sets the factory that creates aGrpcJsonMarshaller
that serializes and deserializes request or response messages to and from JSON depending on theSerializationFormat
.static final ClientOption<Iterable<? extends ClientInterceptor>>
Sets theClientInterceptor
s to the gRPC client stub.static final ClientOption<Integer>
The maximum size, in bytes, of messages coming in a response.static final ClientOption<Integer>
The maximum size, in bytes, of messages sent in a request.static final ClientOption<Boolean>
Enables unsafe retention of response buffers. -
Method Summary
-
Field Details
-
MAX_INBOUND_MESSAGE_SIZE_BYTES
The 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
The 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
RequestContext
instead of being released. AllByteString
in 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
SerializationFormat
isGrpcSerializationFormats.PROTO_WEB_TEXT
. -
GRPC_JSON_MARSHALLER_FACTORY
public static final ClientOption<Function<? super ServiceDescriptor,? extends GrpcJsonMarshaller>> GRPC_JSON_MARSHALLER_FACTORYSets the factory that creates aGrpcJsonMarshaller
that serializes and deserializes request or response messages to and from JSON depending on theSerializationFormat
. The returnedGrpcJsonMarshaller
from 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-
Message
types such asscalapb.GeneratedMessage
for Scala andpbandk.Message
for 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
Sets theGrpcClientStubFactory
that creates a gRPC client stub. If not specified, Armeria provides built-in factories for the following gRPC client stubs: -
INTERCEPTORS
Sets theClientInterceptor
s to the gRPC client stub. The specified interceptor(s) is/are executed in reverse order. -
COMPRESSOR
Sets theCompressor
to use when compressing messages. If not set,Codec.Identity.NONE
will be used by default. -
DECOMPRESSOR_REGISTRY
Sets theDecompressorRegistry
to use when decompressing messages. If not set, will use the default, which supports gzip only. -
CALL_CREDENTIALS
Sets theCallCredentials
that carries credential data that will be propagated to the server via request metadata.
-