-
Notifications
You must be signed in to change notification settings - Fork 84
Let user determine how to handle socket errors #169
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
Conversation
StephenWakely
left a comment
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.
Thank you for this! I just have a small nit around the test...
| })); | ||
|
|
||
| $this->getSocketSpy()->errorThrownOnSend = function () { | ||
| throw new ErrorException('ErrorException: socket_sendto(): Unable to write to socket [111]: Connection refused'); |
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 would be more accurate to call trigger_error with E_USER_WARNING here. PHPUnit has an error handler that then throws an ErrorException, so it amounts to the same thing, but just makes it a little clearer what is going on.
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.
Done.
StephenWakely
left a comment
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.
Nice. Thank you.
Thanks for the quick review and merge @StephenWakely 🙇 Do you know when we might expect this functionality to be released in a new version? I want to make some updates to https://github.com/cosmastech/laravel-statsd-adapter as well as our production systems. 😃 |
|
@cosmastech It is now released. Thanks for your contribution! |
This creates a new parameter for configuration:
flush_failure_handler. This is a callable or null.Why this is necessary: we see socket failures happen far too frequently, and it's very annoying to have to wrap each and every stat write in a try-catch. In our code, we can simply pass something like:
which will write an error to our logs and carry on.
See #168