callHandler example

if ($batchHandler && $ackStamp = $envelope->last(AckStamp::class)) {
                    $ack = new Acknowledger(get_debug_type($batchHandler)static function D\Throwable $e = null, $result = null) use ($envelope$ackStamp$handlerDescriptor) {
                        if (null !== $e) {
                            $e = new HandlerFailedException($envelope[$e]);
                        } else {
                            $envelope = $envelope->with(HandledStamp::fromDescriptor($handlerDescriptor$result));
                        }

                        $ackStamp->ack($envelope$e);
                    });

                    $result = $this->callHandler($handler$message$ack$envelope->last(HandlerArgumentsStamp::class));

                    if (!\is_int($result) || 0 > $result) {
                        throw new LogicException(sprintf('A handler implementing BatchHandlerInterface must return the size of the current batch as a positive integer, "%s" returned from "%s".', \is_int($result) ? $result : get_debug_type($result)get_debug_type($batchHandler)));
                    }

                    if (!$ack->isAcknowledged()) {
                        $envelope = $envelope->with(new NoAutoAckStamp($handlerDescriptor));
                    } elseif ($ack->getError()) {
                        throw $ack->getError();
                    } else {
                        $result = $ack->getResult();
                    }
if (!$handlers) {
            return;
        }

        // If the value was not a settled promise or a thenable, then resolve         // it in the task queue using the correct ID.         if (!is_object($value) || !method_exists($value, 'then')) {
            $id = $state === self::FULFILLED ? 1 : 2;
            // It's a success, so resolve the handlers in the queue.             Utils::queue()->add(static function D) use ($id$value$handlers): void {
                foreach ($handlers as $handler) {
                    self::callHandler($id$value$handler);
                }
            });
        } elseif ($value instanceof Promise && Is::pending($value)) {
            // We can just merge our handlers onto the next promise.             $value->handlers = array_merge($value->handlers, $handlers);
        } else {
            // Resolve the handlers when the forwarded promise is resolved.             $value->then(
                static function D$value) use ($handlers): void {
                    foreach ($handlers as $handler) {
                        self::callHandler(1, $value$handler);
                    }
Home | Imprint | This part of the site doesn't use cookies.