-
Notifications
You must be signed in to change notification settings - Fork 10
Description
I've been trying to debug an issue where tink_sql craps out after a certain amount of rows on php. I'm not getting to any conclusion, my only hunch is the recursiveness of Generator is causing this (since it all works fine on smaller samples). Either an error is getting swallowed or it actually silently stops resuming. I wrote a simple Iterator stream with a little less recursive calls (below). In this particular situation I was limited to 164 rows, with the stream below 495. Not sure where to go from here and if the recursion can be limited even more. Maybe the escape hatch is giving some private access method in the php driver directly to the iterator and skipping the stream abstraction...
Now I don't know if this is desirable to have in tink_streams (also not sure if streams are supposed to be immutable, this is not).
class IteratorStream<Item, Quality> extends StreamBase<Item, Quality> {
var iterator: Iterator<Item>;
public function new(iterator)
this.iterator = iterator;
override function next():Future<Step<Item, Quality>>
return switch iterator.hasNext() {
case true: Link(iterator.next(), this);
case false: End;
}
override public function forEach<Safety>(handler:Handler<Item, Safety>) {
return Future.async(function step(cb:Conclusion<Item, Safety, Quality>->Void)
switch iterator.hasNext() {
case true:
handler.apply(iterator.next()).handle(function (s) {
switch s {
case BackOff:
cb(Halted(this));
case Finish:
cb(Halted(this));
case Resume:
step(cb);
case Clog(e):
cb(Clogged(e, this));
}
});
case false: cb(Depleted);
}, true);
}
}