Package reactor.netty.quic
Class QuicClient
java.lang.Object
reactor.netty.transport.Transport<T,CONF>
reactor.netty.quic.QuicClient
A QuicClient allows building in a safe immutable way a QUIC client that is materialized
and connecting when
connect() is ultimately called.
Example:
QuicClient.create()
.port(7777)
.bindAddress(() -> new InetSocketAddress(0))
.wiretap(true)
.secure(clientCtx)
.idleTimeout(Duration.ofSeconds(5))
.initialSettings(spec ->
spec.maxData(10000000)
.maxStreamDataBidirectionalLocal(1000000))
.connectNow();
- Author:
- Violeta Georgieva
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal QuicClientackDelayExponent(long ackDelayExponent) Set the delay exponent used for ACKs.final QuicClientactiveMigration(boolean enable) Enable/disable active migration.final QuicClientcongestionControlAlgorithm(QuicCongestionControlAlgorithm congestionControlAlgorithm) Set the congestion control algorithm to use.abstract Mono<? extends QuicConnection>connect()final QuicConnectionBlock theQuicClientand return aQuicConnection.final QuicConnectionconnectNow(Duration timeout) Block theQuicClientand return aQuicConnection.static QuicClientcreate()Prepare aQuicClient.final QuicClientdatagram(int recvQueueLen, int sendQueueLen) If configured this will enable Datagram support.final QuicClientdoOnBind(Consumer<? super QuicClientConfig> doOnBind) Set or add a callback called whenQuicTransportis about to start listening for incoming traffic.final QuicClientdoOnBound(Consumer<? super Connection> doOnBound) Set or add a callback called afterQuicTransporthas been started.final QuicClientdoOnConnect(Consumer<? super QuicClientConfig> doOnConnect) Set or add a callback called whenQuicClientis about to connect to the remote endpoint.final QuicClientdoOnConnected(Consumer<? super QuicConnection> doOnConnected) Set or add a callback called afterQuicConnectionhas been connected.final QuicClientdoOnDisconnected(Consumer<? super QuicConnection> doOnDisconnected) Set or add a callback called afterQuicConnectionhas been disconnected.final QuicClientdoOnUnbound(Consumer<? super Connection> doOnUnbound) Set or add a callback called afterQuicTransporthas been shutdown.final QuicClientgrease(boolean enable) Set if greasing should be enabled or not.final QuicClienthandleStream(BiFunction<? super QuicInbound, ? super QuicOutbound, ? extends Publisher<Void>> streamHandler) Attach an IO handler to react on incoming stream.final QuicClientThe host to which this client should connect.final QuicClienthystart(boolean enable) Enable/disable Hystart.final QuicClientidleTimeout(Duration idleTimeout) Set the maximum idle timeout (resolution: ms) See set_max_idle_timeout.final QuicClientinitialSettings(Consumer<QuicInitialSettingsSpec.Builder> initialSettings) Configure QUIC initial settings.final QuicClientlocalConnectionIdLength(int localConnectionIdLength) Sets the local connection id length that is used.final QuicClientmaxAckDelay(Duration maxAckDelay) Set max ACK delay (resolution: ms).final QuicClientmaxRecvUdpPayloadSize(long maxRecvUdpPayloadSize) final QuicClientmaxSendUdpPayloadSize(long maxSendUdpPayloadSize) final QuicClientport(int port) The port to which this client should connect.final QuicClientremoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier) The address to which this client should connect on each subscribe.final QuicClientsecure(QuicSslContext sslContext) final QuicClientsecure(Function<QuicChannel, ? extends QuicSslEngine> sslEngineProvider) final <A> QuicClientstreamAttr(AttributeKey<A> key, @Nullable A value) Injects default attribute to the futureQuicStreamChannel.streamObserve(ConnectionObserver observer) Set or add the givenConnectionObserverfor each stream.final <A> QuicClientstreamOption(ChannelOption<A> key, @Nullable A value) Injects default options to the futureQuicStreamChannel.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
-
QuicClient
public QuicClient()
-
-
Method Details
-
create
Prepare aQuicClient.- Returns:
- a
QuicClient
-
connect
Connect theQuicClientand return aMonoofQuicConnection. IfMonois cancelled, the underlying connection will be aborted. Once theQuicConnectionhas been emitted and is not necessary anymore, disposing must be done by the user viaDisposableChannel.dispose().- Returns:
- a
MonoofQuicConnection
-
connectNow
Block theQuicClientand return aQuicConnection. Disposing must be done by the user viaDisposableChannel.dispose(). The max connection timeout is 45 seconds.- Returns:
- a
QuicConnection
-
connectNow
Block theQuicClientand return aQuicConnection. Disposing must be done by the user viaDisposableChannel.dispose().- Parameters:
timeout- connect timeout (resolution: ns)- Returns:
- a
QuicConnection
-
doOnConnect
Set or add a callback called whenQuicClientis about to connect to the remote endpoint.- Parameters:
doOnConnect- a consumer observing connect events- Returns:
- a
QuicClientreference
-
doOnConnected
Set or add a callback called afterQuicConnectionhas been connected.- Parameters:
doOnConnected- a consumer observing connected events- Returns:
- a
QuicClientreference
-
doOnDisconnected
Set or add a callback called afterQuicConnectionhas been disconnected.- Parameters:
doOnDisconnected- a consumer observing disconnected events- Returns:
- a
QuicClientreference
-
host
The host to which this client should connect.- Parameters:
host- the host to connect to- Returns:
- a
QuicClientreference
-
port
The port to which this client should connect. If a port is not specified, the default port12012is used.Note: The port can be specified also with
QUIC_PORTenvironment variable.- Parameters:
port- the port to connect to- Returns:
- a
QuicClientreference
-
remoteAddress
The address to which this client should connect on each subscribe.- Parameters:
remoteAddressSupplier- A supplier of the address to connect to.- Returns:
- a
QuicClient
-
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 QuicClient 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 QuicClient 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
-