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

Conversation

trim21
Copy link
Contributor

@trim21 trim21 commented Dec 27, 2024

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

generate types for nodejs binding.

type of Operator is already generated and it's hard to interactive, so we will need to add a new typed function create_operator to create operator.

Are there any user-facing changes?

Yes, new typed method create_operator.

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

I'm fine with most of the changes, but do you think it's better to complete the task on the python side first and then expand to other bindings?


# 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.

value_field?: string
}

export interface Redb_Config {
Copy link
Member

Choose a reason for hiding this comment

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

Is it normal for js to jave types like Xxx_Yyy? Should we use XxxYyy instead?

Copy link
Contributor Author

@trim21 trim21 Dec 27, 2024

Choose a reason for hiding this comment

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

we may need some template filter to convert nebula_graph to NebulaGraph

@@ -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.

dev/src/generate/mod.rs Outdated Show resolved Hide resolved
@trim21 trim21 closed this Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants