Skip to content

feat(sdk/js): add synchronous PoolManagerSync wrapper (Node.js)#361

Open
wangdengshan wants to merge 2 commits into
alibaba:mainfrom
wangdengshan:feat/sdk-js-pool-manager-sync
Open

feat(sdk/js): add synchronous PoolManagerSync wrapper (Node.js)#361
wangdengshan wants to merge 2 commits into
alibaba:mainfrom
wangdengshan:feat/sdk-js-pool-manager-sync

Conversation

@wangdengshan
Copy link
Copy Markdown
Contributor

Summary

  • Add synchronous PoolManagerSync wrapper to the JavaScript/TypeScript SDK for blocking pool management in Node.js
  • Add runPoolOpSync utility using worker_threads + Atomics.wait to block the main thread while an async pool operation runs in a short-lived child worker
  • Inline WORKER_SCRIPT (no separate file needed after bundling)
  • Add PoolManagerSync with static create() factory, blocking CRUD methods, close(), and Symbol.dispose support (TC39 explicit resource management / using keyword)
  • Export PoolManagerSync from index.ts

Testing

  • Unit tests
  • 50 tests across 2 test files:
    • pool.manager.sync.test.ts: API shape, payload forwarding, error propagation, post-close guard, connection config forwarding
    • pool.manager.sync.runSync.test.ts: WORKER_SCRIPT structure, WorkerResult shapes, PoolOp union, error reconstruction

Breaking Changes

  • None

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

- Add runPoolOpSync utility using worker_threads + Atomics.wait to
  block the main thread while an async pool operation runs in a
  short-lived child worker
- Inline WORKER_SCRIPT (no separate file needed after bundling)
- Add PoolManagerSync with static create() factory, blocking CRUD
  methods, close(), and Symbol.dispose support (TC39 explicit
  resource management / "using" keyword)
- Export PoolManagerSync from index.ts
- Add 50 tests across 2 test files:
  - pool.manager.sync.test.ts: API shape, payload forwarding,
    error propagation, post-close guard, connection config forwarding
  - pool.manager.sync.runSync.test.ts: WORKER_SCRIPT structure,
    WorkerResult shapes, PoolOp union, error reconstruction
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ This PR has no labels. Please add one based on the changes.

Changed directories: .gitignore、sdks.

📋 Recommended labels (based on changed files):

  • sdks ⬅️

Other available labels:

  • bug - Something isn't working
  • dependencies - Pull requests that update a dependency file
  • documentation - Improvements or additions to documentation
  • feature - New feature or request
  • packages - Changes for package, image and configuration

💡 Tip: Use feature for new functionality or improvements, bug for fixes.

cc @wangdengshan

@wangdengshan
Copy link
Copy Markdown
Contributor Author

Hi maintainers, could someone please add the sdks and feature labels to this PR? As an external contributor I do not have permission to add labels myself. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant