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.