Hi guys,
I am using Recordparser in delimiter mode to parse a readsteram. The stream is like id;content;id;content; and my code is like:
@VisibleForTesting
Future<Void> startToWrite(RecordParser parser) {
Promise<Void> jobDone = Promise.promise();
parser.exceptionHandler(err -> {
jobDone.fail(err);
})
.handler(buffer -> {
getId(parser, buffer, jobDone);
// getContent is inisde getId, then getId again in recursive
});
return jobDone.future();
}
Question:
1. From the book exmaple, it uses recursive call to parse the content. Is there a better way to do it?
2. The parser is wrapped inside a future method. I want to give a promise.complete once it reaches end. But looks I can't reach the end, somehow parser.handle detects the end and stop the recursive. It there a way I can tell if it reachs end?
3. promise.fail never throws to exceptionHandler, can you explain a bit or give anexample how to reach there?
Thanks,
Andrew