Carrier
Carrier for propagating context across process boundaries.
A carrier is the transport mechanism for context propagation headers. Implementations handle specific transport types (HTTP headers, gRPC metadata, message queue headers, etc.).
Example implementation for PSR-7:
final class Psr7Carrier implements Carrier
{
public function __construct(private RequestInterface $request) }
public function get(string $key): ?string
{
$values = $this->request->getHeader($key);
return $values[0] ?? null;
}
public function set(string $key, string $value): void
{
$this->request = $this->request->withHeader($key, $value);
}
}
Methods
Methods
get()
Get a value by key.
public
get(string $key) : null|string
Key lookup should be case-insensitive for HTTP header compatibility.
Parameters
- $key : string
-
The key to look up
Return values
null|string —The value, or null if not found
set()
Set a value.
public
set(string $key, string $value) : void
Parameters
- $key : string
-
The key to set
- $value : string
-
The value to set