mirror of
https://github.com/danog/byte-stream.git
synced 2024-11-30 04:19:23 +01:00
Revert IteratorStream name to Message
This commit is contained in:
parent
abb7c9c6b5
commit
11a92648d1
@ -15,18 +15,18 @@ use Amp\Success;
|
||||
*
|
||||
* Buffering Example:
|
||||
*
|
||||
* $stream = new IteratorStream($iterator); // $iterator is an instance of \Amp\Iterator emitting only strings.
|
||||
* $stream = new Message($iterator); // $iterator is an instance of \Amp\Iterator emitting only strings.
|
||||
* $content = yield $stream;
|
||||
*
|
||||
* Streaming Example:
|
||||
*
|
||||
* $stream = new IteratorStream($iterator); // $iterator is an instance of \Amp\Iterator emitting only strings.
|
||||
* $stream = new Message($iterator); // $iterator is an instance of \Amp\Iterator emitting only strings.
|
||||
*
|
||||
* while (($chunk = yield $stream->read()) !== null) {
|
||||
* // Immediately use $chunk, reducing memory consumption since the entire message is never buffered.
|
||||
* }
|
||||
*/
|
||||
class IteratorStream implements InputStream, Promise {
|
||||
class Message implements InputStream, Promise {
|
||||
/** @var string */
|
||||
private $buffer = "";
|
||||
|
@ -2,18 +2,18 @@
|
||||
|
||||
namespace Amp\ByteStream\Test;
|
||||
|
||||
use Amp\ByteStream\IteratorStream;
|
||||
use Amp\ByteStream\Message;
|
||||
use Amp\Emitter;
|
||||
use Amp\Loop;
|
||||
use Amp\PHPUnit\TestCase;
|
||||
|
||||
class IteratorStreamTest extends TestCase {
|
||||
class MessageTest extends TestCase {
|
||||
public function testBufferingAll() {
|
||||
Loop::run(function () {
|
||||
$values = ["abc", "def", "ghi"];
|
||||
|
||||
$emitter = new Emitter;
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
foreach ($values as $value) {
|
||||
$emitter->emit($value);
|
||||
@ -30,7 +30,7 @@ class IteratorStreamTest extends TestCase {
|
||||
$values = ["abc", "def", "ghi"];
|
||||
|
||||
$emitter = new Emitter;
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
foreach ($values as $value) {
|
||||
$emitter->emit($value);
|
||||
@ -55,7 +55,7 @@ class IteratorStreamTest extends TestCase {
|
||||
$values = ["abc", "def", "ghi"];
|
||||
|
||||
$emitter = new Emitter;
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
foreach ($values as $value) {
|
||||
$emitter->emit($value);
|
||||
@ -78,7 +78,7 @@ class IteratorStreamTest extends TestCase {
|
||||
$values = ["abc", "def", "ghi"];
|
||||
|
||||
$emitter = new Emitter;
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
foreach ($values as $value) {
|
||||
$emitter->emit($value);
|
||||
@ -95,7 +95,7 @@ class IteratorStreamTest extends TestCase {
|
||||
$values = ["abc", "def", "ghi"];
|
||||
|
||||
$emitter = new Emitter;
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
$emitter->emit($values[0]);
|
||||
|
||||
@ -119,7 +119,7 @@ class IteratorStreamTest extends TestCase {
|
||||
$value = "abc";
|
||||
|
||||
$emitter = new Emitter;
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
$emitter->emit($value);
|
||||
$emitter->fail($exception);
|
||||
@ -138,7 +138,7 @@ class IteratorStreamTest extends TestCase {
|
||||
Loop::run(function () {
|
||||
$emitter = new Emitter;
|
||||
$emitter->complete();
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
$this->assertNull(yield $stream->read());
|
||||
});
|
||||
@ -149,7 +149,7 @@ class IteratorStreamTest extends TestCase {
|
||||
$value = "abc";
|
||||
|
||||
$emitter = new Emitter;
|
||||
$stream = new IteratorStream($emitter->iterate());
|
||||
$stream = new Message($emitter->iterate());
|
||||
|
||||
$emitter->emit($value);
|
||||
$emitter->complete();
|
Loading…
Reference in New Issue
Block a user