-
-
Notifications
You must be signed in to change notification settings - Fork 189
feat(helix-lib): embeddable sdk #775
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (4)
-
helix-lib/Cargo.toml, line 4 (link)syntax:
edition = "2024"is not a valid Rust edition. Valid editions are 2015, 2018, 2021. -
helix-lib/src/lib.rs, line 25-26 (link)logic: Type mismatch:
queries::config()returnsOption<Config>but this example treats it asResult. The generated function signature ispub fn config() -> Option<Config>(see build.rs:201), but documentation shows usage with?operator which requires Result. -
helix-lib/README.md, line 71-72 (link)logic: Type mismatch:
queries::config()returnsOption<Config>, notResult, so the?operator won't work here. -
helix-lib/src/lib.rs, line 123 (link)logic: This suggests using
.unwrap_or_default()onOption<Config>, butConfigdoesn't implement Default. This will cause a compilation error. Use.expect()instead.
19 files reviewed, 4 comments
|
Some more things to add:
|
|
I might be being dumb here but, couldn't the embeddable API be just the storage API which HQL compile to? |
I could say I've taken inspiration from the already existing sdk (https://github.com/HelixDB/helix-rs) and mostly have tried to mimic this usage, but doesn't using the actual storage api beat the entire need of hql? isn't hql supposed to be the actual high level interface to the db? |
Description
Embeddable SDK (helix-lib)
Adds
helix-lib- an embeddable SDK for using HelixDB without a server.What It Does
Compile
.hxschemas/queries to Rust at build time, execute them in-process.Changes
New Package:
helix-lib/src/lib.rs- HelixDB struct, execute() APIsrc/errors.rs- Error typessrc/build.rs- Build-time compilerexamples/simple/- Working exampleREADME.md- DocsAPI
Response helpers via
ResponseExttrait:deserialize<T>()- Type-safe deserializationjson()- Dynamic JSON accessget_field<T>(field)- Field extractionTesting
✅ Example builds and runs
✅ Handler registration works
✅ Type-safe deserialization works
✅ No breaking changes
See
helix-lib/examples/simple/for fully-fledged example.Related Issues
Closes #104
Checklist when merging to main
rustfmthelix-cli/Cargo.tomlandhelixdb/Cargo.tomlAdditional Notes
Greptile Summary
Adds
helix-lib, an embeddable SDK that compiles.hxschemas/queries to Rust at build time, enabling in-process database operations without a server.Key Changes:
helix-libpackage withHelixDBstruct andexecute()API for query executionbuild.rs) that parses.hxfiles and generatesqueries.rswith handler registrationsResponseExttrait providingdeserialize(),json(), andget_field()helpers for type-safe response handlingsimple) demonstrating user creation and retrieval workflowsIssues Found:
helix-lib/Cargo.toml(should be "2021")queries::config()returnsOption<Config>but examples use?operator expectingResult.unwrap_or_default()butConfigdoesn't implementDefaultImportant Files Changed
Sequence Diagram
sequenceDiagram participant User as User Code participant Build as build.rs participant Compiler as HelixC Compiler participant Gen as queries.rs (generated) participant DB as HelixDB participant Storage as HelixGraphStorage participant Handler as Query Handler Note over User,Gen: Build Time User->>Build: cargo build Build->>Compiler: compile_queries_default() Compiler->>Compiler: parse .hx files Compiler->>Compiler: analyze schema Compiler->>Gen: generate queries.rs Gen->>Gen: register handlers via #[handler] Note over User,Handler: Runtime User->>Gen: queries::config() Gen-->>User: Config User->>DB: HelixDB::new(path, config) DB->>Storage: HelixGraphStorage::new() Storage-->>DB: Arc<HelixGraphStorage> User->>DB: execute("GetUsers", params) DB->>DB: inventory::iter() collect handlers DB->>Handler: call handler(input) Handler->>Storage: query operations Storage-->>Handler: results Handler-->>DB: Response DB-->>User: Response User->>User: response.deserialize()