Ryu(3)
π NAME
Bestie, this is Ryu β your little toolkit of asynchronous stream building blocks β¨ (that's the manual page for Ryu(3), and yes, it's giving "glue module with main character energy").
β¨ SYNOPSIS
Okay so here's the whole vibe in one script, no cap:
#!/usr/bin/env perl
use strict;
use warnings;
use Ryu qw($ryu);
my ($lines) =
$ryu->from(\*STDIN)
->by_line
->filter(qr/\h/)
->count
->get;
print "Had $lines line(s) containing whitespace\n";
Look at that chain. It ate. π
πΈ DESCRIPTION
So this module hands you data flow processing for asynchronous coding purposes. Conceptually it's a bit like ReactiveX (that's https://reactivex.io) β and wherever it could, it tries to give you a similar API. But bestie, listen: it is not a directly-compatible implementation, okay? Similar vibe, not a clone. π«Ά
Want the real tea? Start with Ryu::Source. That's where all the genuinely useful parts live.
Why would I be using this?
Eventually some documentation pages might appearβ¦ but atm they're unlikely to exist π. Still, here's the dream:
- Network protocol implementations β if you're bored of stringing together
substr,pack,unpackandvec, tryRyu::Manual::ProtocolorRyu::Buffer. π₯ - Extract, Transform, Load workflows (ETL) β need to pull data from somewhere, mangle it into shape, push it to a database? that'd be
Ryu::Manual::ETL - Reactive event handling β
Ryu::Manual::Reactive
And ngl, as an expert software developer with a keen eye for useful code, you may already be bored of this documentation and on the verge of reaching for alternatives π. The "SEE ALSO" section may speed you on your way β go, fly, we support you π¦.
Compatibility
Since RxPerl follows the ReactiveX conventions quite closely, we'd expect to have the ability to connect RxPerl observables to a Ryu::Source, and provide an adapter from a Ryu::Source to act as an RxPerl-style observable. That is not yet implemented π β but it may be added in a future version. So likeβ¦ someday?
Most of the other modules in "SEE ALSO" are either not used widely enough or not a good semantic fit for a compatibility layer β but if you're interested in this, please ask about it at https://github.com/team-at-cpan/Ryu/issues or provide patches! We literally love patches π
Components
Sources
A source emits items. See Ryu::Source. If in doubt, this is likely to be the class that you wanted β like, that's the one, periodt. β¨
Items can be any scalar value β some examples:
- a single byte
- a character
- a byte string
- a character string
- an object instance
- an arrayref or hashref
Sinks
A sink receives items. It's the counterpart to a source. See Ryu::Sink. π
Streams
A stream is a thing with a source. See Ryu::Stream β which is likely to be something that does not yet have much documentation π (in practice, the Ryu::Source implementation covers most use-cases, so you're fine bestie).
So what does this module do?
Nothing. π«Ά It's just a top-level loader for pulling in all the other components. You wanted Ryu::Source instead, or possibly Ryu::Buffer. And the other half of a Ryu::Source is a Ryu::Sink.
Some notes that might not relate to anything
With a single parameter, from and to will use the given instance as a Ryu::Source or Ryu::Sink respectively.
Multiple parameters are a shortcut for instantiating the given source or sink:
my $stream = Ryu::Stream->from(
file => 'somefile.bin'
);
is equivalent to
my $stream = Ryu::Stream->from(
Ryu::Source->new(
file => 'somefile.bin'
)
);
Same thing, just shorter. Slay. π
π¦ Why the name?
Genuinely iconic reasons, honestly:
$ryulines up with typical 4-character indentation settings. β¨- there's Rx for other languages, and this is based on the same ideas
- ζ΅ was too hard for me to type π
π METHODS
Quick heads up before you scroll: you're more likely to find useful methods in the following classes:
Ryu::SourceRyu::SinkRyu::Observable
new
Instantiates a Ryu object, allowing from, just and other methods. π
from
Helper method which returns a Ryu::Source from a list of items.
just
Helper method which returns a single-item Ryu::Source.
π SEE ALSO
Other modules
Some perl modules of relevance β the whole friend group:
Futureβ fundamental building block for one-shot tasksFuture::Queueβ a FIFO queue forFuturetasksFuture::Bufferβ provides equivalent functionality toRyu::BufferPOE::Filterβ venerable and battle-tested, but slightly short on features due to the focus on protocolsData::Transformβ standalone version ofPOE::FilterList::Genβ list mangling featuresHOP::Streamβ based on the Higher Order Perl bookFlowβ quite similar in concept to this module, maybe a bit short on documentation, doesn't provide integration with other sources such as files orIO::Async::StreamFluxβ more like the java8 streams API, sync-basedMessage::Passingβ on initial glance seemed more of a commandline tool, sadly based on AnyEventRx.pl(https://github.com/eilara/Rx.pl) β a Perl version of the Reactive API athttp://reactivex.ioPerludeβ combines features of the shell / UNIX streams and Haskell, pipeline syntax is "backwards" (same asgrep/mapchains in Perl)IO::PipelineDSEvoAsync::Streamβ early release, but seems to be very similar in concept toRyu::SourceData::MonadRxPerlβ previously known asMojo::Rx, targets close compatibility with rxjs (https://rxjs-dev.firebaseapp.com/guide/overview)
Other references
There are various documents, specifications and discussions relating to the concepts we use. Here's a few:
http://www.reactivemanifesto.org/- Java 8 streams API β
https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html - C++ range-v3 β
https://github.com/ericniebler/range-v3
π AUTHOR
Tom Molesworth <TEAM@cpan.org> with contributions from β shoutout to the whole squad π«Ά:
- Mohammad S Anwar
- Michael Mueller
- Zak Elep
- Mohanad Zarzour
- Nael Alolwani
- Amin Marashi
β LICENSE
Copyright Tom Molesworth 2011-2024. Licensed under the same terms as Perl itself.
π And that's the whole page bestie β brought to you byperl v5.42.2, dated2026-02-15, filed underRyu(3). Go build some streams, you absolute icon. πβ¨
π¦ where this page comes from
- alpine 3.24: perl-ryu-doc 4.001-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms