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

Split AppState into logical components #22

Merged
merged 9 commits into from
Sep 20, 2022
Merged

Split AppState into logical components #22

merged 9 commits into from
Sep 20, 2022

Conversation

gswirski
Copy link
Collaborator

@gswirski gswirski commented Sep 19, 2022

Motivation

Simplify main.rs file and provide finer grained locks.

Solution

Split state into smaller components that can be locked separately.

I erred on the side of explicit dependencies which means we have lots of Axum extensions now.

Alternatively, we could have a single Arc<AppState> shared across endpoints with many RwLockss and AtomicInts inside.

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

@codecov-commenter
Copy link

Codecov Report

Merging #22 (3327cbb) into master (00b4bdb) will decrease coverage by 0.19%.
The diff coverage is 46.12%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
- Coverage   23.85%   23.65%   -0.20%     
==========================================
  Files          17       20       +3     
  Lines        5157     5285     +128     
==========================================
+ Hits         1230     1250      +20     
- Misses       3927     4035     +108     
Flag Coverage Δ
test 23.65% <46.12%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/api/v1/auth.rs 0.00% <0.00%> (ø)
src/api/v1/info.rs 0.00% <0.00%> (ø)
src/main.rs 2.40% <0.00%> (-29.05%) ⬇️
src/oauth.rs 0.00% <0.00%> (ø)
src/util.rs 14.28% <0.00%> (ø)
src/lobby.rs 83.13% <83.13%> (ø)
src/api/v1/lobby.rs 78.33% <91.66%> (-0.77%) ⬇️
src/api/v1/contribute.rs 91.97% <95.83%> (-0.58%) ⬇️
... and 2 more

Continue to review full report at Codecov.

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

@kevaundray
Copy link
Collaborator

In terms of best practice, not just for Axum, having a lock within a lock is a code smell. So I think splitting it up would be best

@gswirski gswirski merged commit 8289c5c into master Sep 20, 2022
@gswirski gswirski mentioned this pull request Sep 21, 2022
@gswirski gswirski deleted the state-split branch September 26, 2022 13:43
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.

3 participants