@@ 32-48 (lines=17) @@ | ||
29 | * |
|
30 | * @throws \RuntimeException If proxy is not reachable within timeout |
|
31 | */ |
|
32 | protected function waitFor($ip, $port, $timeout) |
|
33 | { |
|
34 | if (!$this->wait( |
|
35 | $timeout, |
|
36 | function () use ($ip, $port) { |
|
37 | return false !== @fsockopen($ip, $port); |
|
38 | } |
|
39 | )) { |
|
40 | throw new \RuntimeException( |
|
41 | sprintf( |
|
42 | 'Caching proxy cannot be reached at %s:%s', |
|
43 | $ip, |
|
44 | $port |
|
45 | ) |
|
46 | ); |
|
47 | } |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * Wait for caching proxy to be started up and reachable. |
|
@@ 59-75 (lines=17) @@ | ||
56 | * |
|
57 | * @throws \RuntimeException If proxy is not reachable within timeout |
|
58 | */ |
|
59 | protected function waitUntil($ip, $port, $timeout) |
|
60 | { |
|
61 | if (!$this->wait( |
|
62 | $timeout, |
|
63 | function () use ($ip, $port) { |
|
64 | return false === @fsockopen($ip, $port); |
|
65 | } |
|
66 | )) { |
|
67 | throw new \RuntimeException( |
|
68 | sprintf( |
|
69 | 'Caching proxy still up at %s:%s', |
|
70 | $ip, |
|
71 | $port |
|
72 | ) |
|
73 | ); |
|
74 | } |
|
75 | } |
|
76 | ||
77 | protected function wait($timeout, $callback) |
|
78 | { |