NAME
Linux::Event::Stream::Codec::Line - Newline-delimited framing codec
SYNOPSIS
use Linux::Event::Stream;
use Linux::Event::Stream::Codec::Line;
my $codec = Linux::Event::Stream::Codec::Line->new(
chomp => 1,
max_line => 64*1024,
);
my $s = Linux::Event::Stream->new(
loop => $loop,
fh => $fh,
codec => $codec,
on_message => sub ($stream, $line, $data) {
# $line is one message ("\n" removed when chomp => 1)
},
);
DESCRIPTION
This codec frames a byte stream into newline-delimited messages.
Decode behavior:
Consumes complete messages ending in
\nfrom the input buffer.If
chompis true (default), the trailing newline is removed from each message delivered to the application.If
max_lineis set, an error is raised if a newline is found beyond that limit.
Encode behavior:
If
append_newlineis true (default),\nis appended unless the message already ends with\n.
CONSTRUCTOR
new(%args)
- chomp
-
Boolean. Default true.
- max_line
-
Optional maximum allowed bytes per line, including the delimiter.
- append_newline
-
Boolean. Default true.
AUTHOR
Joshua S. Day
LICENSE
Same terms as Perl itself.