-
Notifications
You must be signed in to change notification settings - Fork 61
have flush return the count of successful invalidation requests #47
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
@@ -106,11 +106,12 @@ public function flush() | |||
{ | |||
$queue = $this->queue; | |||
if (0 === count($queue)) { | |||
return; | |||
return 0; |
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.
note that this is no real BC break as we did not respect the fluent interface we promised in the interface...
hm, travis fails but i think this reveals we have an issue here. failing because something was not cached makes no sense - the application can't know if the document is cached or not. do we want to ignore 404 errors or do we want to change our propsed varnish configuration? probably a 204 No Content response code would make most sense. |
->purge('/a') | ||
->flush() | ||
); | ||
} |
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.
Does this need to be a functional rather than a unit test?
Yeah, please change that in |
@@ -167,7 +169,10 @@ protected function sendRequests(array $requests) | |||
$this->client->send($allRequests); | |||
} catch (MultiTransferException $e) { | |||
$this->handleException($e); | |||
$count = $e->getSuccessfulRequests(); |
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.
This conflates the two meanings of “number of requests”: now $count
no longer means “number of requests sent to each proxy” but “number of (successful) requests sent in total to all proxies together”.
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.
ouch, you are right. hm, i guess this will become very difficult to handle. what should we do? return -1 if there is at least one success, to indicate the number could not be determined due to a partial error? we could divide by the number of backends but that is a wild guess...
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.
Or simply change the statistic to mean “total number of (successful) requests”? Would that make it less useful?
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.
trying to build a test for this helped - it just can't matter, as handleException throws the retransformed exception and we never return a count for a (partially) failed invalidation action.
} | ||
} | ||
|
||
sub vcl_miss { | ||
if (req.request == "PURGE") { | ||
purge; | ||
error 404 "Not in cache"; | ||
error 204 "Purged (Not in cache)"; |
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.
like this its still debuggable what is going on.
okay, updated. i think now it makes sense. we probably want to handle the exceptions in the symfony console listener and print some information that cache invalidation did not work out. (if no invalidation was sent, i would expect to have no exception ever, so that should be correct to report when something went wrong) |
@@ -168,6 +170,8 @@ protected function sendRequests(array $requests) | |||
} catch (MultiTransferException $e) { | |||
$this->handleException($e); | |||
} | |||
|
|||
return $count; |
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.
No need for setting a variable anymore. Just return count($requests)
directly.
One minor detail, looks fine otherwise. |
removed the $count variable. |
@@ -6,6 +6,7 @@ | |||
use FOS\HttpCache\Invalidation\Varnish; | |||
use Guzzle\Http\Client; | |||
use Guzzle\Http\Exception\CurlException; | |||
use Guzzle\Http\Exception\MultiTransferException; |
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.
Looks like this is not being used.
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.
you are right. updated.
simplified and squashed. |
have flush return the count of successful invalidation requests
Thanks! |
as discussed in https://github.com/ddeboer/FOSHttpCacheBundle/pull/38/files#r10415347