Я создаю задания для каждого запроса и хочу связывать их по мере необходимости. например каждый POST-запрос должен следовать за запросом к ресурсу OperationStatus, который в конечном итоге должен ответить УСПЕХОМ или FAILED.
Итак, вопрос в том, могу ли я инкапсулировать меньшие процессы в функции и, наконец, связать их в цепочку для больших процесс?
Например. это три функции, которые следует обрабатывать одну за другой:
Код: Выделить всё
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();
}
Код: Выделить всё
Bus::chain([
$this->createInboundPlan($request),
$this->generatePackingOptions($inboundPlanId, $request),
$this->generatelistPackingOptions($inboundPlanId, $request)
])->dispatch();
Привет
Подробнее здесь: https://stackoverflow.com/questions/793 ... -functions
Мобильная версия