This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new d9f1087e3 [ISSUE #4197] Use switch instead of if else
d9f1087e3 is described below
commit d9f1087e3102751f15d5ae37c640ea1193900214
Author: Kartik Tayal <[email protected]>
AuthorDate: Fri Jul 14 11:55:07 2023 +0530
[ISSUE #4197] Use switch instead of if else
Fix #4197
Signed-off-by: Kartik Tayal <[email protected]>
---
.../protocol/grpc/push/WebhookPushRequest.java | 45 ++++++++++++----------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java
index 662774fc4..42ef037d8 100644
---
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java
+++
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/WebhookPushRequest.java
@@ -201,10 +201,17 @@ public class WebhookPushRequest extends
AbstractPushRequest {
"message|eventMesh2client|{}|url={}|topic={}|bizSeqNo={}"
+ "|uniqueId={}|cost={}", result, selectedPushUrl,
EventMeshCloudEventUtils.getSubject(eventMeshCloudEvent),
EventMeshCloudEventUtils.getSeqNum(eventMeshCloudEvent),
EventMeshCloudEventUtils.getUniqueId(eventMeshCloudEvent), cost);
- if (result == ClientRetCode.OK || result ==
ClientRetCode.FAIL) {
- complete();
- } else if (result == ClientRetCode.RETRY || result ==
ClientRetCode.NOLISTEN) {
- delayRetry();
+ switch (result) {
+ case OK:
+ case FAIL:
+ complete();
+ break;
+ case RETRY:
+ case NOLISTEN:
+ delayRetry();
+ break;
+ default:
+ //do nothing
}
}
return new Object();
@@ -237,27 +244,23 @@ public class WebhookPushRequest extends
AbstractPushRequest {
List<String> localIdcUrl = MapUtils.getObject(urls,
eventMeshGrpcConfiguration.getEventMeshIDC(), null);
if (CollectionUtils.isNotEmpty(localIdcUrl)) {
- if (subscriptionMode == SubscriptionMode.CLUSTERING) {
- return Collections.singletonList(localIdcUrl.get((startIdx +
retryTimes) % localIdcUrl.size()));
- } else if (subscriptionMode == SubscriptionMode.BROADCASTING) {
- return localIdcUrl;
- } else {
- MESSAGE_LOGGER.error("Invalid Subscription Mode, no message
returning back to subscriber.");
- return Collections.emptyList();
- }
+ return getStringList(localIdcUrl);
+ } else if (CollectionUtils.isNotEmpty(totalUrls)) {
+ return getStringList(totalUrls);
}
+ MESSAGE_LOGGER.error("No event emitters from subscriber, no message
returning.");
+ return Collections.emptyList();
+ }
- if (CollectionUtils.isNotEmpty(totalUrls)) {
- if (subscriptionMode == SubscriptionMode.CLUSTERING) {
- return Collections.singletonList(totalUrls.get((startIdx +
retryTimes) % totalUrls.size()));
- } else if (subscriptionMode == SubscriptionMode.BROADCASTING) {
- return totalUrls;
- } else {
+ private List<String> getStringList(List<String> stringList) {
+ switch (subscriptionMode) {
+ case CLUSTERING:
+ return Collections.singletonList(stringList.get((startIdx +
retryTimes) % stringList.size()));
+ case BROADCASTING:
+ return stringList;
+ default:
MESSAGE_LOGGER.error("Invalid Subscription Mode, no message
returning back to subscriber.");
return Collections.emptyList();
- }
}
- MESSAGE_LOGGER.error("No event emitters from subscriber, no message
returning.");
- return Collections.emptyList();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]