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

Add a customizable diesel backed session store #42

Merged
merged 5 commits into from
Oct 18, 2023

Conversation

weiznich
Copy link
Contributor

This commit adds a custom diesel backed session store. It abstracts over different database backends and allows to customize the used session table.

This partially addresses #26 (the diesel part, not the diesel-async part)

@maxcountryman
Copy link
Owner

This is fantastic. Thank you!

@maxcountryman
Copy link
Owner

Should we add an integration test while we're at it? I've done that for the SQLx stores we support.

@weiznich
Copy link
Contributor Author

Can you point to where to add these tests?

@maxcountryman
Copy link
Owner

We should be able to put them somewhere in here: https://github.com/maxcountryman/tower-sessions/blob/main/tests/integration-tests.rs

@maxcountryman
Copy link
Owner

It looks like some of the integration tests are failing.

@weiznich
Copy link
Contributor Author

I've tried to reproduce the error locally but they are passing for me. It seems like that this issue is caused by a racing condition while applying the migrate() function to the database.

@maxcountryman
Copy link
Owner

That sounds like it could be the culprit. I had to work around this with some of the SQLx stores. I'm not sure what the correct thing to do here is, since it seems unlikely to matter in a real application.

This commit adds a custom diesel backed session store. It abstracts over
different database backends and allows to customize the used session
table.
This also enables the "bundled" feature for libsqlite to not care about
getting libsqlite3 setup everywhere
Diesel uses libmysqlclient internally, which tries to be clever by using
a unix socket instead of a network socket if it
sees a database url that contains `localhost` as a host name. That won't
work in this case, as the db is running in a docker container. This
change switches to use `127.0.0.1` as host instead which forces the
usage of a network socket.
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #42 (2fadc5d) into main (79dc19b) will decrease coverage by 1.79%.
The diff coverage is 75.43%.

@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
- Coverage   84.51%   82.72%   -1.79%     
==========================================
  Files          13       14       +1     
  Lines         465      579     +114     
==========================================
+ Hits          393      479      +86     
- Misses         72      100      +28     
Files Coverage Δ
src/lib.rs 21.42% <0.00%> (-3.58%) ⬇️
src/diesel_store.rs 76.78% <76.78%> (ø)

@maxcountryman maxcountryman merged commit a476b8b into maxcountryman:main Oct 18, 2023
16 of 18 checks passed
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.

2 participants