Thruster Steam Component
Open Issues: 0
- php: >=7.0
- thruster/event-emitter: ~1.0
- thruster/event-loop: ~1.0
- thruster/promise: ~1.0
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2023-05-13 23:51:40 UTC
 (https://github.com/ThrusterIO/stream/releases)  (LICENSE)  (https://travis-ci.org/ThrusterIO/stream)  (https://scrutinizer-ci.com/g/ThrusterIO/stream)  (https://scrutinizer-ci.com/g/ThrusterIO/stream)  (https://packagist.org/packages/thruster/stream)
The Thruster Stream Component.
Basic readable and writable stream interfaces that support piping.
In order to make the event loop easier to use, this component introduces the concept of streams. They are very similar to the streams found in PHP itself, but have an interface more suited for async I/O.
Mainly it provides interfaces for readable and writable streams, plus a file descriptor based implementation with an in-memory write buffer.
$ composer require thruster/stream
data: Emitted whenever data was read from the source.
end: Emitted when the source has reached the
error: Emitted when an error occurs.
close: Emitted when the connection is closed.
isReadable(): Check if the stream is still in a state allowing it to be read from. It becomes unreadable when the connection ends, closes or an error occurs.
pause(): Remove the data source file descriptor from the event loop. This allows you to throttle incoming data.
resume(): Re-attach the data source after a
pipe(WritableStreamInterface $dest, array $options = ): Pipe this readable stream into a writable stream. Automatically sends all incoming data to the destination. Automatically throttles based on what the destination can handle.
drain: Emitted if the write buffer became full previously and is now ready to accept more data.
error: Emitted whenever an error occurs.
close: Emitted whenever the connection is closed.
pipe: Emitted whenever a readable stream is
pipe()d into this stream.
isWritable(): Check if the stream can still be written to. It cannot be written to after an error or when it is closed.
write($data): Write some data into the stream. If the stream cannot handle it, it should buffer the data or emit and
errorevent. If the internal buffer is full after adding
writeshould return false, indicating that the caller should stop sending data until the buffer
end($data = null): Optionally write some final data to the stream, empty the buffer, then close it.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
Please see License File for more information.