forked from solariumphp/solarium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate endpoint timeout (solariumphp#767) (solariumphp#769)
- Loading branch information
Showing
10 changed files
with
74 additions
and
15 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,10 @@ | |
* | ||
* @author Intervals <[email protected]> | ||
*/ | ||
class Curl extends Configurable implements AdapterInterface | ||
class Curl extends Configurable implements AdapterInterface, TimeoutAwareInterface | ||
{ | ||
use TimeoutAwareTrait; | ||
|
||
/** | ||
* Execute a Solr request using the cURL Http. | ||
* | ||
|
@@ -207,10 +209,10 @@ protected function init() | |
protected function createOptions($request, $endpoint) | ||
{ | ||
$options = [ | ||
'timeout' => $endpoint->getTimeout(), | ||
'timeout' => $this->timeout ?? $endpoint->getTimeout(), | ||
]; | ||
foreach ($request->getHeaders() as $headerLine) { | ||
list($header, $value) = explode(':', $headerLine); | ||
[$header, $value] = explode(':', $headerLine); | ||
if ($header = trim($header)) { | ||
$options['headers'][$header] = trim($value); | ||
} | ||
|
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Solarium\Core\Client\Adapter; | ||
|
||
/** | ||
* Contract for Http Adapters that are aware of timeouts. | ||
*/ | ||
interface TimeoutAwareInterface | ||
{ | ||
/** | ||
* default timeout that should be respected by adapters implementing this interface. | ||
*/ | ||
public const DEFAULT_TIMEOUT = 5; | ||
|
||
public function setTimeout(int $timeoutInSeconds): void; | ||
|
||
public function getTimeout(): int; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Solarium\Core\Client\Adapter; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
trait TimeoutAwareTrait | ||
{ | ||
/** | ||
* @var int|null | ||
*/ | ||
private $timeout; | ||
|
||
public function setTimeout(int $timeoutInSeconds): void | ||
{ | ||
$this->timeout = $timeoutInSeconds; | ||
} | ||
|
||
public function getTimeout(): int | ||
{ | ||
return $this->timeout ?? TimeoutAwareInterface::DEFAULT_TIMEOUT; | ||
} | ||
} |
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 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 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 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 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