-
Notifications
You must be signed in to change notification settings - Fork 12
Add microsecond timeouts to bedrock client #227
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,11 +90,21 @@ class Client implements LoggerAwareInterface | |
| */ | ||
| private $connectionTimeout; | ||
|
|
||
| /** | ||
| * @var int Microsecond timeout for connecting to the server. | ||
| */ | ||
| private $connectionTimeoutMicroseconds; | ||
|
|
||
| /** | ||
| * @var int Timeout for reading the response from the server. | ||
| */ | ||
| private $readTimeout; | ||
|
|
||
| /** | ||
| * @var int Microsecond timeout for reading the response from the server. | ||
| */ | ||
| private $readTimeoutMicroseconds; | ||
|
|
||
| /** | ||
| * @var int Timeout to pass to bedrock. | ||
| */ | ||
|
|
@@ -149,7 +159,9 @@ class Client implements LoggerAwareInterface | |
| * array|null mainHostConfigs List of hosts to attempt first | ||
| * array|null failovers List of hosts to use as failovers | ||
| * int|null connectionTimeout Timeout to use when connecting | ||
| * int|null connectionTimeoutMicroseconds Microsecond timeout to use when connecting | ||
| * int|null readTimeout Timeout to use when reading | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| * int|null readTimeoutMicroseconds Microsecond timeout to use when reading | ||
| * int|null bedrockTimeout Timeout to use for bedrock commands | ||
| * LoggerInterface|null logger Class to use for logging | ||
| * StatsInterface|null stats Class to use for statistics tracking | ||
|
|
@@ -167,7 +179,9 @@ private function __construct(array $config = []) | |
| $this->mainHostConfigs = $config['mainHostConfigs']; | ||
| $this->failoverHostConfigs = $config['failoverHostConfigs']; | ||
| $this->connectionTimeout = $config['connectionTimeout']; | ||
| $this->connectionTimeoutMicroseconds = $config['connectionTimeoutMicroseconds']; | ||
| $this->readTimeout = $config['readTimeout']; | ||
| $this->readTimeoutMicroseconds = $config['readTimeoutMicroseconds']; | ||
| $this->bedrockTimeout = $config['bedrockTimeout']; | ||
| $this->logger = $config['logger']; | ||
| $this->stats = $config['stats']; | ||
|
|
@@ -241,7 +255,9 @@ public static function configure(array $config) | |
| 'mainHostConfigs' => ['localhost' => ['blacklistedUntil' => 0, 'port' => 8888]], | ||
| 'failoverHostConfigs' => ['localhost' => ['blacklistedUntil' => 0, 'port' => 8888]], | ||
| 'connectionTimeout' => 1, | ||
| 'connectionTimeoutMicroseconds' => 0, | ||
| 'readTimeout' => 120, | ||
| 'readTimeoutMicroseconds' => 0, | ||
| 'bedrockTimeout' => 110, | ||
| 'logger' => new NullLogger(), | ||
| 'stats' => new NullStats(), | ||
|
|
@@ -531,8 +547,8 @@ private function sendRawRequest(string $host, int $port, string $rawRequest) | |
| } | ||
|
|
||
| // Configure this socket and try to connect to it | ||
| socket_set_option($this->socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => $this->connectionTimeout, 'usec' => 0]); | ||
| socket_set_option($this->socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => $this->readTimeout, 'usec' => 0]); | ||
| socket_set_option($this->socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => $this->connectionTimeout, 'usec' => $this->connectionTimeoutMicroseconds]); | ||
| socket_set_option($this->socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => $this->readTimeout, 'usec' => $this->readTimeoutMicroseconds]); | ||
| @socket_connect($this->socket, $host, $port); | ||
| $socketErrorCode = socket_last_error($this->socket); | ||
| if ($socketErrorCode === 115) { | ||
|
|
||
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.
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.
Can we remove this after the transition period?
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'll do some tests to see if you can pass a timeout of several seconds in the useconds param or if it is just for the subsecond part of the timeout.
Uh oh!
There was an error while loading. Please reload this page.
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 not test https://github.com/Expensify/Web-Expensify/pull/47169#issuecomment-2966170884
We can probably leave this anyway