-
Notifications
You must be signed in to change notification settings - Fork 72
feat: JS client #3658
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
feat: JS client #3658
Conversation
| }, | ||
| }, | ||
| } | ||
| // func TestSubscriptionWithUpdateAllMutations(t *testing.T) { |
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.
- todo: uncomment when fixed
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3658 +/- ##
===========================================
- Coverage 78.01% 77.10% -0.91%
===========================================
Files 405 418 +13
Lines 37341 38197 +856
===========================================
+ Hits 29129 29451 +322
- Misses 6431 6872 +441
- Partials 1781 1874 +93
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 18 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
AndrewSisley
left a comment
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.
Looks really good Keenan! Is really neat considering what it manages to achieve :)
Is a shame we can quite do a pure wasm build, yet, but maybe Chris's C binding work will solve that soon.
I didn't review any code that moved, please let me know if anything was changed in the code that did move.
I have a few questions, but I don't think any answers would cause me to want to block the PR so I'm approving now.
| @$(MAKE) clean:coverage | ||
|
|
||
|
|
||
| .PHONY: test\:coverage-js |
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.
question: Why is this a new command? Would GOOS=js GOARCH=wasm make test:coverage not work?
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.
It doesn't work because not all of the packages are JS / WASM compatible. If we wanted to go that route we'd need to add a bunch of //go:build !js tags to the files in those packages..
| } | ||
|
|
||
| ctx := identity.WithContext(cmd.Context(), immutable.Some(ident)) | ||
| ctx := acpIdentity.WithContext(cmd.Context(), immutable.Some(ident)) |
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.
question: Why did you remove the unaliased import instead of the aliased one?
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.
I was seeing a linter warning in my IDE about the same packagebeing imported twice.
tests/bench/acp/acp_local_test.go
Outdated
| // by the Apache License, Version 2.0, included in the file | ||
| // licenses/APL.txt. | ||
|
|
||
| //go:build !js |
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.
question: This is a bit annoying to have to include, why is it required?
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.
I think these can be removed now. I'll double check.
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.
It looks like they are not needed. I've removed all of the build flags from tests/bench.
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.
Nice! Thanks Keenan
|
|
||
| //go:build js | ||
|
|
||
| package js |
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.
question: Does this execute the js client as wasm in a JS runtime?
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.
Yes, everything (including the test framework) is executed in a NodeJS runtime.
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.
Nice! That's really great, thanks Keenan.
| test := testUtils.TestCase{ | ||
| Description: "Positive increments of a P Counter with Int type causing overflow behaviour", | ||
| SupportedClientTypes: immutable.Some([]testUtils.ClientType{ | ||
| // JS client does not support 64 bit integers |
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.
question: Why not?
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.
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.
Can you add/document this somewhere incase there are others who wonder about this later.
tests/integration/utils.go
Outdated
| viewType ViewType | ||
| // skipNetworkTests will skip any tests that involve network actions | ||
| skipNetworkTests = false | ||
| // skipBackupTests will skip any tests taht involve backup actions |
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.
nitpick: Typo taht
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.
fixed
| cliClient = false | ||
| jsClient = true | ||
| skipNetworkTests = true | ||
| skipBackupTests = true |
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.
todo: Please document why net and backup are skipped (within this func)
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.
done. Let me know if its a good enough explanation.
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 'why' regarding backup is still a little vague to me. Feel free to keep the comment as-is if you feel like though - I think I'm questioning the design decision as much as the documentation.
I do not see a good reason (other than dev-time priority) to not support importing data in a JS runtime, and can easily imagine that to be very useful.
Exporting to file is harder as you mentioned in another comment, however returning the json could be very useful too (and then let the user decide what they want to do with it, instead of forcing it to file).
I don't remember ever looking at the implementation of import/export, but to me working with files (or any other medium) seems to be a very lightweight bonus option that should be sat on top of the core feature.
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.
I agree it could be useful. I'd prefer to do this in a separate PR since this one is already large. It will likely require changes to the backup API as well.
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.
Yes, completely on onboard with that, and it is a different priority really to this main body of work.
| panic("not implemented") | ||
| } | ||
|
|
||
| func (w *Wrapper) BasicImport(ctx context.Context, filepath string) error { |
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.
question: Why aren't Import/Export implemented?
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.
We had a short discussion about it in the standup. This backup API implementation doesn't make much sense in JS environments. There's also technical issues with where the files should be written in a browser.
shahzadlone
left a comment
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.
LGTM, thanks for doing the suggested changes and investigating why develop change was sneaking in. Just left a question regarding some acp integration test structure refactoring with js build that was done.
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.
question: I am a bit confused, so stuff was moved from acp.go into acp_setup.go and acp_setup_js.go. And only the acp_setup.go is ignored when building with js build-tag, both other files are included with both js and non-js builds?
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.
Files that end in _js.go automatically have the JS build tag.
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.
What I was wondering was does this mean that when we don't build with js build tag, then the _js.go will still be loaded and is not being ignored, is that expected?
i.e. acp_setup.go is being ignored when we build with js tag so was thinking that if we aren't then the acp_setup_js.go will be ignored similarly (which it is not atm).
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.
It works the same as the _test.go suffix. The files are only included when you use the js build tag.
| test := testUtils.TestCase{ | ||
| Description: "Positive increments of a P Counter with Int type causing overflow behaviour", | ||
| SupportedClientTypes: immutable.Some([]testUtils.ClientType{ | ||
| // JS client does not support 64 bit integers |
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.
Can you add/document this somewhere incase there are others who wonder about this later.
|
Bug bash result: created #3778 |
## Relevant issue(s) Resolves sourcenetwork#2442 ## Description This PR adds a JS client implementation to DefraDB. Sorry for the messy commit history. I accidentally started this on a previous feature branch. ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the repository-held documentation is changed accordingly. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in [tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)). - [x] I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ... ## How has this been tested? Added integration test client wrapper. Specify the platform(s) on which this was tested: - MacOS
Relevant issue(s)
Resolves #2442
Description
This PR adds a JS client implementation to DefraDB.
Sorry for the messy commit history. I accidentally started this on a previous feature branch.
Tasks
How has this been tested?
Added integration test client wrapper.
Specify the platform(s) on which this was tested: