view release on metacpan or search on metacpan
Perinci::Result::Format. There are now Perinci-CmdLine and
Perinci-CmdLine-Lite distributions.
- Refactoring: run() and run_*() now returns enveloped response instead
of int. All output is now returned as string by run_*() instead of
printed directly (except for streaming output).
- Refactoring: No long uses internal attributes like
$self->{_subcommand}. Instead, now a per-request (per-run())
stash/hash $r is passed around. This is not unlike the technique used
in Apache handlers and Data::Sah. It's cleaner because the
display_result() (should not be a problem because it's not yet
documented).
[ENHANCEMENTS]
- Support streaming output (function needs to set result metadata
is_stream => 1 and result needs to be glob/IO::Handle/array/tied
array, format needs to be text).
- Observe 'x.perinci.cmdline.default_format' metadata attribute.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perinci/CmdLine/Inline.pm view on Meta::CPAN
my @modules_for_all_args;
my @req_stmts;
for my $arg (sort keys %$args_prop) {
my $arg_spec = $args_prop->{$arg};
# we don't validate streaming input for now
next if $arg_spec->{stream};
my $arg_schema = $arg_spec->{schema};
my $arg_term = '$args->{"'.$arg.'"}';
if (defined $arg_spec->{default}) {
lib/Perinci/CmdLine/Inline.pm view on Meta::CPAN
$shebang_line = $args{shebang} // $^X;
$shebang_line = "#!$shebang_line" unless $shebang_line =~ /\A#!/;
$shebang_line .= "\n" unless $shebang_line =~ /\R\z/;
}
# this will be removed if we don't use streaming input or read from
# stdin
$cd->{sub_srcs}{_pci_gen_iter} = <<'_';
require Data::Sah::Util::Type;
my ($fh, $type, $argname) = @_;
if (Data::Sah::Util::Type::is_simple($type)) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perinci/CmdLine/Base.pm view on Meta::CPAN
#log_trace("TMP: handle cmdline_src for arg=%s", $an);
my $as = $args_p->{$an};
my $src = $as->{cmdline_src};
my $type = $as->{schema}[0]
or die "BUG: No schema is defined for arg '$an'";
# Riap::HTTP currently does not support streaming input
my $do_stream = $as->{stream} && $url !~ /^https?:/;
if ($src) {
die [531,
"Invalid 'cmdline_src' value for argument '$an': $src"]
unless $src =~ /\A(stdin|file|stdin_or_files?|stdin_or_args|stdin_line)\z/;
lib/Perinci/CmdLine/Base.pm view on Meta::CPAN
All direct subclasses of PC:Base do the formatting here.
=head2 $cmd->hook_display_result($r)
The hook is supposed to display the formatted result (stored in C<$r->{fres}>)
to STDOUT. But in the case of streaming output, this hook can also set it up.
All direct subclasses of PC:Base do the formatting here.
=head2 $cmd->hook_after_run($r)
lib/Perinci/CmdLine/Base.pm view on Meta::CPAN
and then skip saving output.
Data that is not representable as JSON will be cleansed using
L<Data::Clean::ForJSON>.
Streaming output will not be saved appropriately, because streaming output
contains coderef that will be called repeatedly during the normal displaying of
result.
=head2 PERINCI_CMDLINE_PLUGINS
view all matches for this distribution
view release on metacpan or search on metacpan
script/peri-eg-read-file view on Meta::CPAN
[--format-options=s] [--format=name] [--json] [--(no)naked-res]
[--no-config] [--no-env] <path>
=head1 DESCRIPTION
This function demonstrate output streaming of bytes.
To do output streaming, on the function side, you just return a coderef which
can be called by caller (e.g. CLI framework L<Perinci::CmdLine>) to read data
from. Code must return data or undef to signify exhaustion.
This works over remote (HTTP) too, because output streaming is supported by
L<Riap::HTTP> (version 1.2) and L<Perinci::Access::HTTP::Client>. Streams
are translated into HTTP chunks.
=head1 OPTIONS
view all matches for this distribution
view release on metacpan or search on metacpan
script/peri-eg-read-file-lite view on Meta::CPAN
[--(no)naked-res] [--no-config | -C] [--no-env]
[--page-result[=program]] <path>
=head1 DESCRIPTION
This function demonstrate output streaming of bytes.
To do output streaming, on the function side, you just return a coderef which
can be called by caller (e.g. CLI framework L<Perinci::CmdLine>) to read data
from. Code must return data or undef to signify exhaustion.
This works over remote (HTTP) too, because output streaming is supported by
L<Riap::HTTP> (version 1.2) and L<Perinci::Access::HTTP::Client>. Streams
are translated into HTTP chunks.
=head1 OPTIONS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perinci/Examples/FilePartial.pm view on Meta::CPAN
The functions are separated into this module because these functions read/write
files on the filesystem and might potentially be dangerous if
`Perinci::Examples` is exposed to the network by accident.
See also `Perinci::Examples::FileStream` which uses streaming instead of
partial.
_
};
lib/Perinci/Examples/FilePartial.pm view on Meta::CPAN
The functions are separated into this module because these functions read/write
files on the filesystem and might potentially be dangerous if
C<Perinci::Examples> is exposed to the network by accident.
See also C<Perinci::Examples::FileStream> which uses streaming instead of
partial.
=head1 FUNCTIONS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perinci/Sub/Wrapper.pm view on Meta::CPAN
"my \$err_$dn;",
"$cd->{result};",
);
if ($argspec->{stream}) {
$self->push_lines(
'if ('."\$err_$dn".') { die "Record #$i of streaming argument '."'$prefix$argname'".' ($rec) fails validation: '."\$err_$dn".'" }',
'$rec;',
);
} else {
$self->_errif(
400, qq["Argument '$prefix$argname' fails validation: \$err_$dn"],
view all matches for this distribution
view release on metacpan or search on metacpan
lib/PerlPoint/Generator.pm view on Meta::CPAN
[
"acceptedFormat=s@", # more accepted formats (embedded or included);
"activeContents", # evaluation of active contents;
"cache", # control the cache;
"cacheCleanup", # cache cleanup;
"dstreaming|docstreaming=s", # document stream handling (allow "docstreaming" for backwards compatibility);
"help", # online help, usage;
"imagedir|image_dir=s", # target image directory (allow "image_dir" for backwards compatibility with pp2html);
"imageref|image_ref=s", # target image directory reference (allow "image_ref" for backwards compatibility with pp2html);
"includelib=s@", # library pathes;
"nocopyright", # suppress copyright message;
lib/PerlPoint/Generator.pm view on Meta::CPAN
Cleans up the cache. Mostly invoked automatically. See docs for details.
EOO
dstreaming => <<EOO,
Document stream handling (for backwards compatibility, C<-docstreaming> can still be used).
Takes a numerical flag value as argument.
Example: -dstreaming 2
By default (or when 0 is passed as value), document streams are evaluated as streams. A value
of 1 ignores all docstreams, while a value of 2 treats docstream entry points as headlines.
For details about document streams please see the parser documentation and the tutorial.
lib/PerlPoint/Generator.pm view on Meta::CPAN
Example: -skipstream details
Note: you cannot skip the "main" stream.
Note: to skip document streams I<in general>, use C<-dstreaming 1>.
EOO
streamBuffer => <<EOO,
lib/PerlPoint/Generator.pm view on Meta::CPAN
skipcomments => exists $me->{options}{skipcomments},
docstreams2skip => exists $me->{options}{skipstream} ? $me->{options}{skipstream} : [],
docstreaming => (exists $me->{options}{dstreaming} and ($me->{options}{dstreaming}==DSTREAM_HEADLINES or $me->{options}{dstreaming}==DSTREAM_IGNORE)) ? $me->{options}{dstreaming} : DSTREAM_DEFAULT,
nestedTables => $me->{build}{nestedTables},
vispro => 1,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perlbal/Plugin/PSGI.pm view on Meta::CPAN
'psgi.url_scheme' => 'http',
'psgi.nonblocking' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
REMOTE_ADDR => $pb->{peer_ip},
SERVER_NAME => $server_name,
SERVER_PORT => $server_port,
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perlbal/Plugin/FlvStreaming.pm view on Meta::CPAN
=head1 NAME
Perlbal::Plugin::FlvStreaming - Enable FLV streaming with reverse proxy
=head1 DESCRIPTION
This plugin enable FLV streaming by modifying headers and prepending
FLV header to the body.
=head1 SYNOPSIS
LOAD FlvStreaming
lib/Perlbal/Plugin/FlvStreaming.pm view on Meta::CPAN
sub load { }
sub register {
my ($class, $svc) = @_;
unless ($svc && $svc->{role} eq "reverse_proxy") {
die "You can't load the flvstreaming plugin on a service not of role reverse_proxy.\n";
}
$svc->register_hook('FlvStreaming', 'start_proxy_request', \&start_proxy_request);
$svc->register_hook('FlvStreaming', 'modify_response_headers', \&modify_response_headers);
$svc->register_hook('FlvStreaming', 'prepend_body', \&prepend_body);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Perlito5X/Test2/API.pm view on Meta::CPAN
$hub->format(undef) if $hide;
}
}
elsif (! $parent->format) {
# If our parent has no format that means we're in a buffered subtest
# and now we're trying to run a streaming subtest. There's really no
# way for that to work, so we need to force the use of a buffered
# subtest here as
# well. https://github.com/Test-More/test-more/issues/721
$buffered = 1;
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/01-basics.t view on Meta::CPAN
ok( my $oid = $o->pgblobs_create_blob() , "Blob is created");
ok( $oid = $o->pgblobs_store_blob('BINARYCONTENT') , "Something is stored in blob");
ok( my $rc = $o->pgblobs_fetch_blob($oid) , "Fetched content");
ok( $rc eq 'BINARYCONTENT' , "Same content was retrieved");
{
## A bit of cake streaming now
my $nslices = 1000;
my $cake;
my $read = sub{
unless( $nslices-- ){ return undef ;}
my $slice = int(rand(1000)) + 1 ;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Pg/Reindex.pm view on Meta::CPAN
SQL
my ($xlog_diff) = @{ query( '', $q )->[0] };
if ( $xlog_diff > $opt_throttle_on ) {
lg "streaming lag = $xlog_diff ==> pausing\n";
LOOP: {
do {
select undef, undef, undef, 1; ## no critic
($xlog_diff) = @{ query( '', $q )->[0] };
} while ( $xlog_diff > $opt_throttle_off );
lib/Pg/Reindex.pm view on Meta::CPAN
select undef, undef, undef, 1; ## no critic
($xlog_diff) = @{ query( '', $q )->[0] };
redo LOOP if $xlog_diff > $opt_throttle_off;
}
}
lg "streaming lag = $xlog_diff -- continuing\n";
}
return;
}
sub next_index {
lib/Pg/Reindex.pm view on Meta::CPAN
sub reindex {
my ( $oid, $nspname, $quoted_nspname, $idxname, $quoted_idxname, $idxdef,
$size, $opt_validate )
= @_;
throttle; # wait for streaming replicas to catch up
lg "Rebuilding Index $quoted_nspname.$quoted_idxname\n";
my @log_id;
@log_id = query '', $oid, <<'SQL' unless $opt_dryrun;
lib/Pg/Reindex.pm view on Meta::CPAN
It handles normal indexes and C<PRIMARY KEY>, C<FOREIGN KEY> and C<UNIQUE>
constraints.
=head2 Streaming replication and throttling
Before creating the next index, the streaming replication lag is checked to
be below a certain limit. If so, nothing special happens and the index is
built.
Otherwise, C<rebuild> waits for the replicas to catch up. When the lag
drops under a second limit, the C<rebuild> does not immediately continue.
lib/Pg/Reindex.pm view on Meta::CPAN
don't modify the database but print the essential SQL statements.
=item --high-txn-lag
the upper limit streaming replicas may lag behind in bytes.
Default is 10,000,000.
=item --low-txn-lag
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Pinto/Remote/SelfContained.pm view on Meta::CPAN
chrome => $self->chrome,
httptiny => $self->httptiny,
);
}
sub run_streaming {
my ($self, $streaming_callback, $action_name, @args) = @_;
my $action = $self->make_action($action_name, @args);
$action->execute($streaming_callback);;
}
sub load_class_for_action {
my ($self, %args) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
t/data/usr/lib/pkgconfig/libarchive.pc view on Meta::CPAN
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libarchive
Description: library that can create and read several streaming archive formats
Version: 2.8.4
Libs: -larchive
Libs.private: -lacl -lattr -lxml2 -llzma -lbz2 -lz -lxml2
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/CGIBin/Streaming.pm view on Meta::CPAN
}
sub serve_path {
my($self, $env, $file) = @_;
die "need a server that supports streaming" unless $env->{'psgi.streaming'};
my $app = $self->{_compiled}->{$file} ||= do {
local $0 = $file; # keep FindBin happy
$self->mkapp(CGI::Compile->compile($file));
lib/Plack/App/CGIBin/Streaming.pm view on Meta::CPAN
=encoding utf-8
=head1 NAME
Plack::App::CGIBin::Streaming - allow old style CGI applications to use
the plack streaming protocol
=head1 SYNOPSIS
in your F<app.psgi>:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/CLI.pm view on Meta::CPAN
'psgi.version' => [1,1],
'psgi.errors' => $error,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::TRUE,
'psgi.streaming' => Plack::Util::FALSE,
'psgi.nonblocking' => Plack::Util::FALSE,
%ENV
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/DBI/Gofer.pm view on Meta::CPAN
=item * More tests
=item * Support http authorization (Basic and Digest)
=item * Support PSGI streaming and async.
=back
Please report any bugs or feature requests to
C<bug-plack-app-dbi-gofer@rt.cpan.org>, or through the web interface at
view all matches for this distribution
view release on metacpan or search on metacpan
# psgi.input *HTTP::Server::PSGI::$input (layers: scalar),
# psgi.multiprocess "",
# psgi.multithread "",
# psgi.nonblocking "",
# psgi.run_once "",
# psgi.streaming 1,
# psgi.url_scheme "http",
# psgi.version [
# [0] 1,
# [1] 1
# ],
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/FakeApache1/Handler.pm view on Meta::CPAN
'psgi.input' => $r,
'psgi.errors' => *STDERR,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
'psgi.nonblocking' => Plack::Util::FALSE,
};
$class->fixup_path($r, $env);
view all matches for this distribution
view release on metacpan or search on metacpan
local/lib/perl5/HTTP/Message/PSGI.pm view on Meta::CPAN
'psgi.input' => $input,
'psgi.errors' => *STDERR,
'psgi.multithread' => $FALSE,
'psgi.multiprocess' => $FALSE,
'psgi.run_once' => $TRUE,
'psgi.streaming' => $TRUE,
'psgi.nonblocking' => $FALSE,
@_,
};
for my $field ( $req->headers->header_field_names ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/Proxy/WebSocket.pm view on Meta::CPAN
my $req = Plack::Request->new($env);
# detect a protocol upgrade handshake or just proxy as usual
my $upgrade = $req->header('Upgrade') or return $self->SUPER::call($env);
$env->{'psgi.streaming'} or die "Plack server support for psgi.streaming is required";
my $client_fh = $env->{'psgix.io'} or die "Plack server support for the psgix.io extension is required";
my $url = $self->build_url_from_env($env) or return [502, [], ["Bad Gateway"]];
my $uri = URI->new($url);
lib/Plack/App/Proxy/WebSocket.pm view on Meta::CPAN
headers for the back-end request; see L</build_headers_from_env> for details.
This module has no configuration options beyond what L<Plack::App::Proxy>
requires or provides, so it may be an easy drop-in replacement. Read the
documentation of that module for advanced usage not covered here. Also, you
must use a L<PSGI> server that supports C<psgi.streaming> and C<psgix.io>.
For performance reasons, you should also use a C<psgi.nonblocking> server
(like L<Twiggy>) and the L<Plack::App::Proxy::Backend::AnyEvent::HTTP> user
agent back-end (which is the default, so no extra configuration is needed).
This module is B<EXPERIMENTAL>. I use it in development and it works
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/Proxy.pm view on Meta::CPAN
}
sub call {
my ($self, $env) = @_;
unless ($env->{'psgi.streaming'}) {
die "Plack::App::Proxy only runs with the server with psgi.streaming support";
}
my $url = $self->build_url_from_env($env)
or return [502, ["Content-Type","text/html"], ["Can't determine proxy remote URL"]];
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/RDF/Files.pm view on Meta::CPAN
iri('http://www.w3.org/2000/01/rdf-schema#Resource')
) ] );
}
# construct PSGI response
if ( $env->{'psgi.streaming'} ) {
$env->{'rdf.iterator'} = $iterator;
return sub {
my $responder = shift;
my $body = $self->_serialize_body( $serializer, $iterator );
$responder->( [ 200, $headers->headers, $body ] );
lib/Plack/App/RDF/Files.pm view on Meta::CPAN
The requested URI as string or L<URI> object.
=item rdf.iterator
The L<RDF::Trine::Iterator> that will be used for serializing, if
C<psgi.streaming> is set. One can use this variable to catch the RDF
data in another post-processing middleware.
=item rdf.files
An hash of source filenames, each with the number of triples (on success)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/App/WebSocket.pm view on Meta::CPAN
}
}
sub call {
my ($self, $env) = @_;
if(!$env->{"psgi.streaming"} || !$env->{"psgi.nonblocking"} || !$env->{"psgix.io"}) {
$env->{$ERROR_ENV} = "not supported by the PSGI server";
return $self->{on_error}->($env);
}
my $cv_conn = $self->{websocket_server}->establish_psgi($env, $env->{"psgix.io"});
return sub {
lib/Plack/App/WebSocket.pm view on Meta::CPAN
=over
=item *
C<psgi.streaming> environment is true.
=item *
C<psgi.nonblocking> environment is true, and the server supports L<AnyEvent>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Client/Backend/psgi_local.pm
t/00-compile.t
t/01-basic.t
t/02-inputs.t
t/03-delayed-response.t
t/04-streaming.t
t/lib/Plack/Client/Test.pm
t/release-eol.t
t/release-no-tabs.t
t/release-pod-coverage.t
t/release-pod-syntax.t
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Middleware/Debugger/Injector.pm view on Meta::CPAN
sub handle_html_content_type {
my ($self, $env, $resp) = @_;
# content to be inserted ...
my $content = $self->get_content_to_insert( $env );
# if the response is not a streaming one ...
if ( (scalar @$resp) == 3 && ref $resp->[2] eq 'ARRAY' ) {
# adjust Content-Length if we have it ...
if ( my $content_length = Plack::Util::header_get( $resp->[1], 'Content-Length' ) ) {
Plack::Util::header_set( $resp->[1], 'Content-Length', $content_length + length($content) );
lib/Plack/Middleware/Debugger/Injector.pm view on Meta::CPAN
last;
}
return $resp;
}
# if we have streaming response, just do what is sensible
else {
# NOTE:
# Plack will remove the Content-Length header
# if it has a streaming response, so there is
# no need to worry about that at all.
# - SL
return sub {
my $chunk = shift;
return unless defined $chunk;
lib/Plack/Middleware/Debugger/Injector.pm view on Meta::CPAN
If we detect a PSGI response which is an array of strings, we will process
it (in reverse) looking for the closing C<<body>> tag and inject the
content accordingly.
All other PSGI responses will be handled as if they are streaming
responses, in which case we simple return a C<CODE> reference that will
process the stream and if a closing C<<body>> tag is found, inject
accordingly.
=item C<application/json>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Handler/AnyEvent/FCGI.pm view on Meta::CPAN
'psgi.input' => do { open my $io, "<", \$request->read_stdin || \''; $io },
'psgi.errors' => io_from_write_cb sub { $request->print_stderr(@_) },
'psgi.multithread' => 0,
'psgi.multiprocess' => 0,
'psgi.run_once' => 0,
'psgi.streaming' => 1,
'psgi.nonblocking' => 1,
'psgix.input.buffered' => 1,
};
my $res = Plack::Util::run_app($app, $env);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Plack/Handler/AnyEvent/HTTPD.pm view on Meta::CPAN
SERVER_PROTOCOL => 'HTTP/1.0', # no way to get this from HTTPConnection
'psgi.version' => [ 1, 1 ],
'psgi.errors' => *STDERR,
'psgi.url_scheme' => 'http',
'psgi.nonblocking' => Plack::Util::TRUE,
'psgi.streaming' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::FALSE,
'psgi.input' => do {
open my $input, "<", \(ref $cont ? '' : $cont);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Message/PSGI.pm view on Meta::CPAN
'psgi.input' => $input,
'psgi.errors' => *STDERR,
'psgi.multithread' => $FALSE,
'psgi.multiprocess' => $FALSE,
'psgi.run_once' => $TRUE,
'psgi.streaming' => $TRUE,
'psgi.nonblocking' => $FALSE,
@_,
};
for my $field ( $req->headers->header_field_names ) {
view all matches for this distribution