Skip to content

Commit fc310d7

Browse files
committed
Merge pull request #5 from naturalist/master
Added the Perl Kelp micro framework
2 parents ef5613c + 951129e commit fc310d7

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

kelp/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Setup
2+
3+
* Perl 5.10+
4+
* MySQL 5.5
5+
* Wrk 2.0
6+
7+
# Requirements
8+
9+
* Kelp
10+
* DBD::mysql
11+
* Starman (if using Starman as web server)
12+
* Plack (for plackup)
13+
* nginx (if you want to front Dancer with nginx, nginx.conf provided)
14+
15+
# Deployment
16+
17+
Something along the lines of
18+
19+
plackup -E production -s Starman --workers=2 -l /tmp/frameworks-benchmark.sock -a ./app.pl
20+
21+
if you want to front it with nginx, otherwise
22+
23+
plackup -E production -s Starman --port=8080 --workers=2 -a ./app.pl

kelp/app.pl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env perl
2+
use Kelp::Less;
3+
use DBI;
4+
5+
attr dbh => sub {
6+
my $database = 'test';
7+
my $host = 'ip-10-34-150-134.eu-west-1.compute.internal';
8+
my $dsn = 'dbi:mysql:database=$database;host=$host;port=3306';
9+
DBI->connect( $dsn, 'root', '', {} );
10+
};
11+
12+
get '/json' => sub {
13+
{ message => 'Hello, World!' }
14+
};
15+
16+
get '/db' => sub {
17+
my $self = shift;
18+
my $queries = param->{queries} || 1;
19+
my @response;
20+
for( 1 .. $queries ) {
21+
my $id = int rand 10000 + 1;
22+
if ( my $row = $self->dbh->quick_select( 'world', { id => $id } ) ) {
23+
push @response, { id => $id, randomNumber => $row->{randomnumber} };
24+
}
25+
}
26+
{ \@response }
27+
};
28+
29+
run;

kelp/nginx.conf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
user www;
2+
3+
worker_processes 2;
4+
5+
events {
6+
worker_connections 1024;
7+
}
8+
9+
http {
10+
output_buffers 1 32k;
11+
postpone_output 1460;
12+
13+
sendfile on;
14+
tcp_nopush on;
15+
16+
tcp_nodelay on;
17+
18+
upstream backendurl {
19+
server unix:/tmp/frameworks-benchmark.sock;
20+
}
21+
22+
server {
23+
listen 8888;
24+
server_name localhost;
25+
26+
location / {
27+
try_files $uri @proxy;
28+
access_log off;
29+
expires max;
30+
}
31+
32+
location @proxy {
33+
proxy_set_header Host $http_host;
34+
proxy_pass http://backendurl;
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)