Refactor ServerStorageCheckJob handle method to improve error handling and messaging
This commit is contained in:
@@ -31,8 +31,6 @@ class ServerStorageCheckJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (! $this->server->isFunctional()) {
|
if (! $this->server->isFunctional()) {
|
||||||
ray('Server is not ready.');
|
|
||||||
|
|
||||||
return 'Server is not ready.';
|
return 'Server is not ready.';
|
||||||
}
|
}
|
||||||
$team = data_get($this->server, 'team');
|
$team = data_get($this->server, 'team');
|
||||||
@@ -42,7 +40,7 @@ class ServerStorageCheckJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
$this->percentage = $this->server->storageCheck();
|
$this->percentage = $this->server->storageCheck();
|
||||||
}
|
}
|
||||||
if (! $this->percentage) {
|
if (! $this->percentage) {
|
||||||
throw new \Exception('No percentage could be retrieved.');
|
return 'No percentage could be retrieved.';
|
||||||
}
|
}
|
||||||
if ($this->percentage > $serverDiskUsageNotificationThreshold) {
|
if ($this->percentage > $serverDiskUsageNotificationThreshold) {
|
||||||
$executed = RateLimiter::attempt(
|
$executed = RateLimiter::attempt(
|
||||||
@@ -55,7 +53,7 @@ class ServerStorageCheckJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (! $executed) {
|
if (! $executed) {
|
||||||
throw new \Exception('Too many messages sent!');
|
return 'Too many messages sent!';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RateLimiter::hit('high-disk-usage:'.$this->server->id, 600);
|
RateLimiter::hit('high-disk-usage:'.$this->server->id, 600);
|
||||||
|
Reference in New Issue
Block a user