-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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: carve out modules from Main.hs
#1814
Conversation
I've added a summary of what changed to the top comment. Suggest that we make a cut here, WDYT @wolfgangwalther ? Thank you for all the review!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it! My head is burning a bit, because this a bit harder to review, but I'm still alive.
It's a bit annoying that this is one of the areas where we're really missing a few tests. Need to review a bit more carefully to make sure there is no change in behaviour. Refactoring with 100% coverage is a lot more fun ;)
Yes, please! :D |
Thank you so much for your thorough review! Working on the fixes |
@wolfgangwalther I think that's it! All review comments should be adressed, in individual commits since you reviewed. I didn't touch the history. Shall we merge? |
Apart from the still wrong comment, everything else looks good. Could you rebase/squash in a way, that everything is in one
(I hope I got all of those?) Would be good to separate those in the history, because they change behaviour. And we can then put them in the changelog, too, when they are properly prefixed and separated. |
765b7dc
to
e861a16
Compare
Yes, that's good! Everything else was just reshuffling stuff around. @wolfgangwalther, I hope you will not be too sad, I think this was the last mega-refactor for now. Now that we have split up a lot of stuff, the further changes will be more localized. Thank you so much for bearing with me on this! |
Something went wrong with rebasing. The |
Yes, weird - must have slipped by as I reordered the commits, would have expected a rebase conflict. Added it back in. |
This will reduce the amount of code under conditional CCP compilation, making the code easier to reason about. Carving out modules will also increase unit testing opportunities.
Very WIP.
Edit: I converged to the following structure, to summarize:
PostgREST.AppState
encapsulate all stateful pieces of our application. It's now the only module handlingMVars
,IORefs
etc. This makes it very obvious where state is used in other modules, and makes it easier to refactor the state further.PostgREST.Workers
contains all current workers. They seem a bit convoluted right now, I tried to clarify the current setup by avoiding passing aroundconnWorker :: IO ()
etc. More work to be done here to simplifyPostgREST.Config
has a simplified interface - parsing the config is now one function, not puzzling together with the right incantation of multiple functions. Config could be signifcantly refactored now that most (soon: all?) options are optional and we have several config sources (env, config file, db..)PostgREST.Config.Database
contains a few of the config from db pieces (e.g. the statement, that was a bit out of place with the request/query stuff) - more to come as we refactor Config down the linePostgREST.Unix
now contains all the unix-specific functionality (from UnixSocket and things in old Main)PostgREST.CLI
absorbed a bit more of the miscellaneous functionality of the executable. To be further sorted out as we goMain
now is quite minimal, also regarding external dependencies. Minimal code is under conditional CPP compilation