PsrTransport
in package
implements
TransportInterface
uses
LogsToLoggerTrait
Tags
Table of Contents
Interfaces
Constants
- DEFAULT_MAX_RESPONSE_BODY_SIZE : mixed = 4 * 1024 * 1024
- Default limit for the response body, also after decompression.
- MAX_REPORTED_BODY_ERRORS : mixed = 16
- Distinct reasons a response body was ignored, which have been logged as a warning already.
Properties
- $client : ClientInterface
- $clock : ClockInterface
- $closed : bool
- $compression : array<string|int, mixed>
- $contentType : string
- $endpoint : string
- $headers : array<string|int, mixed>
- $logger : LoggerInterface
- $maxResponseBodySize : int
- $maxRetries : int
- $reportedBodyErrors : array<string, true>
- $requestFactory : RequestFactoryInterface
- $retryDelay : int
- $streamFactory : StreamFactoryInterface
- $timeout : float
Methods
- __construct() : mixed
- contentType() : string
- forceFlush() : bool
- send() : FutureInterface
- Only the waits between attempts are bounded by the timeout. An attempt runs until the client's own timeout, since PSR-18 has no per-request timeout. `$cancellation` isn't checked yet.
- shutdown() : bool
- logDebug() : void
- logError() : void
- logger() : LoggerInterface
- logInfo() : void
- logNotice() : void
- logWarning() : void
- checkBodySize() : void
- Checks the body of a response that is not going to be used, such as an error. An unreadable body is ignored, so that the status of the response stays the reason for the failure.
- doLog() : void
- Logging is best effort: a failing logger must not break the code that is being observed.
- logIgnoredBody() : void
- A server that always answers in an encoding that can't be decoded would fill the log with a warning for every export, so only the first one for each reason is a warning, the rest are debug messages.
- parseContentEncoding() : array<int, string>
- readBody() : string
Constants
DEFAULT_MAX_RESPONSE_BODY_SIZE
Default limit for the response body, also after decompression.
public
mixed
DEFAULT_MAX_RESPONSE_BODY_SIZE
= 4 * 1024 * 1024
Tags
MAX_REPORTED_BODY_ERRORS
Distinct reasons a response body was ignored, which have been logged as a warning already.
private
mixed
MAX_REPORTED_BODY_ERRORS
= 16
Properties
$client read-only
private
ClientInterface
$client
$clock read-only
private
ClockInterface
$clock
$closed
private
bool
$closed
= false
$compression read-only
private
array<string|int, mixed>
$compression
$contentType read-only
private
string
$contentType
$endpoint read-only
private
string
$endpoint
$headers read-only
private
array<string|int, mixed>
$headers
$logger read-only
private
LoggerInterface
$logger
= new ConfiguredLogger()
$maxResponseBodySize read-only
private
int
$maxResponseBodySize
= self::DEFAULT_MAX_RESPONSE_BODY_SIZE
$maxRetries read-only
private
int
$maxRetries
$reportedBodyErrors
private
array<string, true>
$reportedBodyErrors
= []
$requestFactory read-only
private
RequestFactoryInterface
$requestFactory
$retryDelay read-only
private
int
$retryDelay
$streamFactory read-only
private
StreamFactoryInterface
$streamFactory
$timeout read-only
private
float
$timeout
= 0.0
Methods
__construct()
public
__construct(ClientInterface $client, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, string $endpoint, CONTENT_TYPE $contentType, array<string|int, mixed> $headers, array<string|int, mixed> $compression, int $retryDelay, int $maxRetries[, int $maxResponseBodySize = self::DEFAULT_MAX_RESPONSE_BODY_SIZE ][, LoggerInterface $logger = new ConfiguredLogger() ][, float $timeout = 0.0 ][, ClockInterface|null $clock = null ]) : mixed
Parameters
- $client : ClientInterface
- $requestFactory : RequestFactoryInterface
- $streamFactory : StreamFactoryInterface
- $endpoint : string
- $contentType : CONTENT_TYPE
- $headers : array<string|int, mixed>
- $compression : array<string|int, mixed>
- $retryDelay : int
- $maxRetries : int
- $maxResponseBodySize : int = self::DEFAULT_MAX_RESPONSE_BODY_SIZE
- $logger : LoggerInterface = new ConfiguredLogger()
- $timeout : float = 0.0
- $clock : ClockInterface|null = null
contentType()
public
contentType() : string
Attributes
- #[Override]
Return values
stringforceFlush()
public
forceFlush([CancellationInterface|null $cancellation = null ]) : bool
Parameters
- $cancellation : CancellationInterface|null = null
Attributes
- #[Override]
Return values
boolsend()
Only the waits between attempts are bounded by the timeout. An attempt runs until the client's own timeout, since PSR-18 has no per-request timeout. `$cancellation` isn't checked yet.
public
send(string $payload[, CancellationInterface|null $cancellation = null ]) : FutureInterface
Parameters
- $payload : string
- $cancellation : CancellationInterface|null = null
Tags
Attributes
- #[Override]
Return values
FutureInterfaceshutdown()
public
shutdown([CancellationInterface|null $cancellation = null ]) : bool
Parameters
- $cancellation : CancellationInterface|null = null
Attributes
- #[Override]
Return values
boollogDebug()
protected
logDebug(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logError()
protected
logError(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logger()
protected
logger() : LoggerInterface
Attributes
- #[Override]
Return values
LoggerInterfacelogInfo()
protected
logInfo(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logNotice()
protected
logNotice(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logWarning()
protected
logWarning(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
checkBodySize()
Checks the body of a response that is not going to be used, such as an error. An unreadable body is ignored, so that the status of the response stays the reason for the failure.
private
checkBodySize(ResponseInterface $response) : void
Parameters
- $response : ResponseInterface
Tags
doLog()
Logging is best effort: a failing logger must not break the code that is being observed.
private
doLog(string $level, string $message, array<string|int, mixed> $context) : void
Parameters
- $level : string
- $message : string
- $context : array<string|int, mixed>
logIgnoredBody()
A server that always answers in an encoding that can't be decoded would fill the log with a warning for every export, so only the first one for each reason is a warning, the rest are debug messages.
private
logIgnoredBody(RuntimeException $e, ResponseInterface $response) : void
Parameters
- $e : RuntimeException
- $response : ResponseInterface
parseContentEncoding()
private
static parseContentEncoding(ResponseInterface $response) : array<int, string>
Parameters
- $response : ResponseInterface
Return values
array<int, string>readBody()
private
readBody(ResponseInterface $response) : string
Parameters
- $response : ResponseInterface