forked from swisspost/vertx-redisques
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge splitt-off changes back to feature from develop
OMG! What a conflict mess. Conflicts: src/main/java/org/swisspush/redisques/QueueStatsService.java src/main/java/org/swisspush/redisques/RedisQues.java src/main/java/org/swisspush/redisques/action/GetQueuesItemsCountAction.java src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java src/main/java/org/swisspush/redisques/util/QueueActionFactory.java src/main/java/org/swisspush/redisques/util/QueueStatisticsCollector.java Related: SDCISA-15833, swisspost#170, swisspost#177, swisspost/vertx-rest-storage#186, swisspost/gateleen#577
- Loading branch information
Showing
10 changed files
with
356 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/org/swisspush/redisques/exception/RedisQuesExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.swisspush.redisques.exception; | ||
|
||
import io.vertx.core.eventbus.ReplyException; | ||
import io.vertx.core.eventbus.ReplyFailure; | ||
|
||
|
||
/** | ||
* Applies dependency inversion for exception instantiation. | ||
* | ||
* This class did arise because we had different use cases in different | ||
* applications. One of them has the need to perform fine-grained error | ||
* reporting. Whereas in the other application this led to performance issues. | ||
* So now through this abstraction, both applications can choose the behavior | ||
* they need. | ||
* | ||
* If dependency-injection gets applied properly, an app can even provide its | ||
* custom implementation to fine-tune the exact behavior even further. | ||
*/ | ||
public interface RedisQuesExceptionFactory { | ||
|
||
public default Exception newException(String message) { return newException(message, null); } | ||
|
||
public default Exception newException(Throwable cause) { return newException(null, cause); } | ||
|
||
public Exception newException(String message, Throwable cause); | ||
|
||
public default RuntimeException newRuntimeException(String message) { return newRuntimeException(message, null); } | ||
|
||
public default RuntimeException newRuntimeException(Throwable cause) { return newRuntimeException(null, cause); } | ||
|
||
public RuntimeException newRuntimeException(String message, Throwable cause); | ||
|
||
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg); | ||
|
||
|
||
/** | ||
* See {@link ThriftyRedisQuesExceptionFactory}. | ||
*/ | ||
public static RedisQuesExceptionFactory newThriftyExceptionFactory() { | ||
return new ThriftyRedisQuesExceptionFactory(); | ||
} | ||
|
||
/** | ||
* See {@link WastefulRedisQuesExceptionFactory}. | ||
*/ | ||
public static RedisQuesExceptionFactory newWastefulExceptionFactory() { | ||
return new WastefulRedisQuesExceptionFactory(); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/swisspush/redisques/exception/ThriftyRedisQuesExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.swisspush.redisques.exception; | ||
|
||
import io.vertx.core.eventbus.ReplyException; | ||
import io.vertx.core.eventbus.ReplyFailure; | ||
|
||
/** | ||
* Trades maintainability for speed. For example prefers lightweight | ||
* exceptions without stacktrace recording. It may even decide to drop 'cause' | ||
* and 'suppressed' exceptions. If an app needs more error details it should use | ||
* {@link WastefulRedisQuesExceptionFactory}. If none of those fits the apps needs, it | ||
* can provide its own implementation. | ||
*/ | ||
class ThriftyRedisQuesExceptionFactory implements RedisQuesExceptionFactory { | ||
|
||
ThriftyRedisQuesExceptionFactory() { | ||
} | ||
|
||
public Exception newException(String message, Throwable cause) { | ||
// This impl exists for speed. So why even bother creating new instances | ||
// if we can use already existing ones. If caller really needs another | ||
// instance, he should use another implementation of this factory. | ||
if (cause instanceof Exception) return (Exception) cause; | ||
return new NoStacktraceException(message, cause); | ||
} | ||
|
||
@Override | ||
public RuntimeException newRuntimeException(String message, Throwable cause) { | ||
// This impl exists for speed. So why even bother creating new instances | ||
// if we can use already existing ones. If caller really needs another | ||
// instance, he should use another implementation of this factory. | ||
if (cause instanceof RuntimeException) return (RuntimeException) cause; | ||
return new NoStacktraceException(message, cause); | ||
} | ||
|
||
@Override | ||
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg) { | ||
return new NoStackReplyException(failureType, failureCode, msg); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/swisspush/redisques/exception/WastefulRedisQuesExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.swisspush.redisques.exception; | ||
|
||
import io.vertx.core.eventbus.ReplyException; | ||
import io.vertx.core.eventbus.ReplyFailure; | ||
|
||
/** | ||
* Trades speed for maintainability. For example invests more resources like | ||
* recording stack traces (which likely provocates more logs) to get easier | ||
* to debug error messages and better hints of what is happening. It also | ||
* keeps details like 'causes' and 'suppressed' exceptions. If an app needs | ||
* more error details it should use {@link WastefulRedisQuesExceptionFactory}. If none | ||
* of those fits the apps needs, it can provide its own implementation. | ||
*/ | ||
class WastefulRedisQuesExceptionFactory implements RedisQuesExceptionFactory { | ||
|
||
WastefulRedisQuesExceptionFactory() { | ||
} | ||
|
||
public Exception newException(String message, Throwable cause) { | ||
return new Exception(message, cause); | ||
} | ||
|
||
@Override | ||
public RuntimeException newRuntimeException(String message, Throwable cause) { | ||
return new RuntimeException(message, cause); | ||
} | ||
|
||
@Override | ||
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg) { | ||
return new ReplyException(failureType, failureCode, msg); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.