HttpUtils Aggregation Pattern #349
Closed
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.
Files Changes
What has Changed?
HttpUtils.py now follows an aggregation pattern where instead of having
CLIENT_SESSIONact as a global variable it is now part of a boundary where it is only accessible through the root, where the root is an instance of the class 'Session'. This paradigm also applies toLOGGERwhereLOGGERis also part of the boundary.Because I have applied aggregation here, both
LOGGERandCLIENT_SESSIONare now encapsulated since their instance does not need to be seen individually but only through the lens of an instance of a Session.The logic and approach of
setup_client_session()andteardown_client_session()remain. What only changes is the encapsulation, and the aggregation of the objects that manage those methods.Why
This change seems appropriate as this change encourages keeping one client_session alive per user and managing that session through an instance of a class rather than passing that session where a lack of encapsulation could cause confusion. As such adding a boundary on the
CLIENT_SESSIONandLOGGERmakes perfect sense here through the work of aggregation.