Skip to content
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(bindings/nodejs): generate types and add typed create_operator method #5465

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ default = [
"services-webhdfs",
]


# NOTE: this is the feature we used to build pypi wheels.
# When enable or disable some features,
# also need to update dev/src/generate/binding_nodejs.rs `enabled_service` to match it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have repeated this pattern once again. Let's implement a utility function to retrieve all enabled services by cargo metadata.

services-all = [
"default",
"services-aliyun-drive",
Expand Down
1 change: 1 addition & 0 deletions bindings/nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ declare module './generated' {
}

export * from './generated'
export { create_operator } from './types.generated'
4 changes: 4 additions & 0 deletions bindings/nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ Writer.prototype.createWriteStream = function (options) {
return new WriteStream(this, options)
}

module.exports.create_operator = function (scheme, options) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we modify the Operator's constructor API instead of introducing a new API to build the operator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't since type of Operator is also generated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need to design new APIs instead of adding another one. Maybe we can impelment Operator class in js instead of exposing from native binding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea how? do you suggest to wrap all method of Operator?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea how? do you suggest to wrap all method of Operator?

It seems like a possible approach. I'm not sure if we can have multiple constructors on the Rust side; perhaps we could generate Rust code as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's getting messy...

I haven't start using nodejs binding yet, maybe I'll try this some days later.

return new Operator(scheme, options)
}

module.exports.Operator = Operator
module.exports.layers = {
RetryLayer,
Expand Down
1 change: 1 addition & 0 deletions bindings/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"webhdfs"
],
"files": [
"types.generated.d.ts",
"index.d.ts",
"index.js",
"generated.d.ts",
Expand Down
Loading
Loading