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

FHIRStore actor isolation #26

Merged
merged 9 commits into from
Jan 19, 2025
Merged

FHIRStore actor isolation #26

merged 9 commits into from
Jan 19, 2025

Conversation

philippzagar
Copy link
Member

@philippzagar philippzagar commented Dec 23, 2024

FHIRStore actor isolation

♻️ Current situation & Problem

As references in #25, the current FHIRStore implementation is not ideal as it still uses preconcurrency locking mechanisms. Therefore, the FHIRStore should be reimplemented to use Swift's structured concurrency and isolation mechanisms.

⚙️ Release Notes

  • FHIRStore actor isolation with structured concurrency, not relying on locks anymore.
  • FHIRResources are not Sendable anymore (underlying ModelsR4 class is not Sendable)

📚 Documentation

Documented all isolation thoughts

✅ Testing

--

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

@philippzagar philippzagar added the enhancement New feature or request label Dec 23, 2024
@philippzagar philippzagar self-assigned this Dec 23, 2024
Copy link
Collaborator

@jdisho jdisho left a comment

Choose a reason for hiding this comment

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

Awesome job @philippzagar ⚡️⚡️⚡️

Fyi, I left some suggestions. But these are more or less like nice-to-have ones.

Sources/SpeziFHIR/FHIRStore.swift Outdated Show resolved Hide resolved
Sources/SpeziFHIR/FHIRStore.swift Show resolved Hide resolved
Sources/SpeziFHIR/FHIRStore.swift Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 94.32624% with 8 lines in your changes missing coverage. Please review.

Project coverage is 34.97%. Comparing base (a2e68a2) to head (19f5ccd).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...eziFHIRMockPatients/FHIRStore+TestingSupport.swift 0.00% 3 Missing ⚠️
Sources/SpeziFHIR/FHIRStore.swift 97.30% 2 Missing ⚠️
...urces/SpeziFHIRHealthKit/FHIRStore+HealthKit.swift 0.00% 2 Missing ⚠️
...ces/SpeziFHIRMockPatients/FHIRBundleSelector.swift 97.44% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   33.50%   34.97%   +1.48%     
==========================================
  Files          21       21              
  Lines        1466     1467       +1     
==========================================
+ Hits          491      513      +22     
+ Misses        975      954      -21     
Files with missing lines Coverage Δ
...SpeziFHIR/FHIRResource/FHIRResource+Category.swift 36.70% <100.00%> (-0.70%) ⬇️
Sources/SpeziFHIR/FHIRResource/FHIRResource.swift 16.91% <ø> (+6.34%) ⬆️
...SpeziFHIRMockPatients/FHIRMockBundleSelector.swift 100.00% <100.00%> (ø)
...FHIRMockPatients/FoundationBundle+LoadBundle.swift 71.43% <100.00%> (-3.57%) ⬇️
...ces/SpeziFHIRMockPatients/FHIRBundleSelector.swift 96.56% <97.44%> (+2.68%) ⬆️
Sources/SpeziFHIR/FHIRStore.swift 98.06% <97.30%> (+8.54%) ⬆️
...urces/SpeziFHIRHealthKit/FHIRStore+HealthKit.swift 0.00% <0.00%> (ø)
...eziFHIRMockPatients/FHIRStore+TestingSupport.swift 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2e68a2...19f5ccd. Read the comment docs.

Copy link
Member

@Supereg Supereg left a comment

Choose a reason for hiding this comment

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

Had some comments regarding the concurrency design of the Storage type. I'm definitely missing the bigger pictures of all the inner workings, so feel free to comment on my concerns.

Sources/SpeziFHIR/FHIRStore.swift Outdated Show resolved Hide resolved
Sources/SpeziFHIR/FHIRStore.swift Outdated Show resolved Hide resolved
@philippzagar philippzagar requested a review from Supereg January 2, 2025 23:23
@jdisho jdisho mentioned this pull request Jan 3, 2025
1 task
Copy link
Member

@Supereg Supereg left a comment

Choose a reason for hiding this comment

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

Had two final comments.

LGTM 🚀

Sources/SpeziFHIR/FHIRStore.swift Outdated Show resolved Hide resolved
Sources/SpeziFHIR/FHIRStore.swift Show resolved Hide resolved
@philippzagar philippzagar enabled auto-merge (squash) January 19, 2025 19:35
@philippzagar philippzagar merged commit aa1f1b5 into main Jan 19, 2025
8 checks passed
@philippzagar philippzagar deleted the feat/firestore-actor branch January 19, 2025 19:42
philippzagar added a commit that referenced this pull request Jan 28, 2025
# Write tests for `FHIRResource` and its extensions.

## ♻️ Current situation & Problem
The `FHIRResource` class and its extensions currently have 0% test
coverage. We should increase the code coverage as much as possible, to
ensure long-term maintainability.


## ⚙️ Release Notes 
- This PR doesn't change any features. It adds tests for the
`FHIRResource`, `FHIRResource+Search`, and `ResourceProxy+DisplayName`.
- For the `FHIRResource+Category` tests, it's best to wait until PR #26
is merged into the main branch, avoiding any potential conflicts or
inconsistencies.


## 📚 Documentation
Comments are added throughout the code.


## ✅ Testing
Aim for >90% code coverage, but >80% is acceptable in this case.


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).

---------

Co-authored-by: Philipp Zagar <[email protected]>
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
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants