Lines 0.00% 0 / 3
Functions and Methods 0.00% 0 / 3
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ServiceCallRequest 0.00% 0 / 3 0.00% 0 / 3 12 0.00% 0 / 1
 __construct 0.00% 0 / 1 0.00% 0 / 1 2
 createUnreachableFailure 0.00% 0 / 1 0.00% 0 / 1 2
 createOverloadedFailure 0.00% 0 / 1 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Ipc\Message;
6
7use Stewart\Contracts\Exception\ServiceCallException;
8use Stewart\Contracts\Service\ServiceTarget;
9use Stewart\Runtime\Model\CorrelationId;
10use Stewart\Runtime\Model\ResourceScope;
11use Throwable;
12
13#[IpcMessage(tag: 'service_call_request')]
14final readonly class ServiceCallRequest implements WorkerMessage, RefusableHaCallRequest
15{
16    /** @param array<string, mixed> $data */
17    public function __construct(
18        public CorrelationId $correlationId,
19        public ResourceScope $scope,
20        public string $domain,
21        public string $service,
22        public array $data,
23        public ?ServiceTarget $target,
24        public bool $returnResponse,
25    ) {}
26
27    public function createUnreachableFailure(string $detail, ?Throwable $previous = null): ServiceCallException
28    {
29        return ServiceCallException::unreachable($this->domain, $this->service, $detail, $previous);
30    }
31
32    public function createOverloadedFailure(string $detail): ServiceCallException
33    {
34        return ServiceCallException::overloaded($this->domain, $this->service, $detail);
35    }
36}