Hello community, here is the log from the commit of package perl-Mojolicious for openSUSE:Factory checked in at 2018-02-13 10:31:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Mojolicious (Old) and /work/SRC/openSUSE:Factory/.perl-Mojolicious.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojolicious" Tue Feb 13 10:31:15 2018 rev:88 rq:575635 version:7.65 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Mojolicious/perl-Mojolicious.changes 2018-02-09 15:46:24.149855028 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Mojolicious.new/perl-Mojolicious.changes 2018-02-13 10:31:17.761001959 +0100 @@ -1,0 +2,12 @@ +Mon Feb 12 12:02:07 UTC 2018 - [email protected] + +- updated to 7.65 + see /usr/share/doc/packages/perl-Mojolicious/Changes + + 7.65 2018-02-11 + - Added EXPERIMENTAL timing->begin, timing->elapsed, timing->rps and + timing->server_timing helpers to Mojolicious::Plugin::DefaultHelpers. + - Added EXPERIMENTAL server_timing method to Mojo::Headers. + - Added support for new HTTP status code. + +------------------------------------------------------------------- Old: ---- Mojolicious-7.64.tar.gz New: ---- Mojolicious-7.65.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Mojolicious.spec ++++++ --- /var/tmp/diff_new_pack.HGogNX/_old 2018-02-13 10:31:18.692968377 +0100 +++ /var/tmp/diff_new_pack.HGogNX/_new 2018-02-13 10:31:18.692968377 +0100 @@ -17,7 +17,7 @@ Name: perl-Mojolicious -Version: 7.64 +Version: 7.65 Release: 0 %define cpan_name Mojolicious Summary: Real-time web framework ++++++ Mojolicious-7.64.tar.gz -> Mojolicious-7.65.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/Changes new/Mojolicious-7.65/Changes --- old/Mojolicious-7.64/Changes 2018-02-07 10:47:46.000000000 +0100 +++ new/Mojolicious-7.65/Changes 2018-02-11 14:19:36.000000000 +0100 @@ -1,4 +1,10 @@ +7.65 2018-02-11 + - Added EXPERIMENTAL timing->begin, timing->elapsed, timing->rps and + timing->server_timing helpers to Mojolicious::Plugin::DefaultHelpers. + - Added EXPERIMENTAL server_timing method to Mojo::Headers. + - Added support for new HTTP status code. + 7.64 2018-02-07 - Fixed a bug in Mojo::Log where short log messages spanning multiple lines would not be formatted properly for systemd. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/META.json new/Mojolicious-7.65/META.json --- old/Mojolicious-7.64/META.json 2018-02-07 11:16:36.000000000 +0100 +++ new/Mojolicious-7.65/META.json 2018-02-11 22:54:53.000000000 +0100 @@ -58,6 +58,6 @@ }, "x_IRC" : "irc://irc.perl.org/#mojo" }, - "version" : "7.64", + "version" : "7.65", "x_serialization_backend" : "JSON::PP version 2.97001" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/META.yml new/Mojolicious-7.65/META.yml --- old/Mojolicious-7.64/META.yml 2018-02-07 11:16:36.000000000 +0100 +++ new/Mojolicious-7.65/META.yml 2018-02-11 22:54:53.000000000 +0100 @@ -31,5 +31,5 @@ homepage: http://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/kraih/mojo.git -version: '7.64' +version: '7.65' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/lib/Mojo/Headers.pm new/Mojolicious-7.65/lib/Mojo/Headers.pm --- old/Mojolicious-7.64/lib/Mojo/Headers.pm 2018-01-03 13:49:51.000000000 +0100 +++ new/Mojolicious-7.65/lib/Mojo/Headers.pm 2018-02-10 21:15:14.000000000 +0100 @@ -16,8 +16,8 @@ qw(Last-Modified Link Location Origin Proxy-Authenticate), qw(Proxy-Authorization Range Sec-WebSocket-Accept Sec-WebSocket-Extensions), qw(Sec-WebSocket-Key Sec-WebSocket-Protocol Sec-WebSocket-Version Server), - qw(Set-Cookie Status Strict-Transport-Security TE Trailer Transfer-Encoding), - qw(Upgrade User-Agent Vary WWW-Authenticate) + qw(Server-Timing Set-Cookie Status Strict-Transport-Security TE Trailer), + qw(Transfer-Encoding Upgrade User-Agent Vary WWW-Authenticate) ); for my $header (keys %NAMES) { my $name = $header; @@ -609,6 +609,15 @@ Get or replace current header value, shortcut for the C<Server> header. +=head2 server_timing + + my $timing = $headers->server_timing; + $headers = $headers->server_timing('app;desc=Mojolicious;dur=0.0001'); + +Get or replace current header value, shortcut for the C<Server-Timing> header +from L<Server Timing|https://www.w3.org/TR/server-timing/>. +Note that this method is EXPERIMENTAL and might change without warning! + =head2 set_cookie my $cookie = $headers->set_cookie; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/lib/Mojo/IOLoop.pm new/Mojolicious-7.65/lib/Mojo/IOLoop.pm --- old/Mojolicious-7.64/lib/Mojo/IOLoop.pm 2018-01-03 13:49:48.000000000 +0100 +++ new/Mojolicious-7.65/lib/Mojo/IOLoop.pm 2018-02-11 21:29:21.000000000 +0100 @@ -390,8 +390,9 @@ my $id = $loop->client(address => '127.0.0.1', port => 3000, sub {...}); my $id = $loop->client({address => '127.0.0.1', port => 3000} => sub {...}); -Open a TCP/IP or UNIX domain socket connection with L<Mojo::IOLoop::Client>, -takes the same arguments as L<Mojo::IOLoop::Client/"connect">. +Open a TCP/IP or UNIX domain socket connection with L<Mojo::IOLoop::Client> and +create a L<Mojo::IOLoop::Stream> object, takes the same arguments as +L<Mojo::IOLoop::Client/"connect">. # Connect to 127.0.0.1 on port 3000 Mojo::IOLoop->client({port => 3000} => sub { @@ -529,8 +530,9 @@ my $id = $loop->server(port => 3000, sub {...}); my $id = $loop->server({port => 3000} => sub {...}); -Accept TCP/IP and UNIX domain socket connections with L<Mojo::IOLoop::Server>, -takes the same arguments as L<Mojo::IOLoop::Server/"listen">. +Accept TCP/IP and UNIX domain socket connections with L<Mojo::IOLoop::Server> +and create L<Mojo::IOLoop::Stream> objects, takes the same arguments as +L<Mojo::IOLoop::Server/"listen">. # Listen on port 3000 Mojo::IOLoop->server({port => 3000} => sub { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/lib/Mojo/Message/Response.pm new/Mojolicious-7.65/lib/Mojo/Message/Response.pm --- old/Mojolicious-7.64/lib/Mojo/Message/Response.pm 2018-01-03 13:49:45.000000000 +0100 +++ new/Mojolicious-7.65/lib/Mojo/Message/Response.pm 2018-02-07 21:13:30.000000000 +0100 @@ -50,6 +50,7 @@ 416 => 'Request Range Not Satisfiable', 417 => 'Expectation Failed', 418 => "I'm a teapot", # RFC 2324 :) + 421 => 'Misdirected Request', # RFC 7540 422 => 'Unprocessable Entity', # RFC 2518 (WebDAV) 423 => 'Locked', # RFC 2518 (WebDAV) 424 => 'Failed Dependency', # RFC 2518 (WebDAV) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/lib/Mojolicious/Controller.pm new/Mojolicious-7.65/lib/Mojolicious/Controller.pm --- old/Mojolicious-7.64/lib/Mojolicious/Controller.pm 2018-01-03 13:49:55.000000000 +0100 +++ new/Mojolicious-7.65/lib/Mojolicious/Controller.pm 2018-02-11 16:50:20.000000000 +0100 @@ -8,7 +8,6 @@ use Mojo::Util; use Mojolicious::Routes::Match; use Scalar::Util (); -use Time::HiRes (); has [qw(app tx)]; has match => @@ -201,11 +200,10 @@ if (!$stash->{'mojo.finished'} && ++$stash->{'mojo.finished'}) { # Disable auto rendering and stop timer - my $app = $self->render_later->app; - if (my $started = delete $stash->{'mojo.started'}) { - my $elapsed - = Time::HiRes::tv_interval($started, [Time::HiRes::gettimeofday()]); - my $rps = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed; + my $app = $self->render_later->app; + my $timing = $self->helpers->timing; + if (defined(my $elapsed = $timing->elapsed('mojo.timer'))) { + my $rps = $timing->rps($elapsed) // '??'; my $code = $res->code; my $msg = $res->message || $res->default_message($code); $app->log->debug("$code $msg (${elapsed}s, $rps/s)"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/lib/Mojolicious/Plugin/DefaultHelpers.pm new/Mojolicious-7.65/lib/Mojolicious/Plugin/DefaultHelpers.pm --- old/Mojolicious-7.64/lib/Mojolicious/Plugin/DefaultHelpers.pm 2018-01-03 13:49:56.000000000 +0100 +++ new/Mojolicious-7.65/lib/Mojolicious/Plugin/DefaultHelpers.pm 2018-02-11 16:12:05.000000000 +0100 @@ -6,6 +6,7 @@ use Mojo::Exception; use Mojo::IOLoop; use Mojo::Util qw(dumper hmac_sha1_sum steady_time); +use Time::HiRes qw(gettimeofday tv_interval); use Scalar::Util 'blessed'; sub register { @@ -41,6 +42,11 @@ $app->helper('reply.exception' => sub { _development('exception', @_) }); $app->helper('reply.not_found' => sub { _development('not_found', @_) }); + $app->helper('timing.begin' => \&_timing_begin); + $app->helper('timing.elapsed' => \&_timing_elapsed); + $app->helper('timing.rps' => \&_timing_rps); + $app->helper('timing.server_timing' => \&_timing_server_timing); + $app->helper(ua => sub { shift->app->ua }); } @@ -150,6 +156,24 @@ return !$c->helpers->reply->not_found; } +sub _timing_begin { shift->stash->{'mojo.timing'}{shift()} = [gettimeofday] } + +sub _timing_elapsed { + my ($c, $name) = @_; + return undef unless my $started = $c->stash->{'mojo.timing'}{$name}; + return tv_interval($started, [gettimeofday()]); +} + +sub _timing_rps { $_[1] == 0 ? undef : sprintf '%.3f', 1 / $_[1] } + +sub _timing_server_timing { + my ($c, $metric, $desc, $dur) = @_; + my $value = $metric; + $value .= qq{;desc="$desc"} if defined $desc; + $value .= ";dur=$dur" if defined $dur; + $c->res->headers->append('Server-Timing' => $value); +} + sub _url_with { my $c = shift; return $c->url_for(@_)->query($c->req->url->query->clone); @@ -461,6 +485,68 @@ %= stash('name') // 'Somebody' +=head2 timing->begin + + $c->timing->begin('foo'); + +Create named timestamp for L<"timing-E<gt>elapsed">. Note that this helper is +EXPERIMENTAL and might change without warning! + +=head2 timing->elapsed + + my $elapsed = $c->timing->elapsed('foo'); + +Return fractional amount of time in seconds since named timstamp has been +created with L</"timing-E<gt>begin"> or C<undef> if no such timestamp exists. +Note that this helper is EXPERIMENTAL and might change without warning! + + # Log timing information + $c->timing->begin('database_stuff'); + ... + my $elapsed = $c->timing->elapsed('database_stuff'); + $c->app->log->debug("Database stuff took $elapsed seconds"); + +=head2 timing->rps + + my $rps = $c->timing->rps('0.001'); + +Return fractional number of requests that could be performed in one second if +every singe one took the given amount of time in seconds or C<undef> if the +number is too low. Note that this helper is EXPERIMENTAL and might change +without warning! + + # Log more timing information + $c->timing->begin('web_stuff'); + ... + my $elapsed = $c->timing->elapsed('web_stuff'); + my $rps = $c->timing->rps($elapsed); + $c->app->log->debug("Web stuff took $elapsed seconds ($rps per second)"); + +=head2 timing->server_timing + + $c->timing->server_timing('metric'); + $c->timing->server_timing('metric', 'Some Description'); + $c->timing->server_timing('metric', 'Some Description', '0.001'); + +Create C<Server-Timing> header with optional description and duration. Note that +this helper is EXPERIMENTAL and might change without warning! + + # "Server-Timing: miss" + $c->timing->server_timing('miss'); + + # "Server-Timing: dc;desc=atl" + $c->timing->server_timing('dc', 'atl'); + + # "Server-Timing: db;desc=Database;dur=0.0001" + $c->timing->begin('database_stuff'); + ... + my $elapsed = $c->timing->elapsed('database_stuff'); + $c->timing->server_timing('db', 'Database', $elapsed); + + # "Server-Timing: miss, dc;desc=atl" + $c->timing->server_timing('miss'); + $c->timing->server_timing('dc', 'atl'); + =head2 title %= title diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/lib/Mojolicious.pm new/Mojolicious-7.65/lib/Mojolicious.pm --- old/Mojolicious-7.64/lib/Mojolicious.pm 2018-02-06 21:52:04.000000000 +0100 +++ new/Mojolicious-7.65/lib/Mojolicious.pm 2018-02-11 02:26:05.000000000 +0100 @@ -18,7 +18,6 @@ use Mojolicious::Types; use Mojolicious::Validator; use Scalar::Util (); -use Time::HiRes (); has commands => sub { my $commands = Mojolicious::Commands->new(app => shift); @@ -66,7 +65,7 @@ has validator => sub { Mojolicious::Validator->new }; our $CODENAME = 'Doughnut'; -our $VERSION = '7.64'; +our $VERSION = '7.65'; sub AUTOLOAD { my $self = shift; @@ -129,7 +128,7 @@ my $method = $req->method; my $path = $req->url->path->to_abs_string; $self->log->debug(qq{$method "$path"}); - $stash->{'mojo.started'} = [Time::HiRes::gettimeofday]; + $c->helpers->timing->begin('mojo.timer'); } # Routes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/t/mojo/headers.t new/Mojolicious-7.65/t/mojo/headers.t --- old/Mojolicious-7.64/t/mojo/headers.t 2018-01-04 02:44:51.000000000 +0100 +++ new/Mojolicious-7.65/t/mojo/headers.t 2018-02-10 20:54:26.000000000 +0100 @@ -94,9 +94,10 @@ 'right value'; is $headers->sec_websocket_version('foo')->sec_websocket_version, 'foo', 'right value'; -is $headers->server('foo')->server, 'foo', 'right value'; -is $headers->set_cookie('foo')->set_cookie, 'foo', 'right value'; -is $headers->status('foo')->status, 'foo', 'right value'; +is $headers->server('foo')->server, 'foo', 'right value'; +is $headers->server_timing('foo')->server_timing, 'foo', 'right value'; +is $headers->set_cookie('foo')->set_cookie, 'foo', 'right value'; +is $headers->status('foo')->status, 'foo', 'right value'; is $headers->strict_transport_security('foo')->strict_transport_security, 'foo', 'right value'; is $headers->te('foo')->te, 'foo', 'right value'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/t/mojo/response.t new/Mojolicious-7.65/t/mojo/response.t --- old/Mojolicious-7.64/t/mojo/response.t 2018-01-03 13:48:51.000000000 +0100 +++ new/Mojolicious-7.65/t/mojo/response.t 2018-02-07 21:13:59.000000000 +0100 @@ -60,6 +60,7 @@ 'right message'; is $res->code(417)->default_message, 'Expectation Failed', 'right message'; is $res->code(418)->default_message, "I'm a teapot", 'right message'; +is $res->code(421)->default_message, 'Misdirected Request', 'right message'; is $res->code(422)->default_message, 'Unprocessable Entity', 'right message'; is $res->code(423)->default_message, 'Locked', 'right message'; is $res->code(424)->default_message, 'Failed Dependency', 'right message'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.64/t/mojolicious/lite_app.t new/Mojolicious-7.65/t/mojolicious/lite_app.t --- old/Mojolicious-7.64/t/mojolicious/lite_app.t 2018-01-03 14:03:42.000000000 +0100 +++ new/Mojolicious-7.65/t/mojolicious/lite_app.t 2018-02-11 16:56:55.000000000 +0100 @@ -11,6 +11,7 @@ use Mojo::IOLoop; use Mojolicious::Lite; use Test::Mojo; +use Time::HiRes 'usleep'; # Missing plugin eval { plugin 'does_not_exist' }; @@ -444,6 +445,21 @@ $c->render(inline => 'dynamic inline ' . $dynamic_inline++); }; +get '/timing' => sub { + my $c = shift; + $c->timing->begin('foo'); + $c->timing->begin('bar'); + usleep 1000; + my $foo = $c->timing->elapsed('foo'); + my $bar = $c->timing->elapsed('bar'); + $c->timing->server_timing('miss'); + $c->timing->server_timing('dc', 'atl'); + $c->timing->server_timing('test', 'Some Test', '0.002'); + $c->timing->server_timing('app', undef, '0.001'); + my $rps = $c->timing->rps($bar); + $c->render(text => "Foo: $foo, Bar: $bar ($rps)"); +}; + my $t = Test::Mojo->new; # Application is already available @@ -1028,6 +1044,16 @@ $t->get_ok('/dynamic/inline')->status_is(200)->content_is("dynamic inline 1\n"); $t->get_ok('/dynamic/inline')->status_is(200)->content_is("dynamic inline 2\n"); +# Timing +$t->get_ok('/timing')->status_is(200) + ->header_like('Server-Timing' => + qr/miss, dc;desc="atl", test;desc="Some Test";dur=0.002, app;dur=0.001/) + ->content_like(qr/Foo: [0-9.]+, Bar: [0-9.]+ \([0-9.?]+\)/); +is $t->app->timing->elapsed('does_not_exist'), undef, 'no timing data'; +is $t->app->timing->rps('0.1'), '10.000', 'right number'; +is $t->app->timing->rps(1), '1.000', 'right number'; +is $t->app->timing->rps(0), undef, 'number too small'; + done_testing(); __DATA__
