Skip to content

Commit bade5b6

Browse files
committed
Optimize WebVerticle
1 parent 1f9bf29 commit bade5b6

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package net.cofcool.sourcebox.runner;
22

3-
public record ActionEvent(Object source, String tool, String action) {
3+
public record ActionEvent(Object source, String tool, String action, boolean success) {
44

5+
public ActionEvent(Object source, String tool, String action) {
6+
this(source, tool, action, true);
7+
}
58
}

src/main/java/net/cofcool/sourcebox/runner/WebVerticle.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,17 @@ private Router build(Credentials credentials) {
172172
.context(webToolContext);
173173

174174
vertx.executeBlocking(() -> {
175-
try {
176175
tool.run(args);
177-
EVENT_QUEUE.offer(new ActionEvent("success", toolName, "finished"));
178176
return Future.succeededFuture(webToolContext.toObject());
179-
} catch (Exception e) {
180-
EVENT_QUEUE.offer(new ActionEvent("fail", toolName, "finished"));
181-
return Future.failedFuture(e);
182-
}
183-
});
184-
177+
})
178+
.onSuccess(a ->
179+
EVENT_QUEUE.offer(new ActionEvent(a.result(), toolName, "finished")))
180+
.onFailure(a -> {
181+
EVENT_QUEUE.offer(
182+
new ActionEvent("fail: " + a.getMessage(), toolName,
183+
"finished", false));
184+
log.error("run tool error", a);
185+
});
185186
return Future.succeededFuture(webToolContext.toObject());
186187
});
187188
}

0 commit comments

Comments
 (0)