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 QuicServer
ackDelayExponent
(long ackDelayExponent) Set the delay exponent used for ACKs.final QuicServer
activeMigration
(boolean enable) Enable/disable active migration.abstract Mono<? extends Connection>
bind()
final Connection
bindNow()
Starts the server in a blocking fashion, and waits for it to finish initializing or the startup timeout expires (the startup timeout is45
seconds).final Connection
Start the server in a blocking fashion, and wait for it to finish initializing or the provided startup timeout expires.final QuicServer
congestionControlAlgorithm
(QuicCongestionControlAlgorithm congestionControlAlgorithm) Set the congestion control algorithm to use.final QuicServer
connectionIdAddressGenerator
(QuicConnectionIdGenerator connectionIdAddressGenerator) Set theQuicConnectionIdGenerator
to use.static QuicServer
create()
Prepare aQuicServer
.final QuicServer
datagram
(int recvQueueLen, int sendQueueLen) If configured this will enable Datagram support.final QuicServer
doOnBind
(Consumer<? super QuicServerConfig> doOnBind) Set or add a callback called whenQuicTransport
is about to start listening for incoming traffic.final QuicServer
doOnBound
(Consumer<? super Connection> doOnBound) Set or add a callback called afterQuicTransport
has been started.final QuicServer
doOnConnection
(Consumer<? super QuicConnection> doOnConnection) Set or add a callback called on new remoteQuicConnection
.final QuicServer
doOnUnbound
(Consumer<? super Connection> doOnUnbound) Set or add a callback called afterQuicTransport
has been shutdown.final QuicServer
grease
(boolean enable) Set if greasing should be enabled or not.final QuicServer
handleStream
(BiFunction<? super QuicInbound, ? super QuicOutbound, ? extends Publisher<Void>> streamHandler) Attach an IO handler to react on incoming stream.final QuicServer
The host to which this server should bind.final QuicServer
hystart
(boolean enable) Enable/disable Hystart.final QuicServer
idleTimeout
(Duration idleTimeout) Set the maximum idle timeout (resolution: ms) See set_max_idle_timeout.final QuicServer
initialSettings
(Consumer<QuicInitialSettingsSpec.Builder> initialSettings) Configure QUIC initial settings.final QuicServer
localConnectionIdLength
(int localConnectionIdLength) Sets the local connection id length that is used.final QuicServer
maxAckDelay
(Duration maxAckDelay) Set max ACK delay (resolution: ms).final QuicServer
maxRecvUdpPayloadSize
(long maxRecvUdpPayloadSize) final QuicServer
maxSendUdpPayloadSize
(long maxSendUdpPayloadSize) final QuicServer
port
(int port) The port to which this server should bind.final QuicServer
secure
(QuicSslContext sslContext) final QuicServer
secure
(Function<QuicChannel, ? extends QuicSslEngine> sslEngineProvider) final <A> QuicServer
streamAttr
(AttributeKey<A> key, @Nullable A value) Injects default attribute to the futureQuicStreamChannel
.streamObserve
(ConnectionObserver observer) Set or add the givenConnectionObserver
for each stream.final <A> QuicServer
streamOption
(ChannelOption<A> key, @Nullable A value) Injects default options to the futureQuicStreamChannel
.final QuicServer
tokenHandler
(QuicTokenHandler tokenHandler) Configure theQuicTokenHandler
that is used to generate and validate tokens.warmup()
Based on the actual configuration, returns aMono
that triggers: an initialization of the event loop group loads the necessary native libraries for the transport By default, when method is not used, thebind operation
absorbs 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 theQuicServer
and returns aMono
ofConnection
. IfMono
is cancelled, the underlying binding will be aborted. Once theConnection
has been emitted and is not necessary anymore, disposing the main server loop must be done by the user viaDisposableChannel.dispose()
.- Returns:
- a
Mono
ofConnection
-
bindNow
Starts the server in a blocking fashion, and waits for it to finish initializing or the startup timeout expires (the startup timeout is45
seconds). The returnedConnection
offers 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 returnedConnection
offers 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 theQuicConnectionIdGenerator
to use. Default toQuicConnectionIdGenerator.randomGenerator()
.- Parameters:
connectionIdAddressGenerator
- theQuicConnectionIdGenerator
to use.- Returns:
- a
QuicServer
reference
-
doOnConnection
Set or add a callback called on new remoteQuicConnection
.- Parameters:
doOnConnection
- a consumer observing remote QUIC connections- Returns:
- a
QuicServer
reference
-
host
The host to which this server should bind.- Parameters:
host
- the host to bind to.- Returns:
- a
QuicServer
reference
-
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
QuicServer
reference
-
tokenHandler
Configure theQuicTokenHandler
that is used to generate and validate tokens.- Parameters:
tokenHandler
- theQuicTokenHandler
to 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
QuicTransport
reference
-
activeMigration
Enable/disable active migration. See set_disable_active_migration. Default totrue
.- Parameters:
enable
-true
if migration should be enabled,false
otherwise- Returns:
- a
QuicTransport
reference
-
congestionControlAlgorithm
public final QuicServer congestionControlAlgorithm(QuicCongestionControlAlgorithm congestionControlAlgorithm) Set the congestion control algorithm to use. Default toQuicCongestionControlAlgorithm.CUBIC
.- Parameters:
congestionControlAlgorithm
- theQuicCongestionControlAlgorithm
to use.- Returns:
- a
QuicTransport
reference
-
datagram
If configured this will enable Datagram support.- Parameters:
recvQueueLen
- the RECV queue length.sendQueueLen
- the SEND queue length.- Returns:
- a
QuicTransport
reference
-
doOnBind
Set or add a callback called whenQuicTransport
is about to start listening for incoming traffic.- Parameters:
doOnBind
- a consumer observing connected events- Returns:
- a
QuicTransport
reference
-
doOnBound
Set or add a callback called afterQuicTransport
has been started.- Parameters:
doOnBound
- a consumer observing connected events- Returns:
- a
QuicTransport
reference
-
doOnUnbound
Set or add a callback called afterQuicTransport
has been shutdown.- Parameters:
doOnUnbound
- a consumer observing unbound events- Returns:
- a
QuicTransport
reference
-
grease
Set if greasing should be enabled or not. Default totrue
.- Parameters:
enable
-true
if enabled,false
otherwise.- Returns:
- a
QuicTransport
reference
-
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 whenPublisher
terminates.- Returns:
- a
QuicTransport
reference
-
hystart
Enable/disable Hystart. See enable_hystart. Default totrue
.- Parameters:
enable
-true
if Hystart should be enabled- Returns:
- a
QuicTransport
reference
-
idleTimeout
Set the maximum idle timeout (resolution: ms) See set_max_idle_timeout.By default
idleTimeout
is not specified.- Parameters:
idleTimeout
- the maximum idle timeout (resolution: ms)- Returns:
- a
QuicTransport
reference
-
initialSettings
Configure QUIC initial settings.- Parameters:
initialSettings
- configures QUIC initial settings- Returns:
- a
QuicTransport
reference
-
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
QuicTransport
reference
-
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
QuicTransport
reference
-
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
QuicTransport
reference
-
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
QuicTransport
reference
-
secure
- Parameters:
sslContext
- theQuicSslContext
- Returns:
- a
QuicTransport
reference
-
secure
- Parameters:
sslEngineProvider
- theFunction
that will return theQuicSslEngine
that should be used for theQuicChannel
- Returns:
- a
QuicTransport
reference
-
streamAttr
Injects default attribute to the futureQuicStreamChannel
. It will be available viaAttributeMap.attr(AttributeKey)
. If thevalue
isnull
, the attribute of the specifiedkey
is removed.- Type Parameters:
A
- the attribute type- Parameters:
key
- the attribute keyvalue
- the attribute value - null to remove a key- Returns:
- a
QuicTransport
reference - See Also:
-
streamObserve
Set or add the givenConnectionObserver
for each stream.- Parameters:
observer
- theConnectionObserver
addition- Returns:
- a
QuicTransport
reference
-
streamOption
Injects default options to the futureQuicStreamChannel
. It will be available viaQuicStreamChannel.config()
. If thevalue
isnull
, the attribute of the specifiedkey
is removed.- Type Parameters:
A
- the option type- Parameters:
key
- the option keyvalue
- the option value - null to remove a key- Returns:
- a
QuicTransport
reference - See Also:
-
warmup
Based on the actual configuration, returns aMono
that triggers:- an initialization of the event loop group
- loads the necessary native libraries for the transport
bind operation
absorbs the extra time needed to load resources.- Returns:
- a
Mono
representing the completion of the warmup
-