Skip to content

Commit

Permalink
[SDCISA-15833, swisspost#170] Fix some todos.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddenalpha committed May 24, 2024
1 parent cda08f9 commit 53a830c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/swisspush/redisques/QueueStatsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.swisspush.redisques.exception.RedisQuesExceptionFactory;
import org.swisspush.redisques.exception.NoStacktraceException;
import org.swisspush.redisques.util.DequeueStatistic;
import org.swisspush.redisques.util.DequeueStatisticCollector;
import org.swisspush.redisques.util.QueueStatisticsCollector;
Expand All @@ -20,6 +19,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;

import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE;
import static java.lang.Long.compare;
import static java.lang.System.currentTimeMillis;
import static java.util.Collections.emptyList;
Expand Down Expand Up @@ -72,7 +72,8 @@ public QueueStatsService(

public <CTX> void getQueueStats(CTX mCtx, GetQueueStatsMentor<CTX> mentor) {
if (!incomingRequestQuota.tryAcquire()) {
var ex = new NoStacktraceException("Server too busy to handle yet-another-queue-stats-request now (error_bG8CAJJ3AgCKMwIAPBUC)");
Throwable ex = exceptionFactory.newReplyException(RECIPIENT_FAILURE, 429,
"Server too busy to handle yet-another-queue-stats-request now");
vertx.runOnContext(v -> mentor.onError(ex, mCtx));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,21 @@ public void handle(AsyncResult<Response> handleQueues) {
ctx.iter = ctx.queues.iterator();
var p = Promise.<Void>promise();
upperBoundParallel.request(redisRequestQuota, null, new UpperBoundParallel.Mentor<Void>() {
@Override public boolean runOneMore(BiConsumer<Throwable, Void> onDone, Void unused) {
/*TODO rename 'onDone' to 'onLlenDone' or similar*/
@Override public boolean runOneMore(BiConsumer<Throwable, Void> onLLenDone, Void unused) {
if (ctx.iter.hasNext()) {
String queue = ctx.iter.next();
int iNum = ctx.iNumberResult++;
ctx.redis.send(Request.cmd(Command.LLEN, queuesPrefix + queue)).onSuccess((Response rsp) -> {
ctx.queueLengths[iNum] = rsp.toInteger();
onDone.accept(null, null);
onLLenDone.accept(null, null);
}).onFailure((Throwable ex) -> {
onDone.accept(ex, null);
onLLenDone.accept(ex, null);
});
}
return ctx.iter.hasNext();
}
@Override public boolean onError(Throwable ex, Void ctx_) {
/*TODO use exceptionFactory*/
log.error("Unexpected queue length result", new Exception(ex));
log.error("Unexpected queue length result", exceptionFactory.newException(ex));
event.reply(new JsonObject().put(STATUS, ERROR));
return false;
}
Expand Down

0 comments on commit 53a830c

Please sign in to comment.