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(sdk): Mapping concurrency #2899

Merged
merged 4 commits into from
Nov 22, 2024
Merged

feat(sdk): Mapping concurrency #2899

merged 4 commits into from
Nov 22, 2024

Conversation

teogeb
Copy link
Contributor

@teogeb teogeb commented Nov 21, 2024

Improved concurrency for Mapping class. Now concurrent equal get() calls share the same promise, i.e. they evaluate the valueFactory only once.

Example

const valueFactory = async () => ...
const mapping = new Mapping(valueFactory)
await Promise.all([
    mapping.get('foo'),
    mapping.get('bar'),
    mapping.get('bar'),
    mapping.get('foo'),
    mapping.get('foo')
])

Triggers two calls to valueFactory (one for foo and another for bar). Before this PR it triggered 5 calls.

Small refactoring

  • Added readonly field annotations
  • Updated deprecated jest method call

@github-actions github-actions bot added the sdk label Nov 21, 2024
packages/sdk/src/utils/Mapping.ts Outdated Show resolved Hide resolved
@teogeb teogeb merged commit 2dae8b0 into main Nov 22, 2024
24 checks passed
@teogeb teogeb deleted the sdk-mapping-concurrency branch November 22, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants