Class GrpcServerOptions
java.lang.Object
io.vertx.grpc.server.GrpcServerOptions
Configuration for a
GrpcServer.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<WireFormat> The default set of enabled wire formats =[PROTOBUF, JSON]static final Set<GrpcProtocol> The default set of enabled protocols =[HTTP/2, TRANSCODING, WEB, WEB_TEXT]static final JsonReaderConfigstatic final JsonWriterConfigstatic final longThe default maximum message size in bytes accepted from a client =256KBstatic final booleanWhether the server propagates a deadline, by default =falsestatic final booleanWhether the server schedule deadline automatically when a request carrying a timeout is received, by default =false -
Constructor Summary
ConstructorsConstructorDescriptionDefault options.GrpcServerOptions(JsonObject json) Creates options from JSON.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddEnabledFormat(WireFormat format) Enables a wire format.addEnabledProtocol(GrpcProtocol protocol) Adds a gRPC protocol to the list of enabled protocols for the server.booleanRetrieves the set of gRPC protocols that are currently enabled for the server.longbooleanbooleanisProtocolEnabled(GrpcProtocol protocol) Determines if the specified gRPC protocol is enabled in the current server configuration.removeEnabledFormat(WireFormat format) Removes the specified wire format from the set of enabled formats.removeEnabledProtocol(GrpcProtocol protocol) Removes the specified gRPC protocol from the set of enabled protocols.setDeadlinePropagation(boolean deadlinePropagation) Set whether the server propagate deadlines toio.vertx.grpc.client.GrpcClientRequest.setJsonReaderConfig(JsonReaderConfig jsonReaderConfig) Configures the json input format parsed by the server, either forapplication/grpc+jsonorapplication/jsonsetJsonWriterConfig(JsonWriterConfig jsonWriterConfig) Configures the json output format emitted by the server, either forapplication/grpc+jsonorapplication/jsonsetMaxMessageSize(long maxMessageSize) Set the maximum message size in bytes accepted from a client, the maximum value is0xFFFFFFFFsetScheduleDeadlineAutomatically(boolean scheduleDeadlineAutomatically) Set whether a deadline is automatically scheduled when a request carrying a timeout is received.toJson()toString()
-
Field Details
-
DEFAULT_ENABLED_PROTOCOLS
The default set of enabled protocols =[HTTP/2, TRANSCODING, WEB, WEB_TEXT] -
DEFAULT_ENABLED_FORMATS
The default set of enabled wire formats =[PROTOBUF, JSON] -
DEFAULT_SCHEDULE_DEADLINE_AUTOMATICALLY
public static final boolean DEFAULT_SCHEDULE_DEADLINE_AUTOMATICALLYWhether the server schedule deadline automatically when a request carrying a timeout is received, by default =false- See Also:
-
DEFAULT_PROPAGATE_DEADLINE
public static final boolean DEFAULT_PROPAGATE_DEADLINEWhether the server propagates a deadline, by default =false- See Also:
-
DEFAULT_MAX_MESSAGE_SIZE
public static final long DEFAULT_MAX_MESSAGE_SIZEThe default maximum message size in bytes accepted from a client =256KB- See Also:
-
DEFAULT_JSON_READER_CONFIG_CONFIG
-
DEFAULT_JSON_WRITER_CONFIG_CONFIG
-
-
Constructor Details
-
GrpcServerOptions
public GrpcServerOptions()Default options. -
GrpcServerOptions
Copy constructor. -
GrpcServerOptions
Creates options from JSON.
-
-
Method Details
-
isProtocolEnabled
Determines if the specified gRPC protocol is enabled in the current server configuration.- Parameters:
protocol- the gRPC protocol to check- Returns:
- true if the protocol is enabled; false otherwise
-
getEnabledFormats
- Returns:
- the wire formats the server accepts on inbound calls. The set is mutable. Entries
compare by
, so it holds at most one instance per format name. The configured one wins.
invalid reference
WireFormat#canonicalName()
-
addEnabledProtocol
Adds a gRPC protocol to the list of enabled protocols for the server.- Parameters:
protocol- the gRPC protocol to enable- Returns:
- a reference to this GrpcServerOptions instance, allowing method chaining
-
removeEnabledProtocol
Removes the specified gRPC protocol from the set of enabled protocols.- Parameters:
protocol- the gRPC protocol to be removed- Returns:
- a reference to this, so the API can be used fluently
-
getEnabledProtocols
Retrieves the set of gRPC protocols that are currently enabled for the server.- Returns:
- a set of enabled gRPC protocols defined by
GrpcProtocol
-
getJsonReaderConfig
- Returns:
- the server json reader config
-
setJsonReaderConfig
Configures the json input format parsed by the server, either forapplication/grpc+jsonorapplication/json- Parameters:
jsonReaderConfig- the config- Returns:
- a reference to this, so the API can be used fluently
-
getJsonWriterConfig
- Returns:
- the server json writer config
-
setJsonWriterConfig
Configures the json output format emitted by the server, either forapplication/grpc+jsonorapplication/json- Parameters:
jsonWriterConfig- the config- Returns:
- a reference to this, so the API can be used fluently
-
addEnabledFormat
Enables a wire format. Equality is name-based, so adding a format with the same name replaces the previously configured instance.- Parameters:
format- the wire format to enable, must not be null- Returns:
- a reference to this, so the API can be used fluently
-
removeEnabledFormat
Removes the specified wire format from the set of enabled formats.- Parameters:
format- the wire format to remove- Returns:
- a reference to this, so the API can be used fluently
-
getScheduleDeadlineAutomatically
public boolean getScheduleDeadlineAutomatically()- Returns:
- whether the server will automatically schedule a deadline when a request carrying a timeout is received.
-
setScheduleDeadlineAutomatically
Set whether a deadline is automatically scheduled when a request carrying a timeout is received.
- When a deadline is automatically scheduled and a request carrying a timeout is received, a deadline (timer)
will be created to cancel the request when the response has not been timely sent. The deadline can be obtained
with
GrpcServerRequest.deadline(). - When the deadline is not set and a request carrying a timeout is received, the timeout is available with
GrpcServerRequest.timeout()and it is the responsibility of the service to eventually cancel the request. Note: the client might cancel the request as well when its local deadline is met.
- Parameters:
scheduleDeadlineAutomatically- whether to schedule a deadline automatically- Returns:
- a reference to this, so the API can be used fluently
- When a deadline is automatically scheduled and a request carrying a timeout is received, a deadline (timer)
will be created to cancel the request when the response has not been timely sent. The deadline can be obtained
with
-
getDeadlinePropagation
public boolean getDeadlinePropagation()- Returns:
- whether the server propagate deadlines to
io.vertx.grpc.client.GrpcClientRequest.
-
setDeadlinePropagation
Set whether the server propagate deadlines toio.vertx.grpc.client.GrpcClientRequest.- Parameters:
deadlinePropagation- the propagation setting- Returns:
- a reference to this, so the API can be used fluently
-
getMaxMessageSize
public long getMaxMessageSize()- Returns:
- the maximum message size in bytes accepted by the server
-
setMaxMessageSize
Set the maximum message size in bytes accepted from a client, the maximum value is0xFFFFFFFF- Parameters:
maxMessageSize- the size- Returns:
- a reference to this, so the API can be used fluently
-
toJson
- Returns:
- a JSON representation of options
-
toString
-