Remove ReactiveResult.java

This commit is contained in:
lancer.hong
2021-11-07 19:04:17 +08:00
parent 96eecc3899
commit 4c3025e2a8
8 changed files with 70 additions and 137 deletions

View File

@@ -29,7 +29,6 @@ import we.config.AggregateRedisConfig;
import we.config.SystemConfig;
import we.plugin.auth.ApiConfig;
import we.util.JacksonUtils;
import we.util.ReactiveResult;
import we.util.Result;
import we.util.UrlTransformUtils;
@@ -115,7 +114,7 @@ public class ApiPairingDocSetService {
rt.listenToChannel(channel)
.doOnError(
t -> {
result.code = ReactiveResult.FAIL;
result.code = Result.FAIL;
result.msg = "lsn error, channel: " + channel;
result.t = t;
log.error("lsn channel {} error", channel, t);

View File

@@ -27,7 +27,6 @@ import reactor.core.publisher.Mono;
import we.config.AggregateRedisConfig;
import we.config.SystemConfig;
import we.util.JacksonUtils;
import we.util.ReactiveResult;
import we.util.Result;
import javax.annotation.PostConstruct;
@@ -111,7 +110,7 @@ public class ApiPairingInfoService {
rt.listenToChannel(channel)
.doOnError(
t -> {
result.code = ReactiveResult.FAIL;
result.code = Result.FAIL;
result.msg = "lsn error, channel: " + channel;
result.t = t;
log.error("lsn channel {} error", channel, t);

View File

@@ -32,7 +32,7 @@ import we.proxy.CallbackReplayReq;
import we.proxy.CallbackService;
import we.util.Consts;
import we.util.JacksonUtils;
import we.util.ReactiveResult;
import we.util.Result;
import we.util.ThreadContext;
import javax.annotation.Resource;
@@ -61,7 +61,7 @@ public class CallbackController {
callbackService.replay(req)
.onErrorResume(
t -> {
return Mono.just(ReactiveResult.fail(t));
return Mono.just(Result.fail(t));
}
)
.map(
@@ -69,13 +69,12 @@ public class CallbackController {
StringBuilder b = ThreadContext.getStringBuilder();
b.append(req.id).append(' ').append(req.service).append(' ').append(req.path).append(' ');
ServerHttpResponse resp = exchange.getResponse();
if (r.code == ReactiveResult.SUCC) {
if (r.code == Result.SUCC) {
log.info(b.append("replay success").toString(), LogService.BIZ_ID, req.id);
resp.setStatusCode(HttpStatus.OK);
return Consts.S.EMPTY;
} else {
b.append("replay error:\n");
r.toStringBuilder(b);
b.append("replay error:\n").append(r);
log.error(b.toString(), LogService.BIZ_ID, req.id);
resp.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
if (r.msg != null) {

View File

@@ -27,7 +27,6 @@ import reactor.core.publisher.Mono;
import we.config.AggregateRedisConfig;
import we.fizz.input.PathMapping;
import we.util.JacksonUtils;
import we.util.ReactiveResult;
import we.util.Result;
import javax.annotation.PostConstruct;
@@ -119,7 +118,7 @@ public class GlobalResourceService {
rt.listenToChannel(channel)
.doOnError(
t -> {
result.code = ReactiveResult.FAIL;
result.code = Result.FAIL;
result.msg = "lsn error, channel: " + channel;
result.t = t;
log.error("lsn channel {} error", channel, t);

View File

@@ -249,7 +249,7 @@ public class ApiConfigService implements ApplicationListener<ContextRefreshedEve
rt.listenToChannel(channel)
.doOnError(
t -> {
result.code = ReactiveResult.FAIL;
result.code = Result.FAIL;
result.msg = "lsn error, channel: " + channel;
result.t = t;
log.error("lsn channel {} error", channel, t);

View File

@@ -204,14 +204,14 @@ public class CallbackService {
.doOnError(throwable -> clean(remoteResp)).doOnCancel(() -> clean(remoteResp));
}
public Mono<ReactiveResult> replay(CallbackReplayReq req) {
public Mono<Result> replay(CallbackReplayReq req) {
HashSet<String> gatewayGroups = new HashSet<>();
gatewayGroups.add(req.gatewayGroup);
Result<ApiConfig> result = apiConfigService.get(gatewayGroups, req.app, req.service, req.method, req.path);
ApiConfig ac = result.data;
if (ac == null) {
return Mono.just(ReactiveResult.fail("no api config for " + req.path));
return Mono.just(Result.fail("no api config for " + req.path));
}
CallbackConfig cc = ac.callbackConfig;
@@ -259,21 +259,21 @@ public class CallbackService {
.collectList()
.map(
sendResults -> {
int c = ReactiveResult.SUCC;
int c = Result.SUCC;
Throwable t = null;
for (int i = 0; i < sendResults.size(); i++) {
Object r = sendResults.get(i);
if (r instanceof FizzFailClientResponse) {
c = ReactiveResult.FAIL;
c = Result.FAIL;
t = ((FizzFailClientResponse) r).throwable;
} else if (r instanceof FailAggregateResult) {
c = ReactiveResult.FAIL;
c = Result.FAIL;
t = ((FailAggregateResult) r).throwable;
} else if (r instanceof ClientResponse) {
clean((ClientResponse) r);
}
}
return ReactiveResult.with(c, t);
return Result.with(c, t);
}
)
;