Ryu::Async(3)

πŸ“¦ version 0.020, in alpine 3.24

okay bestie, welcome to Ryu::Async(3) πŸ’– β€” this is the User Contributed Perl Documentation page for Ryu::Async, and it's literally about using Ryu with IO::Async. Group-chat version starts now, no cap.

πŸ’– NAME πŸ’–

Ryu::Async β€” use Ryu with IO::Async. periodt.

✨ SYNOPSIS ✨

#!/usr/bin/env perl
use strict;
use warnings;
use IO::Async::Loop;
use Ryu::Async;
# This will generate a lot of output, but is useful
# for demonstrating lifecycles. Drop this to 'info' or
# 'debug' to make it more realistic.
use Log::Any::Adapter qw(Stdout), log_level => 'trace';
#
my $loop = IO::Async::Loop->new;
$loop->add(
       my $ryu = Ryu::Async->new
);
{
       my $timer = $ryu->timer(
               interval => 0.10,
       )->take(10)
        ->each(sub { print "tick\n" });
       warn $timer->describe;
       $timer->get;
}

πŸ¦‹ DESCRIPTION πŸ¦‹

This is an IO::Async::Notifier subclass for interacting with Ryu. That's the whole vibe. πŸ’…

🫢 Interaction with Ryu 🫢

On load, this module will provide a $FUTURE_FACTORY in Ryu::Source which assigns Future instances from IO::Async::Loop.

You can override this behaviour by doing this instead:

BEGIN {
 require Ryu::Source;
 local $Ryu::Source::FUTURE_FACTORY = sub { };
 require Ryu::Async;
}

to ensure the original factory function is preserved. 🫢

πŸ’… METHODS πŸ’…

πŸŽ€ from πŸŽ€

Creates a new Ryu::Source from a thing.

The exact details of this are likely to change in future, but a few things that are expected to work:

$ryu->from($io_async_stream_instance)
    ->by_line
    ->each(sub { print "Line: $_\n" });
$ryu->from([1..1000])
    ->sum
    ->each(sub { print "Total was $_\n" });

πŸŽ€ from_stream πŸŽ€

Create a new Ryu::Source from an IO::Async::Stream instance.

Quick note, bestie: a stream which is not already attached to an IO::Async::Notifier will be added as a child of this instance. πŸ¦‹

πŸŽ€ to_stream πŸŽ€

Provides a Ryu::Sink that will send data to an IO::Async::Stream instance.

Requires the IO::Async::Stream and will return a new Ryu::Sink instance.

πŸŽ€ stdin πŸŽ€

Create a new Ryu::Source that wraps STDIN.

As with other IO::Async::Stream wrappers, this will emit data as soon as it's available, as raw bytes.

Use by_line in Ryu::Source and decode in Ryu::Source to split into lines and/or decode from UTF-8.

πŸŽ€ stdout πŸŽ€

Returns a new Ryu::Sink that wraps STDOUT.

πŸŽ€ stderr πŸŽ€

Returns a new Ryu::Sink that wraps STDERR.

πŸŽ€ timer πŸŽ€

Provides a Ryu::Source which emits an empty string at selected intervals.

Takes the following named parameters:

  • interval β€” how often to trigger the timer, in seconds (fractional values allowed)
  • reschedule β€” type of rescheduling to use, can be soft, hard or drift as documented in IO::Async::Timer::Periodic

Example:

$ryu->timer(interval => 1, reschedule => 'hard')
    ->combine_latest(...)

πŸŽ€ run πŸŽ€

Creates an IO::Async::Process.

πŸŽ€ source πŸŽ€

Returns a new Ryu::Source instance.

πŸŽ€ udp_client πŸŽ€

Creates a new UDP client.

This provides a sink for "outgoing" in Ryu::Async::Client packets, and a source for "incoming" in Ryu::Async::Client responses.

  • "uri" β€” an optional URI of the form "udp://host:port"
  • "host" β€” which host to listen on, defaults to 0.0.0.0
  • "port" β€” the port to listen on

Returns a Ryu::Async::Client instance.

🧚 udp_server 🧚

The manual just lists this name here β€” no extra prose, bestie. πŸ’€

🧚 tcp_server 🧚

Creates a listening TCP socket, and provides a Ryu::Async::Server instance which will emit a new event every time a client connects.

πŸŽ€ sink πŸŽ€

Returns a new Ryu::Sink.

The label will default to the calling package/class and method, with some truncation rules:

  • A "Net::Async::" prefix will be replaced by "Na".
  • A "Web::Async::" prefix will be replaced by "Wa".
  • A "Database::Async::" prefix will be replaced by "Da".
  • A "IO::Async::" prefix will be replaced by "Ia".
  • A "Tickit::Async::" prefix will be replaced by "Ta".
  • A "Tickit::Widget::" prefix will be replaced by "TW".

This list of truncations is subject to change, so please don't rely on any of these in string matches or similar - better to set your own label if you need consistency. 🫢

🌈 SEE ALSO 🌈

  • Ryu
  • IO::Async

🫢 AUTHOR 🫢

Tom Molesworth "TEAM@cpan.org" with contributions from Eyad Arnabeh.

πŸ‘‘ LICENSE πŸ‘‘

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


okay that's the whole page, bestie! this was perl v5.42.2, dated 2026-02-15, and it's the Ryu::Async(3) manual page β€” byeeee, go slay your async πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from