-
Notifications
You must be signed in to change notification settings - Fork 78
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
Use HttpClient in SessionTracker #582
Merged
imjoehaines
merged 3 commits into
project/session-tracking-rework
from
use-http-client-in-session-tracker
Jun 5, 2020
Merged
Use HttpClient in SessionTracker #582
imjoehaines
merged 3 commits into
project/session-tracking-rework
from
use-http-client-in-session-tracker
Jun 5, 2020
Conversation
This file contains 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
This change unifies the SessionTracker and Client WRT how they use Guzzle. They now both use the HttpClient abstraction, which also allows them to share a Guzzle instance. This means that we can't use the base URI feature of Guzzle anymore because the notify and session endpoints are on separate subdomains. However this isn't a big deal as we POST to the root in most cases anyway; the only exception being the deploy notification, which is '/deploy' BC breaks: - Removal of Client and Configuration 'getSessionClient' This doesn't make sense to keep given the session client is now the same as the notify Guzzle client. Keeping this would mean changes to the "session" client also propagate to the notify client, which could lead to things being delivered to the wrong endpoint - We no longer use the Guzzle base URI for requests This means if a Guzzle client is passed in the constructor with a pre-defined base URI, we will still send requests to the notify URI. Client::setNotifyEndpoint now needs to be called manually instead. This changed because the Guzzle base URI is ambiguous now given that it is shared between notifications and sessions - Removal of SessionTracker::setConfig This was unused internally and doesn't seem to be needed as the configuration can be changed via the Client or Configuration instance itself. Having the posibility for there to be two different Configuration instances could be dangerous Additionally several constants have been deprecated as they are no longer used. Specifically these are: - Client::ENDPOINT This is ambiguous as we have three separate endpoints Use Configuration::NOTIFY_ENDPOINT instead - HttpClient::PAYLOAD_VERSION This is ambiguous as there is a session payload version too Use HttpClient::NOTIFICATION_PAYLOAD_VERSION instead - Report::PAYLOAD_VERSION As above. This was also unused by the notifier Use HttpClient::NOTIFICATION_PAYLOAD_VERSION instead - SessionTracker::$SESSION_PAYLOAD_VERSION Use HttpClient::SESSION_PAYLOAD_VERSION instead Finally, Client::makeGuzzle has been deprecated as it is only used in one place internally to Client and therefore doesn't need to be public
imjoehaines
commented
Jun 4, 2020
imjoehaines
changed the base branch from
master
to
project/session-tracking-rework
June 4, 2020 12:51
15 tasks
tomlongridge
reviewed
Jun 5, 2020
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.
Looks good, just a few small tweaks suggested.
Can you also add a changelog for this so we can track the public changes for this block of work?
imjoehaines
force-pushed
the
use-http-client-in-session-tracker
branch
from
June 5, 2020 13:12
a26f087
to
dd2bd2d
Compare
tomlongridge
approved these changes
Jun 5, 2020
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.
Goal
This change unifies the SessionTracker and Client WRT how they use Guzzle. They now both use the HttpClient abstraction, which also allows them to share a Guzzle instance. This means that we can't use the base URI feature of Guzzle anymore because the notify and session endpoints are on separate subdomains. However we always POST to the root so weren't really taking advantage of this anyway
Changeset
BC breaks
Removal of
getSessionClient
method inClient
andConfiguration
This doesn't make sense to keep given the session client is now the same as the notify Guzzle client. Keeping this would either mean changes to the "session" client also propagate to the notify client or changes to this do nothing. Either of which could lead to things being delivered to the wrong endpoint and expected Guzzle changes not being reflected in the actual requests
We no longer use the Guzzle base URI for requests
This means if a Guzzle client is passed in the constructor with a pre-defined base URI, we will still send requests to the notify URI.
Client::setNotifyEndpoint
now needs to be called manually instead. This changed because the Guzzle base URI is ambiguous now given that it is shared between notifications and sessionsRemoval of
SessionTracker::setConfig
This was unused internally and doesn't seem to be needed as the configuration can be changed via the
Client
orConfiguration
instance itself. Having the possibility for there to be two differentConfiguration
instances could be dangerous as changes may not propagate as expectedClient::ENDPOINT
This is ambiguous as we have three separate endpoints
Use
Configuration::NOTIFY_ENDPOINT
insteadHttpClient::PAYLOAD_VERSION
This is ambiguous as there is a session payload version too
Use
HttpClient::NOTIFY_PAYLOAD_VERSION
insteadReport::PAYLOAD_VERSION
As above. This was also unused by the notifier
Use
HttpClient::NOTIFY_PAYLOAD_VERSION
insteadSessionTracker::$SESSION_PAYLOAD_VERSION
Use
HttpClient::SESSION_PAYLOAD_VERSION
insteadClient::makeGuzzle
has been made privateUse the
$guzzle
parameter ofBugsnag\Client::__construct
insteadTests
The existing tests have been modified to avoid using the removed methods and the
SessionTracker
mocks updated to useHttpClient
rather than Guzzle. Otherwise this is covered by existing testsDiscussion
Outstanding Questions
In the original PR for this (#521) we pulled the base URI out of the Guzzle instance that can be passed to the
Client
constructor and set the notify endpoint based on thatI'm not convinced whether that's a good idea — we can't use the base URI feature of Guzzle as we're sharing a single Guzzle client for two different URIs so they have to be absolute. That means if a base URI is set then it will be ignored anyway, because the absolute URI makes it irrelevant (the idea is you set
base_uri => 'https://example.com
and then can requesthttps://example.com/foo
by passingfoo
to Guzzle)Linked issues
Supersedes #521
Fixes #558
Review
For the submitter, initial self-review:
For the pull request reviewer(s), this changeset has been reviewed for: