-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Facades\EntityFacade; | ||
use App\Models\Entity; | ||
use App\Models\Federation; | ||
use App\Models\Membership; | ||
use App\Traits\HandlesJobsFailuresTrait; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\Log; | ||
use Illuminate\Support\Facades\Storage; | ||
use Mockery\Exception; | ||
|
||
class FolderAddMembership implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
use HandlesJobsFailuresTrait; | ||
|
||
public Membership $membership; | ||
|
||
/** | ||
* Create a new job instance. | ||
*/ | ||
public function __construct(Membership $membership) | ||
{ | ||
$this->membership = $membership; | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
*/ | ||
public function handle(): void | ||
{ | ||
Log::info('MEMBERSHIP START'); | ||
$federation = Federation::find($this->membership->federation_id); | ||
$entity = Entity::find($this->membership->entity_id); | ||
$diskName = config('storageCfg.name'); | ||
if (! Storage::disk($diskName)->exists($federation->name)) { | ||
$this->fail(); | ||
} | ||
$pathToDirectory = Storage::disk($diskName)->path($federation->name); | ||
$lockKey = 'directory-'.md5($pathToDirectory).'-lock'; | ||
$lock = Cache::lock($lockKey, 61); | ||
|
||
try { | ||
$lock->block(61); | ||
EntityFacade::saveMetadataToFederationFolder($entity->id, $federation->id); | ||
RunMdaScript::dispatch($federation, $lock->owner()); | ||
} catch (Exception $e) { | ||
$this->fail($e); | ||
} finally { | ||
if ($lock->isOwnedByCurrentProcess()) { | ||
$lock->release(); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class FolderDeleteMembership implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
/** | ||
* Create a new job instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
*/ | ||
public function handle(): void | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters