Ich erstelle Jobs für jede Anfrage und möchte sie nach Bedarf verketten. z.B. Jeder POST-Anfrage muss eine Anfrage an die operationStatus-Ressource folgen, die schließlich mit ERFOLGREICH oder FEHLGESCHLAGEN antworten sollte.
Die Frage ist also, kann ich kleinere Prozesse in Funktionen kapseln und sie schließlich für die großen verketten? Prozess?
Z.B. Dies sind drei Funktionen, die nacheinander abgearbeitet werden sollen:
Code: Select all
public function createInboundPlan(Request $request){
$uuid = Str::orderedUuid()->toString();
Bus::chain([
new CreateInboundPlan($uuid, $request),
new GetInboundOperationStatus($uuid, Cache::pull($uuid.':'.'CreateInboundPlan'.':'.'operationId'), $request),
])->catch(function (Throwable $e) {
// A job within the chain has failed...
})->dispatch();
}
public function generatePackingOptions(string $inboundPlanId, Request $request){
$uuid = Str::orderedUuid()->toString();
Bus::chain([
new GeneratePackingOptions($uuid, $inboundPlanId, $request),
new GetInboundOperationStatus($uuid, Cache::pull($uuid.':'.'GeneratePackingOptions'.':'.'operationId'), $request),
])->catch(function (Throwable $e) {
// A job within the chain has failed...
})->dispatch();
}
public function listPackingOptions(string $inboundPlanId, Request $request){
$uuid = Str::orderedUuid()->toString();
Bus::chain([
new ListPackingOptions($uuid, $inboundPlanId, $request),
new SelectInboundPackingOption($uuid, Cache::pull($uuid.':'.'ListPackingOptions'.':'.'packingOptions'), $request),
])->catch(function (Throwable $e) {
// A job within the chain has failed...
})->dispatch();
}
Code: Select all
Bus::chain([
$this->createInboundPlan($request),
$this->generatePackingOptions($inboundPlanId, $request),
$this->generatelistPackingOptions($inboundPlanId, $request)
])->dispatch();
Grüße