Skip to content

Commit

Permalink
Get before increment when getting a new callback id; add javadocs
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Dec 29, 2023
1 parent 74a6ce0 commit 6dcad76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public Pair<Integer, CompletableFuture<Response>> registerRequest() {
var future = new CompletableFuture<Response>();
Integer callbackId = freeRequestIds.poll();
if (callbackId == null) {
// on null, we have no available request ids available
// we can add
callbackId = nextAvailableRequestId.incrementAndGet();
// on null, we have no available request ids available in freeRequestIds
// instead, get the next available request from counter
callbackId = nextAvailableRequestId.getAndIncrement();
}
responses.put(callbackId, future);
return Pair.of(callbackId, future);
Expand Down
6 changes: 5 additions & 1 deletion java/client/src/main/java/glide/managers/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import redis_request.RedisRequestOuterClass.RequestType;
import response.ResponseOuterClass.Response;

/**
* Service responsible for submitting command requests to a socket channel handler
* and unpack responses from the same socket channel handler.
*/
@RequiredArgsConstructor
public class CommandManager {

Expand Down Expand Up @@ -53,7 +57,7 @@ private CompletableFuture<String> submitNewRequest(RequestType command, List<Str
* Check response and extract data from it.
*
* @param response A response received from rust core lib
* @return A String from the Redis RESP2 response, or Ok. Otherwise, returns null
* @return A String from the Redis response, or Ok. Otherwise, returns null
*/
private String extractValueFromGlideRsResponse(Response response) {
if (response.hasRequestError()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import response.ResponseOuterClass.ConstantResponse;
import response.ResponseOuterClass.Response;

/**
* Service responsible for submitting connection requests to a socket channel handler
* and unpack responses from the same socket channel handler.
*/
@RequiredArgsConstructor
public class ConnectionManager {

Expand Down

0 comments on commit 6dcad76

Please sign in to comment.