-
-
Notifications
You must be signed in to change notification settings - Fork 44
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 the diesel pool support #59
Conversation
Thanks for this. I'm starting to wonder if it's not better to encourage folks to implement If we did take that path, we could instead have a Diesel example of a concrete implementation for a given store. |
862c808
to
9422338
Compare
Codecov Report
@@ Coverage Diff @@
## main #59 +/- ##
===========================================
+ Coverage 64.67% 80.66% +15.98%
===========================================
Files 13 13
Lines 569 574 +5
===========================================
+ Hits 368 463 +95
+ Misses 201 111 -90
|
042cc60
to
eb6c0cf
Compare
I believe having a single generic implementation might be much easier for users than having to implement that again and again for slightly different use-cases. Especially given that some users might require more or less all that degrees on freedom in their own implementation. |
Okay I'm having difficulty migrating this as part of the work on #57. While I'm working on that patch, I've removed the Diesel store but I can try adding it based on the changes here. |
I'm happy to help with such problems. |
Thanks I appreciate that--I'll create a separate branch we can work from. |
I've rebased this on top of #64 |
Hm seems like we're having the same issue: zero tests are selected for e.g. the r2d2 flag. I feel like we need a more reliable way to ensure these tests actually run. |
I'm also a bit concerned this requires hacking around the various backends to support generically. Doesn't that imply that it's going to be more efficient to implement this in a concrete way for each backend? For example, having to query the row first adds additional overhead that isn't necessarily required given a concrete database. In what circumstances would I use this over implementing |
These tests are enabled here: https://github.com/maxcountryman/tower-sessions/pull/59/files#diff-73e17259d77e5fbef83b2bdbbe4dc40a912f807472287f7f45b77e0cbf78792dR128-R137
Well it's complicated. Yes implementing the trait for a specifc backend would allow you to write more efficient queries, but that raises the problem that users need to match feature flags for diesel and tower-sessions. Additionally tower-sessions would mean to provide support of all possible (third party) diesel backends. So essentially: You be willing to accept store implementations for the firebird sql adaptor for diesel? My feeling was that this would likely be not accepted, therefore I've chosen a generic implementation that hopefully works out of the box on all backends. That's mostly the generic answer. To give a more concrete answer to the specific problem: I've chosen for now not to change tower-sessions outside of the |
It's also possible to implement this as its own crate. Perhaps more generally that's the better pattern to follow (not just for Diesel, but all storage backends). I'd like to cut a new release so it's a bit awkward with Diesel changes pending (again, I want to point point that's not a fault of Diesel but rather the fact we're bundling built in backends). |
Just wanted to make sure that it's clear that in this PR the Diesel integration tests are not being selected and therefore not running. I can't merge this until those tests are passing. At the same time I want to cut a new release so what I may do is exclude Diesel in main for the time being--I'm sorry to have to do that again, but I am blocked on this and I don't want to push out changes that aren't covered by the integration tests. Please let me know what you think about breaking this out into its own crate. |
I'm not familiar with the CI setup of this repo, so its hard to tell for me why these the tests are not run. All I can say is that using the listed flags in a local test run results in the tests being executed successfully. I'm glad to change the integration in the CI setup if you provide some pointers about what needs to be changed. Also: The changes are covered by integration tests. You can verify that locally if it really blocks you. (Although I can understand the need to run those tests on CI) |
I believe this is an issue with cargo and the feature flags independent of CI. You might want to look at how the flags are being passed to the runner tho. Again the issue is that no tests are selected which seems to be because the features aren't matching. |
This PR also has numerous merge conflicts so to merge this we need to resolve those conflicts and get the integration tests to select the proper tests and pass. |
For what it's worth, the test selection issue does not seem to be related to CI. For example, when running this branch locally, here's what I see:
Via commit Looking at the I think this might be a consequence of 7e59cd0 being force-pushed onto the branch. |
This commit refactors the support for connection pools for diesel. Instead of only allowing `r2d2` based pools we now abstract the actual pool away. It also adds support for `deadpool-diesel` based pools as alternative.
The issue here was caused by the force push--that commit removed the feature flags which meant the tests were not selected. It wasn't related to CI. I'm unclear what you're finding confusing about the CI workflow, which is based directly on cargo, but I'm happy to answer any questions you have. As for the commit I excluded in main, I did so because it was only created to demonstrate the issue with the tests not running and revealed an issue with the implementation itself which caused a failed test run. It wouldn't have made sense to include it in main since it prevented the rest of the suite from running. However, I needed to move forward with pending changes and couldn't wait for this PR to be updated. I'm sorry about that, I should have made that clear. Fixing that particular issue should be as easy as rebasing and excluding that commit. |
I must disagree here. This was purely related to how your CI setup works, as just doing a
The relevant PR has a passing CI test suite: https://github.com/maxcountryman/tower-sessions/pull/64/checks, therefore I really cannot follow your point why this would "prevent the rest of the suite from running".
Maybe we misunderstood each other here. This PR was built on top of the minimal fix. You could have merged that fix and moved on, while waiting for that PR being fixed. Anyway this PR is now ready for review and passes all tests on CI, so please let me know what else you expect here. |
I'm sorry to argue here but that just is not correct: the force push is what broke this PR. If you find the Actions workflow confusing, that's fair but that has nothing to do with the force push removing the flags altogether, which is what happened. That's a n issue with force pushing to a remote branch and generally discouraged re git. |
This is not correct. The test suite was not selecting tests for Diesel. I could not merge that. |
I feel like we are arguing in circles here. The fundamental issue why the diesel tests were not executed from the start is this line in your CI setup. The |
The tests were working before the force push excluded the feature flags thanks to the fix you made in a separate PR. Is the CI interface obvious? No. I agree with you. (And it would be helpful to have contributors improve this as they encounter these things.) However, the issue remains the exclusion of the flags in the force push in this PR. Locally I was able to run the tests yesterday by using the included flags. |
Here's where I'm at: this is a ton of friction. I don't really know where things went wrong here but what I do know is I cannot maintain this implementation. You've offered to help (thank you so much for that, it's truly appreciated). But you're encountering friction given how this repo is setup (again I'm sorry about that, that isn't what I would want). This implementation itself doesn't seem ideal: it's not async but is in the core of a crate that's fundamentally async. It also has to compromise on performance in order to be generic. I agree with your points around making things easy for on ramping, so this is not to say those are bad decisions. However, I'm not sure this doesn't belong in its own crate. This is the same approach that async-session took: it demarcates boundaries between the core session management bits and individual backends that implement SessionStore. This also means that changes to the core crate aren't entangled with the stores which would relieve the tension we've encountered here. It was probably a mistake for me to bundle any backends, but so it goes. |
No, the tests were not executed before the force push. See for example this CI run from #55.
I'm not sure what you are referring to but the last CI run executed all tests. They worked on the version from yesterday as well, the CI filtered them out for naming reasons.
Well it would have been great if you had communicated that before I've spend quite a lot of time to implement all the necessary stuff. It's also frustrating to only get the message: "Tests are run working" without any indication that this is likely just a "broken" CI setup (which to be clear is not really related to the diesel backend at all.). I honestly start to consider that trying to contribute here is a mistake and I should just stop as my contributions are not wanted here.
I've already pointed out that this "compromise on performance " can be easily removed.
In the end it's your decision as this is your crate. I would argue that you should handle sqlx support and diesel support in the same way. So if you move support for one into a separate crate you should handle support for the other one in the same way. If you keep one in the core crate you should keep the other one there as well. Also moving support for certain stores into separate crates does not really answer who should maintain them. To be very clear here: I do not have the capacity to maintain any additional crate. |
It's clear to me we won't be able to work together productively. Thank you again for all the effort here, it might not feel like it's appreciated but it is. I've decided this will be best implemented as a standalone crate. |
It would help if you would communicate clearly what you expect from changes, instead of changing your opinion every time. Also it would have been really helpful to actually suggest solutions instead of saying "It doesn't work, fix it now, its blocking me". That's an attitude that strange in the rust community. I will likely warn people about interacting with this project due to this attitude. Consider changing that if you want to make this project successful.
Well, that confirms suspicions. My work is obviously not appreciated here.
It would have been great to know that as part of the initial issue or the initial PR. It would have saved a lot of work on both sides. Also it demonstrates quite good what I've wrote above about changing opinions all the time. |
Truly, I apologize: if that's what you heard, that's unfortunate. I'm sorry. I clearly communicated poorly and that's on me.
😢 I'm not sure what I can do, but I am sorry you feel this way. I completely understand this is not the outcome you were hoping for, still it doesn't change the fact that I do appreciate the work you put into this.
I could not agree more: I am sorry that you spent time on this only to reach this conclusion. That said, the input for this decision largely came from this PR. For example, it's clear to me after having tried to work on this branch that I can't maintain this and you've now said you don't have the bandwidth either. So with that, I don't think we can in good faith include this implementation: neither of us can maintain it. However, that was not clear when this PR was opened so it wouldn't have been possible to reach such a conclusion before we had the input that was uncovered over the course of working on this PR. I understand your frustration. I am sorry you run into these issues--it sucks and as a crate author, it's not the outcome I'm aiming for. I'm wishing you the best going forward and if there's anything I can do to show you my good faith, I'd be happy to do so. |
To bring this discussion back to something more productive: What would need to change that this becomes maintainable for you? Would it help to replace the generic implementation with something that is backend specific? That would probably mean its a bit more code and that it is not as universal as possible, but if that helps you to better work with the implementation thats a huge argument to go with that solution instead. |
One problem I'm running into is that I haven't used Diesel for several years now (and unfortunately I'm not actively using it elsewhere at this time). This creates an organic limitation on my ability to be helpful with Diesel and is a barrier to my effectiveness in supporting it. Most likely I would still need the help of someone from the Diesel community, even if we had specific backend implementations, who would be willing to take point on the maintenance of this implementation. This is also where I start to think that standalone crates make more sense: I'm not the best person to be providing support for an ecosystem I'm not current with and it's unfortunate for the core of this crate to be a bottleneck to developing and publishing support for store backends. If we essentially will require individuals to provide maintenance for implementations, then maybe that should be over the scope of a standalone crate. Now one thing we could consider is if it would make sense to create a workspace of crates within this repo--then we don't need separate repos or if we should follow a pattern similar to async-session where crates live in their own repos. Of course, we have preexisting implementations, so those would also ideally be migrated to their own crates, whichever pattern we might follow should we pursue this. Returning to your original question, it's absolutely possible that specific backends lower the maintenance burden such that I can independently manage them. But I want to be careful about promising that because I don't know enough about the current state of Diesel to confidently say one way or the other. |
I've created a striped down version of the diesel store here. It only implement support for postgres for now. I removed the backend unspecific generic code + the flexibility to change the session table, which in turn removes most of the complicated looking generic code. I've opted for leaving support for several pooling solutions in place as that looked like "simple" code in my opinion. Code is here: |
@maxcountryman Do you have any opinion on the simplified implementation? |
Sorry for the delay, I've been trying to get axum-login migrated. I'm planning to take a closer look at the implementation this weekend. My hope is to distill the store vendoring strategy further, which will also help me evaluate how to best support things like Diesel. |
I've got a PR open to address the workspace configuration: #86. Hopefully I can get that merged soon and then I'll be returning to this. Thanks for your patience here. |
Thanks for keeping me updated 👍 |
I had another look at this but realized that it's depending directly on |
I'm not sure I can follow what you are trying to say there. As far as I can see from the API docs all relevant methods on |
Maybe I'm misunderstanding how Diesel works (very likely) but it seems like there's a trait that needs to be implemented for |
It's not necessary to implement any trait for session. In fact the implementation linked above already works without such an trait implementation. You can always load data into a tuple and map afterwards (or take them from session into a tuple for inserts). |
@maxcountryman It would be great to have a response from you whether or not linked implementation would be acceptable. |
@maxcountryman This is another ping to get you feedback on the implementation linked above. |
@maxcountryman This is another ping to get your feedback on the implementation linked above. |
I found myself needing this today. I wrote an impl of the needed traits but only for the async-diesel, deadpool, sqlite combo. I was thinking of putting a crate online for that combo since I need it. |
I did consider whether I should abstract over the pool/connection type myself, as it seems like a lot of code duplication if not doing that. The only part that felt a bit "unclean" is to abstract over a |
This commit refactors the support for connection pools for diesel. Instead of only allowing
r2d2
based pools we now abstract the actual pool away. It also adds support fordeadpool-diesel
based pools as alternative.