Package reactor.netty.quic
Class QuicServer
java.lang.Object
reactor.netty.transport.Transport<T,CONF>
reactor.netty.quic.QuicServer
A QuicServer allows building in a safe immutable way a QUIC server that is materialized
and bound when
bind() is ultimately called.
Example:
QuicServer.create()
.tokenHandler(InsecureQuicTokenHandler.INSTANCE)
.port(7777)
.wiretap(true)
.secure(serverCtx)
.idleTimeout(Duration.ofSeconds(5))
.initialSettings(spec ->
spec.maxData(10000000)
.maxStreamDataBidirectionalLocal(1000000)
.maxStreamDataBidirectionalRemote(1000000)
.maxStreamsBidirectional(100)
.maxStreamsUnidirectional(100))
.bindNow();
- Author:
- Violeta Georgieva
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal QuicServerackDelayExponent(long ackDelayExponent) Set the delay exponent used for ACKs.final QuicServeractiveMigration(boolean enable) Enable/disable active migration.abstract Mono<? extends Connection>bind()final ConnectionbindNow()Starts the server in a blocking fashion, and waits for it to finish initializing or the startup timeout expires (the startup timeout is45seconds).final ConnectionStart the server in a blocking fashion, and wait for it to finish initializing or the provided startup timeout expires.final QuicServercongestionControlAlgorithm(QuicCongestionControlAlgorithm congestionControlAlgorithm) Set the congestion control algorithm to use.final QuicServerconnectionIdAddressGenerator(QuicConnectionIdGenerator connectionIdAddressGenerator) Set theQuicConnectionIdGeneratorto use.static QuicServercreate()Prepare aQuicServer.final QuicServerdatagram(int recvQueueLen, int sendQueueLen) If configured this will enable Datagram support.final QuicServerdoOnBind(Consumer<? super QuicServerConfig> doOnBind) Set or add a callback called whenQuicTransportis about to start listening for incoming traffic.final QuicServerdoOnBound(Consumer<? super Connection> doOnBound) Set or add a callback called afterQuicTransporthas been started.final QuicServerdoOnConnection(Consumer<? super QuicConnection> doOnConnection) Set or add a callback called on new remoteQuicConnection.final QuicServerdoOnUnbound(Consumer<? super Connection> doOnUnbound) Set or add a callback called afterQuicTransporthas been shutdown.final QuicServergrease(boolean enable) Set if greasing should be enabled or not.final QuicServerhandleStream(BiFunction<? super QuicInbound, ? super QuicOutbound, ? extends Publisher<Void>> streamHandler) Attach an IO handler to react on incoming stream.final QuicServerThe host to which this server should bind.final QuicServerhystart(boolean enable) Enable/disable Hystart.final QuicServeridleTimeout(Duration idleTimeout) Set the maximum idle timeout (resolution: ms) See set_max_idle_timeout.final QuicServerinitialSettings(Consumer<QuicInitialSettingsSpec.Builder> initialSettings) Configure QUIC initial settings.final QuicServerlocalConnectionIdLength(int localConnectionIdLength) Sets the local connection id length that is used.final QuicServermaxAckDelay(Duration maxAckDelay) Set max ACK delay (resolution: ms).final QuicServermaxRecvUdpPayloadSize(long maxRecvUdpPayloadSize) final QuicServermaxSendUdpPayloadSize(long maxSendUdpPayloadSize) final QuicServerport(int port) The port to which this server should bind.final QuicServersecure(QuicSslContext sslContext) final QuicServersecure(Function<QuicChannel, ? extends QuicSslEngine> sslEngineProvider) final <A> QuicServerstreamAttr(AttributeKey<A> key, @Nullable A value) Injects default attribute to the futureQuicStreamChannel.streamObserve(ConnectionObserver observer) Set or add the givenConnectionObserverfor each stream.final <A> QuicServerstreamOption(ChannelOption<A> key, @Nullable A value) Injects default options to the futureQuicStreamChannel.final QuicServertokenHandler(QuicTokenHandler tokenHandler) Configure theQuicTokenHandlerthat is used to generate and validate tokens.warmup()Based on the actual configuration, returns aMonothat triggers: an initialization of the event loop group loads the necessary native libraries for the transport By default, when method is not used, thebind operationabsorbs the extra time needed to load resources.Methods inherited from class reactor.netty.transport.Transport
attr, bindAddress, channelGroup, configuration, doOnChannelInit, duplicate, metrics, metrics, observe, option, runOn, runOn, runOn, wiretap, wiretap, wiretap, wiretap, wiretap
-
Constructor Details
-
QuicServer
public QuicServer()
-
-
Method Details
-
create
Prepare aQuicServer.- Returns:
- a
QuicServer
-
bind
Binds theQuicServerand returns aMonoofConnection. IfMonois cancelled, the underlying binding will be aborted. Once theConnectionhas been emitted and is not necessary anymore, disposing the main server loop must be done by the user viaDisposableChannel.dispose().- Returns:
- a
MonoofConnection
-
bindNow
Starts the server in a blocking fashion, and waits for it to finish initializing or the startup timeout expires (the startup timeout is45seconds). The returnedConnectionoffers simple server API, including toDisposableChannel.disposeNow()shut it down in a blocking fashion.- Returns:
- a
Connection
-
bindNow
Start the server in a blocking fashion, and wait for it to finish initializing or the provided startup timeout expires. The returnedConnectionoffers simple server API, including toDisposableChannel.disposeNow()shut it down in a blocking fashion.- Parameters:
timeout- max startup timeout (resolution: ns)- Returns:
- a
Connection
-
connectionIdAddressGenerator
public final QuicServer connectionIdAddressGenerator(QuicConnectionIdGenerator connectionIdAddressGenerator) Set theQuicConnectionIdGeneratorto use. Default toQuicConnectionIdGenerator.randomGenerator().- Parameters:
connectionIdAddressGenerator- theQuicConnectionIdGeneratorto use.- Returns:
- a
QuicServerreference
-
doOnConnection
Set or add a callback called on new remoteQuicConnection.- Parameters:
doOnConnection- a consumer observing remote QUIC connections- Returns:
- a
QuicServerreference
-
host
The host to which this server should bind.- Parameters:
host- the host to bind to.- Returns:
- a
QuicServerreference
-
port
The port to which this server should bind. If a port is not specified, the system picks up an ephemeral port.- Parameters:
port- The port to bind to.- Returns:
- a
QuicServerreference
-
tokenHandler
Configure theQuicTokenHandlerthat is used to generate and validate tokens.- Parameters:
tokenHandler- theQuicTokenHandlerto use- Returns:
- a
QuicServer
-
ackDelayExponent
Set the delay exponent used for ACKs. See set_ack_delay_exponent. Default to 3.- Parameters:
ackDelayExponent- the delay exponent used for ACKs.- Returns:
- a
QuicTransportreference
-
activeMigration
Enable/disable active migration. See set_disable_active_migration. Default totrue.- Parameters:
enable-trueif migration should be enabled,falseotherwise- Returns:
- a
QuicTransportreference
-
congestionControlAlgorithm
public final QuicServer congestionControlAlgorithm(QuicCongestionControlAlgorithm congestionControlAlgorithm) Set the congestion control algorithm to use. Default toQuicCongestionControlAlgorithm.CUBIC.- Parameters:
congestionControlAlgorithm- theQuicCongestionControlAlgorithmto use.- Returns:
- a
QuicTransportreference
-
datagram
If configured this will enable Datagram support.- Parameters:
recvQueueLen- the RECV queue length.sendQueueLen- the SEND queue length.- Returns:
- a
QuicTransportreference
-
doOnBind
Set or add a callback called whenQuicTransportis about to start listening for incoming traffic.- Parameters:
doOnBind- a consumer observing connected events- Returns:
- a
QuicTransportreference
-
doOnBound
Set or add a callback called afterQuicTransporthas been started.- Parameters:
doOnBound- a consumer observing connected events- Returns:
- a
QuicTransportreference
-
doOnUnbound
Set or add a callback called afterQuicTransporthas been shutdown.- Parameters:
doOnUnbound- a consumer observing unbound events- Returns:
- a
QuicTransportreference
-
grease
Set if greasing should be enabled or not. Default totrue.- Parameters:
enable-trueif enabled,falseotherwise.- Returns:
- a
QuicTransportreference
-
handleStream
public final QuicServer handleStream(BiFunction<? super QuicInbound, ? super QuicOutbound, ? extends Publisher<Void>> streamHandler) Attach an IO handler to react on incoming stream.Note: If an IO handler is not specified the incoming streams will be closed automatically.
- Parameters:
streamHandler- an IO handler that can dispose underlying connection whenPublisherterminates.- Returns:
- a
QuicTransportreference
-
hystart
Enable/disable Hystart. See enable_hystart. Default totrue.- Parameters:
enable-trueif Hystart should be enabled- Returns:
- a
QuicTransportreference
-
idleTimeout
Set the maximum idle timeout (resolution: ms) See set_max_idle_timeout.By default
idleTimeoutis not specified.- Parameters:
idleTimeout- the maximum idle timeout (resolution: ms)- Returns:
- a
QuicTransportreference
-
initialSettings
Configure QUIC initial settings.- Parameters:
initialSettings- configures QUIC initial settings- Returns:
- a
QuicTransportreference
-
localConnectionIdLength
Sets the local connection id length that is used. Default 20, which is also the maximum that is supported.- Parameters:
localConnectionIdLength- the length of local generated connections ids- Returns:
- a
QuicTransportreference
-
maxAckDelay
Set max ACK delay (resolution: ms). See set_max_ack_delay. Default to 25 ms.- Parameters:
maxAckDelay- the max ACK delay (resolution: ms)- Returns:
- a
QuicTransportreference
-
maxRecvUdpPayloadSize
See set_max_recv_udp_payload_size. The default value is 65527.- Parameters:
maxRecvUdpPayloadSize- the maximum payload size that is advertised to the remote peer.- Returns:
- a
QuicTransportreference
-
maxSendUdpPayloadSize
See set_max_send_udp_payload_size. The default and minimum value is 1200.- Parameters:
maxSendUdpPayloadSize- the maximum payload size that is advertised to the remote peer.- Returns:
- a
QuicTransportreference
-
secure
- Parameters:
sslContext- theQuicSslContext- Returns:
- a
QuicTransportreference
-
secure
- Parameters:
sslEngineProvider- theFunctionthat will return theQuicSslEnginethat should be used for theQuicChannel- Returns:
- a
QuicTransportreference
-
streamAttr
Injects default attribute to the futureQuicStreamChannel. It will be available viaAttributeMap.attr(AttributeKey). If thevalueisnull, the attribute of the specifiedkeyis removed.- Type Parameters:
A- the attribute type- Parameters:
key- the attribute keyvalue- the attribute value - null to remove a key- Returns:
- a
QuicTransportreference - See Also:
-
streamObserve
Set or add the givenConnectionObserverfor each stream.- Parameters:
observer- theConnectionObserveraddition- Returns:
- a
QuicTransportreference
-
streamOption
Injects default options to the futureQuicStreamChannel. It will be available viaQuicStreamChannel.config(). If thevalueisnull, the attribute of the specifiedkeyis removed.- Type Parameters:
A- the option type- Parameters:
key- the option keyvalue- the option value - null to remove a key- Returns:
- a
QuicTransportreference - See Also:
-
warmup
Based on the actual configuration, returns aMonothat triggers:- an initialization of the event loop group
- loads the necessary native libraries for the transport
bind operationabsorbs the extra time needed to load resources.- Returns:
- a
Monorepresenting the completion of the warmup
-