Skip to content

Commit

Permalink
Add TODOs
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jan 3, 2024
1 parent 448c6e5 commit 0327a84
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ public class ChannelHandler {

/** Open a new channel for a new client. */
public ChannelHandler(CallbackDispatcher callbackDispatcher, String socketPath) {
// TODO: add the ability to pass in group and channel from user
channel =
new Bootstrap()
// TODO let user specify the thread pool or pool size as an option
.group(ThreadPoolAllocator.createNettyThreadPool(THREAD_POOL_NAME, Optional.empty()))
.group(
ThreadPoolAllocator.createOrGetNettyThreadPool(THREAD_POOL_NAME, Optional.empty()))
.channel(Platform.getClientUdsNettyChannelType())
.handler(new ProtobufSocketChannelInitializer(callbackDispatcher))
.connect(new DomainSocketAddress(socketPath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class ThreadPoolAllocator {
*
* @return A new thread pool.
*/
public static EventLoopGroup createNettyThreadPool(String prefix, Optional<Integer> threadLimit) {
public static EventLoopGroup createOrGetNettyThreadPool(
String prefix, Optional<Integer> threadLimit) {
int threadCount = threadLimit.orElse(Runtime.getRuntime().availableProcessors());
if (Platform.getCapabilities().isKQueueAvailable()) {
String name = prefix + "-kqueue-elg";
Expand Down
5 changes: 3 additions & 2 deletions java/client/src/main/java/glide/managers/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,20 @@ private CompletableFuture<String> submitNewRequest(RequestType command, List<Str
*/
private String extractValueFromGlideRsResponse(Response response) {
if (response.hasRequestError()) {
// TODO do we need to support different types of exceptions and distinguish them by type?
// TODO we need to support different types of exceptions and distinguish them by type
throw new RuntimeException(
String.format(
"%s: %s",
response.getRequestError().getType(), response.getRequestError().getMessage()));
} else if (response.hasClosingError()) {
// TODO: close the channel on closingError

This comment has been minimized.

Copy link
@Yury-Fridlyand

Yury-Fridlyand Jan 6, 2024

Collaborator

Is this todo already completed on the next line?

CompletableFuture.runAsync(channel::close);
throw new RuntimeException("Connection closed: " + response.getClosingError());
} else if (response.hasConstantResponse()) {
return response.getConstantResponse().toString();
} else if (response.hasRespPointer()) {
return RedisValueResolver.valueFromPointer(response.getRespPointer()).toString();
}
return "OK";
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CompletableFuture<Void> connectToRedis(
/** Check a response received from Glide. */
private Void checkGlideRsResponse(Response response) {
if (response.hasRequestError()) {
// TODO do we need to support different types of exceptions and distinguish them by type?
// TODO unexpected when establishing a connection
throw new RuntimeException(
String.format(
"%s: %s",
Expand Down

0 comments on commit 0327a84

Please sign in to comment.