Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #2858] Unified http client implementation, enhanced async request callback interface #3452

Merged
merged 6 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void failed(Exception ex) {

@Override
public void cancelled() {

callback.onCancel();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ public interface Callback<T> {
*/
void onError(Throwable throwable);

/**
* Callback when the request is cancelled.
*/
void onCancel();

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void failed(Exception ex) {

@Override
public void cancelled() {

callback.onCancel();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ public void onError(Throwable throwable) {
ExceptionUtil.getAllExceptionMsg(throwable));
MemberUtils.onFail(target, throwable);
}

@Override
public void onCancel() {

}
});
} catch (Throwable ex) {
Loggers.CLUSTER.error("failed to report new info to target node : {}, error : {}", target.getAddress(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public void onError(Throwable throwable) {
latch.countDown();
}
}

@Override
public void onCancel() {

}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public void onReceive(RestResult<T> result) {

@Override
public void onError(Throwable throwable) {
throwable = throwable;
this.throwable = throwable;
}

@Override
public void onCancel() {

}

public HttpRestResult<T> getRestResult() {
Expand Down Expand Up @@ -135,7 +140,7 @@ public void test_url_get() throws Exception {
System.out.println(restResult.getData());
System.out.println(restResult.getHeader());
Assert.assertTrue(restResult.ok());
Assert.assertEquals(restResult.getData().get("dom"), "app-test");
Assert.assertEquals(restResult.getData().get("name"), "DEFAULT_GROUP@@app-test");
}

@Test
Expand All @@ -150,7 +155,7 @@ public void test_url_by_map() throws Exception {
System.out.println(restResult.getData());
System.out.println(restResult.getHeader());
Assert.assertTrue(restResult.ok());
Assert.assertEquals(restResult.getData().get("dom"), "app-test");
Assert.assertEquals(restResult.getData().get("name"), "DEFAULT_GROUP@@app-test");
}

@Test
Expand Down