Skip to content

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

Open
wangdengshan wants to merge 1 commit intoalibaba:mainfrom
wangdengshan:feat/sdk-js-pool-manager-sync
Open

feat(sdk/js): add synchronous PoolManagerSync wrapper (Node.js)#361
wangdengshan wants to merge 1 commit intoalibaba:mainfrom
wangdengshan:feat/sdk-js-pool-manager-sync

Conversation

@wangdengshan
Copy link
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
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