Skip to content

use newer mojolicious defaults, remove config file dance #1961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions frameworks/Perl/mojolicious/app.conf

This file was deleted.

32 changes: 14 additions & 18 deletions frameworks/Perl/mojolicious/app.pl
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
use Mojolicious::Lite;
use Mojo::Pg;

use JSON::XS 'encode_json';
use Cpanel::JSON::XS 'encode_json';
use Scalar::Util 'looks_like_number';

# configuration

plugin Config => {
file => 'app.conf',
default => {
database_host => 'localhost',
hypnotoad => {
graceful_timeout => 1,
workers => 8,
},
hypnotoad_merge => {},
},
};

{
my $merge = app->config->{hypnotoad_merge};
@{app->config->{hypnotoad}}{keys %$merge} = values %$merge;
my $nproc = `nproc`;
app->config(hypnotoad => {
accepts => 0,
clients => int( 256 / $nproc ) + 1,
graceful_timeout => 1,
requests => 10000,
workers => $nproc,
});
}


helper pg => sub { state $pg = Mojo::Pg->new('postgresql://benchmarkdbuser:benchmarkdbpass@' . shift->config->{database_host} . '/hello_world') };
{
my $db_host = $ENV{DBHOST} || 'localhost';
helper pg => sub { state $pg = Mojo::Pg->new('postgresql://benchmarkdbuser:benchmarkdbpass@' . $db_host . '/hello_world') };
}

helper render_json => sub {
my $c = shift;
Expand Down Expand Up @@ -80,7 +76,7 @@
foreach (1 .. $q) {
my $id = int rand 10_000;
my $randomNumber = $db->query('SELECT randomnumber FROM World WHERE id=?', $id)->array->[0];
$db->query('UPDATE World SET randomnumber=? WHERE id=?', ($randomNumber = 1 + int rand 10_000), $id) if $update;
$db->query('UPDATE World SET randomnumber=? WHERE id=?', ($randomNumber = 1 + int rand 10_000), $id) if $update;
push @$r, { id => $id, randomNumber => $randomNumber };
}

Expand Down
4 changes: 2 additions & 2 deletions frameworks/Perl/mojolicious/cpanfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
requires 'Mojolicious', '6.02';
requires 'Mojolicious', '6.53';
requires 'Mojo::Pg', '1.14';
requires 'JSON::XS', '3.01';
requires 'Cpanel::JSON::XS', '3.01';
requires 'EV', '4.18';

recommends 'IO::Socket::IP', '0.36';
Expand Down
32 changes: 11 additions & 21 deletions frameworks/Perl/mojolicious/cpanfile.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ DISTRIBUTIONS
Canary::Stability 2006
requirements:
ExtUtils::MakeMaker 0
Cpanel-JSON-XS-3.0213
pathname: R/RU/RURBAN/Cpanel-JSON-XS-3.0213.tar.gz
provides:
Cpanel::JSON::XS 3.0213
requirements:
ExtUtils::MakeMaker 0
Pod::Text 2.08
Pod::Usage 1.33
DBD-Pg-3.5.3
pathname: T/TU/TURNSTEP/DBD-Pg-3.5.3.tar.gz
provides:
Expand Down Expand Up @@ -130,14 +138,6 @@ DISTRIBUTIONS
IO::Socket 0
Socket 1.97
Test::More 0.88
JSON-XS-3.01
pathname: M/ML/MLEHMANN/JSON-XS-3.01.tar.gz
provides:
JSON::XS 3.01
requirements:
ExtUtils::MakeMaker 0
Types::Serialiser 0
common::sense 0
Mojo-Pg-2.23
pathname: S/SR/SRI/Mojo-Pg-2.23.tar.gz
provides:
Expand All @@ -151,8 +151,8 @@ DISTRIBUTIONS
DBD::Pg 3.005001
ExtUtils::MakeMaker 0
Mojolicious 6.0
Mojolicious-6.48
pathname: S/SR/SRI/Mojolicious-6.48.tar.gz
Mojolicious-6.55
pathname: S/SR/SRI/Mojolicious-6.55.tar.gz
provides:
Mojo undef
Mojo::Asset undef
Expand Down Expand Up @@ -215,7 +215,7 @@ DISTRIBUTIONS
Mojo::UserAgent::Transactor undef
Mojo::Util undef
Mojo::WebSocket undef
Mojolicious 6.48
Mojolicious 6.55
Mojolicious::Command undef
Mojolicious::Command::cgi undef
Mojolicious::Command::cpanify undef
Expand Down Expand Up @@ -267,16 +267,6 @@ DISTRIBUTIONS
JSON::PP 2.27103
Pod::Simple 3.09
Time::Local 1.2
Types-Serialiser-1.0
pathname: M/ML/MLEHMANN/Types-Serialiser-1.0.tar.gz
provides:
JSON::PP::Boolean 1.0
Types::Serialiser 1.0
Types::Serialiser::BooleanBase 1.0
Types::Serialiser::Error 1.0
requirements:
ExtUtils::MakeMaker 0
common::sense 0
common-sense-3.74
pathname: M/ML/MLEHMANN/common-sense-3.74.tar.gz
provides:
Expand Down