-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransport.php
More file actions
36 lines (29 loc) · 1013 Bytes
/
Transport.php
File metadata and controls
36 lines (29 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
namespace Arcp\Transport;
use Amp\Cancellation;
use Arcp\Envelope\Envelope;
/**
* Transport-agnostic message channel (RFC §22).
*
* Both directions are async: `send()` returns a future-style void, and
* `receive()` blocks the calling fiber until an envelope arrives. The
* implementation MAY drop the connection at any time; consumers see this
* as `receive()` returning `null`.
*/
interface Transport
{
/**
* Push `$env` onto the wire. Throws on transport errors.
*/
public function send(Envelope $env, ?Cancellation $cancellation = null): void;
/**
* Pull the next envelope. Returns `null` if the peer closed cleanly.
* Throws on transport errors or cancellation.
*/
public function receive(?Cancellation $cancellation = null): ?Envelope;
/** Close the transport. Idempotent. */
public function close(): void;
/** True iff the transport has been closed by either side. */
public function isClosed(): bool;
}