-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Feature/webhook transfer time #60
Conversation
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.
Could you also add a test to make sure that this works?
Tests seem to be failing now.
src/CallWebhookJob.php
Outdated
], $body)); | ||
'on_stats' => function (TransferStats $stats) { | ||
|
||
$this->response = $stats->getResponse(); |
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.
Do we have to do this, the response is already captured on line 72, no?
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.
It is redundant I've removed this and just set the entire TransferStats
instead.
src/CallWebhookJob.php
Outdated
'on_stats' => function (TransferStats $stats) { | ||
|
||
$this->response = $stats->getResponse(); | ||
$this->transferTime = $stats->getTransferTime(); |
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.
Instead of just passing transfertime, let's pass the entire $stats
src/CallWebhookJob.php
Outdated
@@ -133,6 +141,7 @@ private function dispatchEvent(string $eventClass) | |||
$this->response, | |||
$this->errorType, | |||
$this->errorMessage, | |||
$this->transferTime, |
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.
This is a breaking change. Move the added option as the last one and make it optional.
… object instead of only the transferTime property
src/CallWebhookJob.php
Outdated
|
||
$this->dispatchEvent(WebhookCallSucceededEvent::class); | ||
if (! Str::startsWith($response->getStatusCode(), 2)) { |
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.
Why do we throw the exception in on_stats? The previous code looks cleaner in this regard. Imho we just get the stats and nothing more here.
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 was originally under the impression that stats would not get set since the on_stats
hook is called after the responsee
and the event would be dispatched without the stats var set. Anyway, I've reverted and it works the same. I'll be adding test ASAP and updating the branch.
The tests are failing for this PR, could you take a look at that? |
The code seems fine, but the tests are failing. Can you take a look at that. Could you also add an example of the new functionality in the readme? |
Closing due to inactivity. |
This uses the
on_stats
request options to set the transferTime metric