Just a comment: There was some discussion during the conference about the Promise interfaces. I am not the right person to summarize the specific issues, but the bottom line was that the current APIs probably need some more work. This has nothing to do with your new API since it is merely using Promises. Maybe we can re-boot this discussion here on the list?
Otherwise, I personally really like the Promises APIs and avoid pure callback-based APIs when I have the choice.
Arne
On 11/22/17 16:15, Stephen R. van den Berg wrote:
Utilising the momentum, I whipped out a Concurrent.Promise interface for Sql.Connection in git Pike 8.1.
The included examples in the docs could still use some love. Other than that, I thought this was a reasonable attempt at a sane interface between promises and SQL.
Lame sample code:
int main() { db = Sql.Sql(DBNGURL);
Concurrent.Future q1 = db->promise_query("SELECT :bar::INT b", (["bar":3])); Concurrent.Future q2 = db->promise_query("SELECT :foo::INT f", (["foo":4]));
array all = ({q1, q2});
all->on_success(lambda (Sql.FutureResult okresp) { werror("#########################Ok result %O %O\n", okresp, okresp->data); }); all->on_failure(lambda (Sql.FutureResult okresp) { werror("##########################Failed result %O\n", okresp); }); return -1; }
Promises only work with the default backend running. I have tested this with pgsql only, but it should work with any database backend.
Any critisism, suggestions and/or improvements are welcome.