cpjk / canary

:hatching_chick: Elixir authorization and resource-loading library for Plug applications.
MIT License
474 stars 51 forks source link

Add new plug option: :repo #76

Closed lucas-nelson closed 4 years ago

lucas-nelson commented 6 years ago

When using the plug, support a :repo option that when used will override the default repo from the configuration.

This can be used in applications that have different repos (databases) for different controllers / actions.

In my case the application has a primary and a replica MySQL database. Read actions go to the replica and write actions go to the primary. We could have configured canary just to use the primary, but that would put extra reads on the primary that ideally we would avoid.

Also there was a problem during testing because each Repo is sandboxed, so the test would create records in the replica database for testing. But, when we added canary for authorization (configured to use the primary repo), the tests failed because the primary repo sandbox did not contain the records.

cpjk commented 4 years ago

👋 Hey! I'm sorry for the lack of movement on this. I shouldn't have left this for so long without a reply.

I am not currently writing Elixir at all, and therefore, I think it would be irresponsible of me to review PRs on this project. I just kept putting off reviewing the issues/PRs on this repo until I started writing Elixir again, but never got around to it.

That is my mistake, and I'm really sorry about that 🙏. You put in the time to make this PR, and you deserve a response at the very least.

I've marked the project as "not being actively maintained" in the readme. Please feel free to fork it with a different name and put it up on hex with current fixes.