refactor: App control flow refactoring#4969
Draft
mkleczek wants to merge 1 commit into
Draft
Conversation
9d4b293 to
9350465
Compare
refactor: App control flow refactoring 1. Handling of NoDb ActionPlan in database related code. Make MainTx.mainTx and Query.mainQuery receive DbPlan instead of ActionPlan so that they do not have to handle unrelated NoDb cases. Removed "NoDbResult" constructor from "DbResult" datatype and factored out noDbActionResponse from actionResponse to clearly separate "DbResult" and "InfoPlan" handling. 2. Server timing is now handled using WriterT monad so that it does not pollute the control flow. Timings are accumulated in [(ByteString, Double)] list and then, if the list is not empty, passed to Performance.serverTimingHeader as (NonEmpty (ByteString, Double) 3. postgrestResponse now returns PgrstResponse and Wai.Response creation is moved to postgrest. The reason is that Wai.Response requires timings but timing gathering is split between postgrest and postgrestResponse functions. That made the code weird because postgrest must have passed JWT timing to postgrestResponse. Moving Wai.Response creation level up simplifies it.
9350465 to
42da614
Compare
Member
I'm confused: This is a self-reference and there is only one commit in here. |
Collaborator
Author
Yes, sorry - during reworking of this PR the description got outdated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
App control flow refactoring
Handling of NoDb ActionPlan in database related code.
Make MainTx.mainTx and Query.mainQuery receive DbPlan instead of ActionPlan so that they do not have to handle unrelated NoDb cases.
Removed "NoDbResult" constructor from "DbResult" datatype and factored out noDbActionResponse from actionResponse to clearly separate "DbResult" and "InfoPlan" handling.
Server timing is now handled using WriterT monad so that it does not pollute the control flow.
Timings are accumulated in
[(ByteString, Double)]list and then, if the list is not empty, passed to Performance.serverTimingHeader asNonEmpty (ByteString, Double)Moved authentication back to
App.postgrestResponseso that all steps that require timing are encapsulated. In refactor: remove auth and logging middleware #4884 it was moved level up the call chain which, while achieving the goal of removing auth middleware, made the control flow complicated and difficult to follow. Thanks to introduction ofWriterTbased handling of auth role in refactor: simplify control flow in App.postgrest #4968, it is now possible to return to have all request handling pipeline steps inApp.postgrestResponse. That also allows to makewithTiminglocal binding again.This PR is a follow up on #4968.