Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/main/java/io/lettuce/core/ConnectionBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,17 @@ public void configureBootstrap(boolean domainSocket,

SocketOptions.TcpUserTimeoutOptions tcpUserTimeoutOptions = options.getTcpUserTimeout();

boolean applied = false;
if (IOUringProvider.isAvailable()) {
IOUringProvider.applyTcpUserTimeout(bootstrap, tcpUserTimeoutOptions.getTcpUserTimeout());
applied = true;
} else if (io.lettuce.core.resource.EpollProvider.isAvailable()) {
EpollProvider.applyTcpUserTimeout(bootstrap, tcpUserTimeoutOptions.getTcpUserTimeout());
} else {
logger.warn("Cannot apply TCP User Timeout options to channel type " + channelClass.getName());
applied = true;
}

LettuceAssert.assertState(applied,
"TCP User Timeout options could not be applied. Native transports (io_uring or epoll) are required.");
}
}

Expand All @@ -291,17 +295,22 @@ public void configureBootstrap(boolean domainSocket,
if (options.isKeepAlive() && options.isExtendedKeepAlive()) {

SocketOptions.KeepAliveOptions keepAlive = options.getKeepAlive();
boolean applied = false;

if (IOUringProvider.isAvailable()) {
IOUringProvider.applyKeepAlive(bootstrap, keepAlive.getCount(), keepAlive.getIdle(), keepAlive.getInterval());
applied = true;
} else if (io.lettuce.core.resource.EpollProvider.isAvailable()) {
EpollProvider.applyKeepAlive(bootstrap, keepAlive.getCount(), keepAlive.getIdle(), keepAlive.getInterval());
applied = true;
} else if (ExtendedNioSocketOptions.isAvailable() && !KqueueProvider.isAvailable()) {
ExtendedNioSocketOptions.applyKeepAlive(bootstrap, keepAlive.getCount(), keepAlive.getIdle(),
keepAlive.getInterval());
} else {
logger.warn("Cannot apply extended TCP keepalive options to channel type " + channelClass.getName());
applied = true;
}

LettuceAssert.assertState(applied,
"Extended TCP keepalive options could not be applied. Native transports (io_uring or epoll) or a compatible NIO transport are required.");
}

}
Expand Down