-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Research how to simplify the connection between JS and C++ code (considering both ios and android) #37
Comments
The rust way of doing things is a far simpler. And NAPI-RS does alot of good things. If we switch to using the rust's rocksdb, we might get around some of the problems. Of course one has to be aware of the block encryption requirement. Right now no mention of that API support. I created an upstream issue rust-rocksdb/rust-rocksdb#802 Also see: |
I have a feeling that delegating the lifecycle and resource management to JS side is the right thing, and instead the C++ code shouldn't be using classes at all, but instead exposing underlying state possibly through opaque pointers that can be managed manually be JS. This does require a bit of rearchitecture. |
Specification
The work from #19 introduced rocksdb, and inherited the architecture from leveldown and rocksdb.
This means that we have roughly 3 layers of abstraction:
DB.ts
,DBTransaction.ts
andDBIterator.ts
- this is what is used by the end user of this librarynapi-macros
, but doesn't use thenode-addon-api
framework. This creates a flat list of functions exposed fromindex.cpp
, and these functions manipulate classes likeDatabase
,Transaction
, these classes embed logic involving thenapi
system in nodejs, the code here is not portable to the non-node environmentnode-gyp
, and all of its objects are encapsulated in classes in our C++ NAPI bindingThere's a couple things here that aren't as robust as they can be:
napi-macros
, let's just usenode-addon-api
, it seems like a much more comprehensive framework for integrating into nodejsI have some ideas to make the C++ classes behave more like JS classes, and to use the napi bindings to connect them together. Then instead of exposing raw functions, we just extend the native class constructors with the JS classes. However at the same time, keeping the interface simple might simplify the expectations the JS side has of the C++ side, so that when android/ios work is involved, and napi conveniences are not available, then we have to consider if there's an additional bridge layer like Java or Swift/Obj-C that sits in-between the JS and C++ code.
Additional context
Tasks
The text was updated successfully, but these errors were encountered: