Skip to content
forked from team-at-cpan/Ryu

Streaming things for Perl. Not quite Rx.

License

Notifications You must be signed in to change notification settings

mohanad-deriv/Ryu

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Ryu - asynchronous stream building blocks

SYNOPSIS

#!/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";

DESCRIPTION

Provides data flow processing for asynchronous coding purposes. It's a bit like ReactiveX in concept. Where possible, it tries to provide a similar API. It is not a directly-compatible implementation, however.

Why would I be using this?

Eventually some documentation pages might appear, but at the moment they're unlikely to exist.

  • Network protocol implementations - if you're bored of stringing together substr, pack, unpack and vec, try Ryu::Manual::Protocol
  • 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

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.

Components

Sources

A source emits items. See Ryu::Source.

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 exist.

What does this module do?

Nothing. It's just a top-level loader for pulling in all the other components.

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'
 )
);

Why the name?

  • $ryu lines 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

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:

Other references

There are various documents, specifications and discussions relating to the concepts we use. Here's a few:

AUTHOR

Tom Molesworth TEAM@cpan.org

LICENSE

Copyright Tom Molesworth 2011-2019. Licensed under the same terms as Perl itself.

About

Streaming things for Perl. Not quite Rx.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Perl 100.0%