Psr18Transport
in package
implements
BoundedPayloadTransport, BoundedPayloadUploadTransport, BoundedTransport, BoundedProgressPayloadTransport, ResponseStatusTransport
FinalYes
Default PSR-18 JSON and bounded runtime-payload transport.
Table of Contents
Interfaces
- BoundedPayloadTransport
- Optional payload download capability with a complete request time bound.
- BoundedPayloadUploadTransport
- Optional payload upload capability that bounds transmission and response reads.
- BoundedTransport
- A transport that can bound the complete request, including connection and body reads.
- BoundedProgressPayloadTransport
- Optional finite payload streaming with supervision during transfer and idle I/O.
- ResponseStatusTransport
- Optional status metadata; existing custom transports remain supported.
Constants
- DEFAULT_REQUEST_TIMEOUT_SECONDS : mixed = 60.0
- DEFAULT_WORKER_REQUEST_TIMEOUT_SECONDS : mixed = 60.0
- Worker lifecycle requests (register, heartbeat, complete, fail, deregister); long polls keep their own budget.
Properties
- $client : ClientInterface
- $completionArmed : bool
- $completionHandler : CompletionRequestHandler|null
- $completionOwner : Fiber<mixed, mixed>|null
- $completionUri : string|null
- $defaultProcessConfiguration : bool
- $nativeControlClient : Client|null
- $payloadTransferTimeoutSeconds : int
- $requestFactory : RequestFactoryInterface
- $requestTimeoutSeconds : float|null
- $responseStatus : int|null
- $streamFactory : StreamFactoryInterface
- $workerRequestTimeoutSeconds : float|null
Methods
- __construct() : mixed
- fetchPayload() : string
- Fetch bounded bytes without following redirects and verify declared response metadata.
- fetchPayloadBounded() : string
- fetchPayloadWithBoundedProgress() : string
- fetchPayloadWithProgress() : string
- lastResponseStatus() : int|null
- Status of the latest document send, or null when no response was received.
- send() : array<string, mixed>|array<int, mixed>|null
- sendBounded() : array<string, mixed>|array<int, mixed>|null
- supportsBoundedRequests() : bool
- uploadPayload() : array<string, mixed>
- Upload encoded bytes without redirects; return a bounded JSON response.
- uploadPayloadBounded() : array<string, mixed>
- controlTimeoutFailure() : TransportException
- createJsonRequest() : RequestInterface
- decodeJsonResponse() : array<string, mixed>|array<int, mixed>|null
- fetch() : string
- guzzleRequestOptions() : array<string, mixed>
- isControlRequest() : bool
- isTimeout() : bool
- nativeControlHttpClient() : Client
- pollTimeoutSeconds() : int|float
- requestFailure() : TransportException
- sendJson() : array<string, mixed>|array<int, mixed>|null
- sendPayloadBounded() : ResponseInterface
- sendRequest() : ResponseInterface
- upload() : array<string, mixed>
Constants
DEFAULT_REQUEST_TIMEOUT_SECONDS
public
mixed
DEFAULT_REQUEST_TIMEOUT_SECONDS
= 60.0
DEFAULT_WORKER_REQUEST_TIMEOUT_SECONDS
Worker lifecycle requests (register, heartbeat, complete, fail, deregister); long polls keep their own budget.
public
mixed
DEFAULT_WORKER_REQUEST_TIMEOUT_SECONDS
= 60.0
Properties
$client read-only
private
ClientInterface
$client
$completionArmed
private
bool
$completionArmed
= false
$completionHandler
private
CompletionRequestHandler|null
$completionHandler
= null
$completionOwner
private
Fiber<mixed, mixed>|null
$completionOwner
= null
$completionUri
private
string|null
$completionUri
= null
$defaultProcessConfiguration read-only
private
bool
$defaultProcessConfiguration
$nativeControlClient
private
Client|null
$nativeControlClient
= null
$payloadTransferTimeoutSeconds read-only
private
int
$payloadTransferTimeoutSeconds
= 30
$requestFactory read-only
private
RequestFactoryInterface
$requestFactory
$requestTimeoutSeconds read-only
private
float|null
$requestTimeoutSeconds
$responseStatus
private
int|null
$responseStatus
= null
$streamFactory read-only
private
StreamFactoryInterface
$streamFactory
$workerRequestTimeoutSeconds read-only
private
float|null
$workerRequestTimeoutSeconds
Methods
__construct()
public
__construct([ClientInterface|null $client = null ][, RequestFactoryInterface|null $requestFactory = null ][, StreamFactoryInterface|null $streamFactory = null ][, int $payloadTransferTimeoutSeconds = 30 ][, float|null $requestTimeoutSeconds = null ][, float|null $workerRequestTimeoutSeconds = null ]) : mixed
Parameters
- $client : ClientInterface|null = null
- $requestFactory : RequestFactoryInterface|null = null
- $streamFactory : StreamFactoryInterface|null = null
- $payloadTransferTimeoutSeconds : int = 30
- $requestTimeoutSeconds : float|null = null
- $workerRequestTimeoutSeconds : float|null = null
fetchPayload()
Fetch bounded bytes without following redirects and verify declared response metadata.
public
fetchPayload(string $uri, array<string|int, mixed> $headers, int $maxBytes) : string
Parameters
- $uri : string
- $headers : array<string|int, mixed>
- $maxBytes : int
Return values
stringfetchPayloadBounded()
public
fetchPayloadBounded(string $uri, array<string|int, mixed> $headers, int $maxBytes, int $timeoutSeconds) : string
Parameters
- $uri : string
- $headers : array<string|int, mixed>
- $maxBytes : int
- $timeoutSeconds : int
Return values
stringfetchPayloadWithBoundedProgress()
public
fetchPayloadWithBoundedProgress(string $uri, array<string|int, mixed> $headers, int $maxBytes, Closure $progress[, int|null $timeoutSeconds = null ]) : string
Parameters
- $uri : string
- $headers : array<string|int, mixed>
- $maxBytes : int
- $progress : Closure
- $timeoutSeconds : int|null = null
Return values
stringfetchPayloadWithProgress()
public
fetchPayloadWithProgress(string $uri, array<string|int, mixed> $headers, int $maxBytes, Closure $progress) : string
Parameters
- $uri : string
- $headers : array<string|int, mixed>
- $maxBytes : int
- $progress : Closure
-
Exceptions interrupt the transfer unchanged.
Return values
stringlastResponseStatus()
Status of the latest document send, or null when no response was received.
public
lastResponseStatus() : int|null
Return values
int|nullsend()
public
send(string $method, string $uri, array<string, string> $headers[, array<string, mixed>|null $body = null ]) : array<string, mixed>|array<int, mixed>|null
Parameters
- $method : string
- $uri : string
- $headers : array<string, string>
- $body : array<string, mixed>|null = null
Return values
array<string, mixed>|array<int, mixed>|nullsendBounded()
public
sendBounded(string $method, string $uri, array<string|int, mixed> $headers, array<string|int, mixed>|null $body, int $timeoutSeconds) : array<string, mixed>|array<int, mixed>|null
Parameters
- $method : string
- $uri : string
- $headers : array<string|int, mixed>
- $body : array<string|int, mixed>|null
- $timeoutSeconds : int
Return values
array<string, mixed>|array<int, mixed>|nullsupportsBoundedRequests()
public
supportsBoundedRequests() : bool
Return values
booluploadPayload()
Upload encoded bytes without redirects; return a bounded JSON response.
public
uploadPayload(string $uri, array<string|int, mixed> $headers, string $blob, int $timeoutSeconds) : array<string, mixed>
Parameters
- $uri : string
- $headers : array<string|int, mixed>
- $blob : string
- $timeoutSeconds : int
Return values
array<string, mixed>uploadPayloadBounded()
public
uploadPayloadBounded(string $uri, array<string|int, mixed> $headers, string $blob, int $timeoutSeconds) : array<string, mixed>
Parameters
- $uri : string
- $headers : array<string|int, mixed>
- $blob : string
- $timeoutSeconds : int
Return values
array<string, mixed>controlTimeoutFailure()
private
controlTimeoutFailure(Throwable $exception, float $seconds[, bool $control = true ]) : TransportException
Parameters
- $exception : Throwable
- $seconds : float
- $control : bool = true
Return values
TransportExceptioncreateJsonRequest()
private
createJsonRequest(string $method, string $uri, array<string, string> $headers, array<string, mixed>|null $body) : RequestInterface
Parameters
- $method : string
- $uri : string
- $headers : array<string, string>
- $body : array<string, mixed>|null
Return values
RequestInterfacedecodeJsonResponse()
private
decodeJsonResponse(ResponseInterface $response[, bool $poll = false ]) : array<string, mixed>|array<int, mixed>|null
Parameters
- $response : ResponseInterface
- $poll : bool = false
Return values
array<string, mixed>|array<int, mixed>|nullfetch()
private
fetch(string $uri, array<string, string> $headers, int $maxBytes[, int|null $timeoutSeconds = null ][, Closure|null $progress = null ]) : string
Parameters
- $uri : string
- $headers : array<string, string>
- $maxBytes : int
- $timeoutSeconds : int|null = null
- $progress : Closure|null = null
Return values
stringguzzleRequestOptions()
private
guzzleRequestOptions(bool $stream, int|float $timeoutSeconds, bool $bounded, StreamInterface|null $sink, Closure|null $progress) : array<string, mixed>
Parameters
- $stream : bool
- $timeoutSeconds : int|float
- $bounded : bool
- $sink : StreamInterface|null
- $progress : Closure|null
Return values
array<string, mixed>isControlRequest()
private
isControlRequest(array<string, string> $headers) : bool
Parameters
- $headers : array<string, string>
Return values
boolisTimeout()
private
isTimeout(Throwable $exception) : bool
Parameters
- $exception : Throwable
Return values
boolnativeControlHttpClient()
private
nativeControlHttpClient() : Client
Return values
ClientpollTimeoutSeconds()
private
pollTimeoutSeconds(array<string, mixed>|null $body) : int|float
Parameters
- $body : array<string, mixed>|null
Return values
int|floatrequestFailure()
private
requestFailure(Throwable $exception, float|null $controlTimeout, bool $timedOut, bool $connectionFailure[, bool $control = true ]) : TransportException
Parameters
- $exception : Throwable
- $controlTimeout : float|null
- $timedOut : bool
- $connectionFailure : bool
- $control : bool = true
Return values
TransportExceptionsendJson()
private
sendJson(string $method, string $uri, array<string, string> $headers, array<string, mixed>|null $body[, int|null $timeoutSeconds = null ]) : array<string, mixed>|array<int, mixed>|null
Parameters
- $method : string
- $uri : string
- $headers : array<string, string>
- $body : array<string, mixed>|null
- $timeoutSeconds : int|null = null
Return values
array<string, mixed>|array<int, mixed>|nullsendPayloadBounded()
private
sendPayloadBounded(RequestInterface $request, int $maxBytes, int $timeoutSeconds[, Closure|null $progress = null ]) : ResponseInterface
Parameters
- $request : RequestInterface
- $maxBytes : int
- $timeoutSeconds : int
- $progress : Closure|null = null
Return values
ResponseInterfacesendRequest()
private
sendRequest(RequestInterface $request[, bool $stream = false ][, int|float $timeoutSeconds = 30 ][, bool $bounded = false ][, StreamInterface|null $sink = null ][, Closure|null $progress = null ][, float|null $controlTimeout = null ][, bool $control = true ]) : ResponseInterface
Parameters
- $request : RequestInterface
- $stream : bool = false
- $timeoutSeconds : int|float = 30
- $bounded : bool = false
- $sink : StreamInterface|null = null
- $progress : Closure|null = null
- $controlTimeout : float|null = null
- $control : bool = true
Return values
ResponseInterfaceupload()
private
upload(string $uri, array<string, string> $headers, string $blob, int $timeoutSeconds, bool $bounded) : array<string, mixed>
Parameters
- $uri : string
- $headers : array<string, string>
- $blob : string
- $timeoutSeconds : int
- $bounded : bool