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

refactor(subscriptions): skip bullmq for WS subs, push all WS subs thru one Redis channel #4585

Merged
merged 6 commits into from
May 27, 2024

Conversation

ThatOneBro
Copy link
Member

No description provided.

@ThatOneBro ThatOneBro requested a review from a team as a code owner May 23, 2024 00:23
Copy link

vercel bot commented May 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medplum-provider ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2024 7:40pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
medplum-app ⬜️ Ignored (Inspect) Visit Preview May 27, 2024 7:40pm
medplum-storybook ⬜️ Ignored (Inspect) Visit Preview May 27, 2024 7:40pm
medplum-www ⬜️ Ignored (Inspect) Visit Preview May 27, 2024 7:40pm

@ThatOneBro ThatOneBro changed the title refactor(subscriptions): skip bullmq job for WS subscriptions refactor(subscriptions): skip bullmq job for WS subscriptions, push all subscriptions through one Redis channel May 25, 2024
@ThatOneBro ThatOneBro changed the title refactor(subscriptions): skip bullmq job for WS subscriptions, push all subscriptions through one Redis channel refactor(subscriptions): skip bullmq for WS subs, push all WS subs thru one Redis channel May 25, 2024
Copy link
Member

@codyebberson codyebberson left a comment

Choose a reason for hiding this comment

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

Nice, this is clean.

  1. Minor, some commented out code
  2. What is the case for multiple websocket connections sharing a Subscription? I guess it's neat that we support it, I just didn't think it was something that would be possible. Maybe if the Subscription id is in localStorage, and you have multiple tabs open?

packages/server/src/subscriptions/websockets.ts Outdated Show resolved Hide resolved
}

function subscribeWsToSubscription(ws: ws.WebSocket, subscriptionId: string): void {
let wsSet = subToWsLookup.get(subscriptionId);
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 allowed to use the same Subscription on multiple websocket connections? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's technically allowed by the spec, and Currently our client doesn't support it but it shouldn't be hard to add support for it in the future. I kinda left it open more for other client implementers / to be more FHIR spec-compliant

}
const wsSet = subToWsLookup.get(subscriptionId) as Set<ws.WebSocket>;
wsSet.delete(ws);
if (wsSet.size === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Clever

Copy link

sonarcloud bot commented May 27, 2024

@ThatOneBro ThatOneBro added this pull request to the merge queue May 27, 2024
Merged via the queue into main with commit a51b166 May 27, 2024
32 checks passed
@ThatOneBro ThatOneBro deleted the derrick-ws-sub-skip-bullmq branch May 27, 2024 20:44
medplumbot added a commit that referenced this pull request Jun 2, 2024
Updating sample HL7 bot to include ADT-08 messages (#4591)Dependency upgrades 2024-05-27 (#4593)
feat: enable unit testing subscription criteria (#4581)
feat(fhircast): properly respond to `unsubscribe` request (#4590)
Fixes #4576 - Windows 1252 character encoding (#4594)
refactor(subscriptions): skip `bullmq` for WS subs, push all WS subs thru one Redis channel (#4585)
Added fhirpath test data (#4598)
Fix several fhirpath functions taking `other` Atom and implement subsetOf & supersetOf (#4601)
Use nested transactions with stronger isolation (#4583)
Support Database SSL config from Env (#4597)
Parse ADT example  (#4596)
Better PATCH error messages (#4607)
Respect AccessPolicy.resource.{readonlyFields,hiddenFields} in ResourceForm (#4588)
Fix IAM policy resource strings (#4603)
Fixes #4440 - backslash escaped commas in search values (#4609)
Fixes #4147 - formatSearchQuery with _include:iterate (#4610)
Fixes #4462 - configurable Bot AuditEvent.outcomeDesc max length (#4612)
Fixes #4531 - choice-of-type definitions and getExtensionValue() (#4611)
Allow Bot to return Binary (#4595)
Remove spurious console.warn (#4616)
Fixed flaky repo tests (#4618)
Fixes #4617 - replace Google QR code API (#4619)
@medplumbot medplumbot mentioned this pull request Jun 2, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jun 2, 2024
Updating sample HL7 bot to include ADT-08 messages (#4591)Dependency upgrades 2024-05-27 (#4593)
feat: enable unit testing subscription criteria (#4581)
feat(fhircast): properly respond to `unsubscribe` request (#4590)
Fixes #4576 - Windows 1252 character encoding (#4594)
refactor(subscriptions): skip `bullmq` for WS subs, push all WS subs thru one Redis channel (#4585)
Added fhirpath test data (#4598)
Fix several fhirpath functions taking `other` Atom and implement subsetOf & supersetOf (#4601)
Use nested transactions with stronger isolation (#4583)
Support Database SSL config from Env (#4597)
Parse ADT example  (#4596)
Better PATCH error messages (#4607)
Respect AccessPolicy.resource.{readonlyFields,hiddenFields} in ResourceForm (#4588)
Fix IAM policy resource strings (#4603)
Fixes #4440 - backslash escaped commas in search values (#4609)
Fixes #4147 - formatSearchQuery with _include:iterate (#4610)
Fixes #4462 - configurable Bot AuditEvent.outcomeDesc max length (#4612)
Fixes #4531 - choice-of-type definitions and getExtensionValue() (#4611)
Allow Bot to return Binary (#4595)
Remove spurious console.warn (#4616)
Fixed flaky repo tests (#4618)
Fixes #4617 - replace Google QR code API (#4619)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subscriptions Features and fixes related to subscriptions
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants