Skip to content

Commit 42ff6dd

Browse files
dbuddeboer
authored andcommitted
have extension point for dynamic caching servers in HttpDispatcher (#352)
1 parent a627d4c commit 42ff6dd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/ProxyClient/HttpDispatcher.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class HttpDispatcher
7171
* If you specify a custom HTTP client, make sure that it converts HTTP
7272
* errors to exceptions.
7373
*
74+
* If your proxy server IPs can not be statically configured, extend this
75+
* class and overwrite getServers. Be sure to have some caching in
76+
* getServers.
77+
*
7478
* @param string[] $servers Caching proxy server hostnames or IP
7579
* addresses, including port if not port 80.
7680
* E.g. ['127.0.0.1:6081']
@@ -170,6 +174,16 @@ public function flush()
170174
return count($queue);
171175
}
172176

177+
/**
178+
* Get the list of servers to send invalidation requests to.
179+
*
180+
* @return UriInterface[]
181+
*/
182+
protected function getServers()
183+
{
184+
return $this->servers;
185+
}
186+
173187
/**
174188
* Duplicate a request for each caching server.
175189
*
@@ -214,7 +228,7 @@ private function fanOut(RequestInterface $request)
214228
$request = $request->withUri($uri)->withHeader('Connection', 'Close');
215229

216230
// Create a request to each caching proxy server
217-
foreach ($this->servers as $server) {
231+
foreach ($this->getServers() as $server) {
218232
$requests[] = $request->withUri(
219233
$uri
220234
->withScheme($server->getScheme())

0 commit comments

Comments
 (0)