Update job queue, separate deletes into their own queue

This commit is contained in:
Daniel Supernault 2021-07-13 23:09:50 -06:00
parent 3b071e56ac
commit 7f4213924f
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 309 additions and 283 deletions

View file

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Jobs\InboxPipeline\{
DeleteWorker,
InboxWorker,
InboxValidator
};
@ -104,7 +105,13 @@ class FederationController extends Controller
$headers = $request->headers->all();
$payload = $request->getContent();
$obj = json_decode($payload, true, 8);
if(isset($obj['type']) && $obj['type'] === 'Delete') {
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
} else {
dispatch(new InboxValidator($username, $headers, $payload))->onQueue('high');
}
return;
}
@ -115,7 +122,13 @@ class FederationController extends Controller
$headers = $request->headers->all();
$payload = $request->getContent();
$obj = json_decode($payload, true, 8);
if(isset($obj['type']) && $obj['type'] === 'Delete') {
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
} else {
dispatch(new InboxWorker($headers, $payload))->onQueue('high');
}
return;
}

View file

@ -50,7 +50,7 @@ class DeleteWorker implements ShouldQueue
$payload = json_decode($this->payload, true, 8);
if(isset($payload['id'])) {
$lockKey = hash('sha256', $payload['id']);
$lockKey = 'pf:ap:del-lock:' . hash('sha256', $payload['id']);
if(Cache::get($lockKey) !== null) {
// Job processed already
return 1;
@ -116,6 +116,18 @@ class DeleteWorker implements ShouldQueue
return;
}
$profile = null;
if($this->verifySignature($headers, $payload) == true) {
(new Inbox($headers, $profile, $payload))->handle();
return;
} else if($this->blindKeyRotation($headers, $payload) == true) {
(new Inbox($headers, $profile, $payload))->handle();
return;
} else {
return;
}
}
protected function verifySignature($headers, $payload)

View file

@ -82,6 +82,7 @@ return [
'redis:feed' => 30,
'redis:default' => 30,
'redis:high' => 30,
'redis:delete' => 30
],
/*
@ -165,7 +166,7 @@ return [
'production' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['high', 'default', 'feed'],
'queue' => ['high', 'default', 'feed', 'delete'],
'balance' => 'auto',
'maxProcesses' => 20,
'memory' => 128,
@ -177,7 +178,7 @@ return [
'local' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['high', 'default', 'feed'],
'queue' => ['high', 'default', 'feed', 'delete'],
'balance' => 'auto',
'maxProcesses' => 20,
'memory' => 128,