josephg / node-foundationdb

Modern Node.js FoundationDB bindings
Other
115 stars 17 forks source link

Adding synchronous API calls #43

Closed bigfatwhale closed 4 years ago

bigfatwhale commented 4 years ago

Hi,

I'm trying to use the api with vscode extensions that are mostly synchronous function calls.

Is it possible to add synchronous counterparts to most of the api calls?

I'm rather new to typescript so maybe there's some easy workaround that I might not know about, if there is, could you kindly point me to the right direction?

Thanks!

josephg commented 4 years ago

... Technically we could, but that would require suspending the whole nodejs process while the database requests run. So any glitches on the network would cause the whole UI to freeze up.

Using a sync api for network IO is counter to the nodejs philosophy. It is only technically possible in this case because of native code. Ideally in the future this library will be pure-javascript, and at that point that API will be impossible to maintain.

Anyway, in short, no I'm not interested in writing and maintaining a sync API in this library. You'll need to fork the work I'm doing here and maintain that yourself if its something you want.

I recommend talking to the vs code devs - maybe you can make the extension APIs async instead. The solution at the end of that road would perform better anyway, since the UI wouldn't freeze for DB accesses.