-
Notifications
You must be signed in to change notification settings - Fork 32
Node wrapper poc #785
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
Draft
surbhigarg92
wants to merge
9
commits into
main
Choose a base branch
from
node-wrapper-poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Node wrapper poc #785
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b96ede2
Added POC for Wrapper using Koffi
surbhigarg92 e8981a1
NAPI implementation
surbhigarg92 978eca7
IPC changes
surbhigarg92 b70dd93
koffi with metadata method
surbhigarg92 2c59157
napi fix
surbhigarg92 8c83c0b
napi metadata changes
surbhigarg92 10f14a9
benchmark
surbhigarg92 e41d93a
benchmarking results
surbhigarg92 213703c
Benchmark run 2
surbhigarg92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| gorm/ | ||
| .idea | ||
| .DS_Store | ||
| node_modules | ||
| build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Spanner NodeJS gRPC/IPC Wrapper | ||
|
|
||
| This directory contains a proof-of-concept for a NodeJS wrapper for the Go Spanner library that uses IPC via a gRPC client to communicate with a Go gRPC server. | ||
|
|
||
| ## Architecture | ||
|
|
||
| The wrapper consists of three main parts: | ||
|
|
||
| 1. **Go gRPC Server**: A server written in Go that exposes the Spanner library's functionality over a gRPC interface. This server is located in `spannerlib/grpc-server`. It must be running for this wrapper to function. | ||
|
|
||
| 2. **Node.js gRPC Client**: A client written in Node.js that communicates with the Go gRPC server. It uses the `@grpc/grpc-js` and `@grpc/proto-loader` packages to interact with the server. The client is defined in `src/grpc/`. | ||
|
|
||
| 3. **JavaScript Wrapper**: A high-level JavaScript API that provides `Pool`, `Connection`, and `Rows` classes. This abstracts away the gRPC communication and provides a clean, async/await-based interface that is identical to the Koffi and N-API POCs. | ||
|
|
||
| ## How to Run | ||
|
|
||
| 1. **Start the Go gRPC server**: | ||
| ```sh | ||
| cd spannerlib/grpc-server | ||
| go run server.go localhost:50051 tcp | ||
| ``` | ||
|
|
||
| 2. **Install Node.js dependencies**: | ||
| ```sh | ||
| cd spannerlib/wrappers/spannerlib-nodejs-poc/ipc | ||
| npm install | ||
| ``` | ||
|
|
||
| 3. **Run the test**: | ||
| ```sh | ||
| npm test | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module ipc-poc | ||
|
|
||
| go 1.25.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const { Pool } = require('./src/lib/pool.js'); | ||
| const { Connection } = require('./src/lib/connection.js'); | ||
| const { Rows } = require('./src/lib/rows.js'); | ||
|
|
||
| module.exports = { | ||
| Pool, | ||
| Connection, | ||
| Rows | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The script contains hardcoded paths to
protocplugins, which makes it non-portable and specific to a single user's machine (/Users/loite/...). This will cause the script to fail for other developers or in CI/CD environments.To improve this, consider one of the following approaches:
PATH: Require developers to have theprotoc-gen-*executables in theirPATH.