in all our stuff - it's amazing. Async code is so
@Override
public void handle(RoutingContext context) {
new Fiber<Void>() {
@Override
protected Void run() throws SuspendExecution, InterruptedException {
try {
StormpathAuthProvider stormpathAuthProvider = context.get("stormpathAuthProvider");
// The following is an async call that will suspend this fibre (not block!) until the HTTP response comes in!
JsonNode customData = stormpathAuthProvider.userCustomDataAsync(context.user().principal());
final OffsetDateTime now = OffsetDateTime.now();
...
We use a wrapper for http client requests that does the magic of turning it into a fibre so that we can do something like this:
ExpandedHttpClientResponse resp = FiberWrappers.sendHttpClientRequest(getCustomDataRequest);
// This occurs after the response is returned (in a non blocking manner).
if (resp.response.statusCode() != 200) {
I'm so impressed with fibres (and Quasar) that I sought out a thread to post to! It's so much simpler than nested code, and so much simpler than CompleteableFuture based code (which quickly becomes unreadable as we found out).
Only gotcha is that you have to remember that while it looks sync, it aint.