PsrTransport
in package
implements
TransportInterface
uses
LogsMessagesTrait
FinalYes
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
- $closed : bool
- $compression : array<string|int, mixed>
- $contentType : string
- $endpoint : string
- $headers : array<string|int, mixed>
- $maxResponseBodySize : int
- $maxRetries : int
- $reportedBodyErrors : array<string, true>
- $requestFactory : RequestFactoryInterface
- $retryDelay : int
- $streamFactory : StreamFactoryInterface
Methods
- __construct() : mixed
- contentType() : string
- forceFlush() : bool
- send() : FutureInterface
- shutdown() : bool
- logDebug() : void
- logError() : void
- 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 log writer (for example an error handler that throws on `trigger_error`) 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
- shouldLog() : bool
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
$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
$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
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 ]) : 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
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()
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
static logDebug(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logError()
protected
static logError(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logInfo()
protected
static logInfo(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logNotice()
protected
static logNotice(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logWarning()
protected
static 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 log writer (for example an error handler that throws on `trigger_error`) must not break the code that is being observed.
private
static 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
Tags
Return values
stringshouldLog()
private
static shouldLog(string $level) : bool
Parameters
- $level : string