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: Add support of using keyword for driver and session management #353

Open
nikolaymatrosov opened this issue Feb 18, 2024 · 2 comments · May be fixed by #397
Open

feat: Add support of using keyword for driver and session management #353

nikolaymatrosov opened this issue Feb 18, 2024 · 2 comments · May be fixed by #397
Labels
enhancement New feature or request

Comments

@nikolaymatrosov
Copy link

Feature Request

Describe the Feature Request

The YDB SDK, like many database SDKs, offers interfaces for establishing sessions and
interacting with the database through a driver. The addition of TypeScript support, specifically for a using
keyword, would introduce several benefits for developers working with YDB.

As the support of this keyword was introduced
in Typecscript 5.2, it would be great if its support will be added to the SDK.

Resource Management: The primary advantage of a using construct is automatic resource management. In the context of YDB, this would ensure that database sessions and connections are properly closed or disposed of once they are no longer needed, reducing the risk of resource leaks that could lead to performance issues or exceeding resource limits.
Code Clarity and Maintenance: Using a using construct makes the scope of resource usage clear. It delineates where resources are started to be used and where they are released, making the code easier to understand and maintain. This is particularly beneficial in complex applications where resource management is critical.

Promote Best Practices: Encouraging the use of a using pattern or similar construct can promote best practices among developers. It makes resource management a more integral part of the development process, encouraging developers to think about the lifecycle of the resources they use.

Asynchronous Support: With the modern TypeScript ecosystem heavily relying on asynchronous operations, especially in the context of database operations, integrating using with async/await patterns would make managing asynchronous database sessions and connections more intuitive. This would allow developers to write non-blocking code while ensuring resources are automatically managed.

Describe Alternatives

I personally find callback approach for managing sessions a little bit cumbersome and I think that developer experience will be much smoother after this change.

Additional Context

Short introduction into using

If the feature request is approved, would you be willing to submit a PR?
No

@nikolaymatrosov nikolaymatrosov added the enhancement New feature or request label Feb 18, 2024
@Zork33
Copy link
Collaborator

Zork33 commented Apr 2, 2024

Symbol.dispose and Symbol.asyncDispose appear in fresh builds of NodeJS 18 and 20. If NodeJS is not recently updated, these symbols may be missing.

So including this functionality in the SDK will require adding a polyfill. So far the polyfill that is found has some issues itself

@nikolaymatrosov
Copy link
Author

Node 16 reached its end of life September 16th, 2023. blog
So there's nothing wrong to drop its support.

@polRk polRk linked a pull request Aug 14, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants