Ryu::Source - base representation for a source of events
This is probably the module you'd want to start with, if you were going to be using any of this. There's a disclaimer in Ryu that may be relevant at this point.
This is a coderef which should return a new Future-compatible instance.
Example overrides might include:
$Ryu::Source::FUTURE_FACTORY = sub { Mojo::Future->new->set_label(shift) };
Takes named parameters.
Returns a string describing this source and any parents - typically this will result in a chain like from->combine_latest->count.
from->combine_latest->count
Creates a new source from things.
The precise details of what this method supports may be somewhat ill-defined at this point in time. It is expected that the interface and internals of this method will vary greatly in versions to come.
Passes each item through an encoder.
The first parameter is the encoder to use, the remainder are used as options for the selected encoder.
Examples:
$src->encode('json') $src->encode('utf8') $src->encode('base64')
Passes each item through a decoder.
The first parameter is the decoder to use, the remainder are used as options for the selected decoder.
$src->decode('json') $src->decode('utf8') $src->decode('base64')
Creates an empty source, which finishes immediately.
An empty source that never finishes.
Throws something. I don't know what, maybe a chair.
Used internally to get a Future.
Does nothing useful.
Is about as much use as "pause".
Might return 1 or 0, but is generally meaningless.
Not yet implemented.
Requires timing support, see implementations such as Ryu::Async instead.
Chomps all items with the current delimiter.
Once you've instantiated this, it will stick with the delimiter which was in force at the time of instantiation. Said delimiter follows the usual rules of $/, whatever they happen to be.
$/
A bit like "map" in perlfunc.
Splits the input into chunks. By default, will split into characters.
Splits input into fixed-size chunks.
Note that output is always guaranteed to be a full chunk - if there is partial input at the time the input stream finishes, those extra bytes will be discarded.
Used for setting up multiple streams.
Accepts a variable number of coderefs, will call each one and gather Ryu::Source results.
Given a stream of Futures, will emit the results as each Future is marked ready. If any fail, the stream will fail.
This is a terrible name for a method, expect it to change.
Emits new distinct items, using string equality with an exception for undef (i.e. undef is treated differently from empty string or 0).
undef
Given 1,2,3,undef,2,3,undef,'2',2,4,1,5, you'd expect to get the sequence 1,2,3,undef,4,5.
Removes contiguous duplicates, defined by string equality.
Skips the first N items.
Skips the last N items.
Takes a limited number of items.
Given a sequence of 1,2,3,4,5 and ->take(3), you'd get 1,2,3 and then the stream would finish.
1,2,3,4,5
->take(3)
Emits a single hashref of statistics once the source completes.
Similar to "map", but will flatten out some items:
an arrayref will be expanded out to emit the individual elements
for a Ryu::Source, passes on any emitted elements
This also means you can "merge" items from a series of sources.
Note that this is not recursive - an arrayref of arrayrefs will be expanded out into the child arrayrefs, but no further.
The following methods are proxied to our completion Future:
then
is_ready
is_done
failure
is_cancelled
else
Block until this source finishes.
Mark this source as completed.
Returns a new Ryu::Source chained from this one.
Tom Molesworth <TEAM@cpan.org>
Copyright Tom Molesworth 2011-2016. Licensed under the same terms as Perl itself.
To install Ryu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ryu
CPAN shell
perl -MCPAN -e shell install Ryu
For more information on module installation, please visit the detailed CPAN module installation guide.