perl6 web-app

22
Writing web application on Perl6 (In progress) 2015.09.17 gotanda.pm tokuhirom

Upload: tokuhiro-matsuno

Post on 14-Apr-2017

1.266 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Perl6 web-app

Writing web application on Perl6

(In progress)2015.09.17 gotanda.pm

tokuhirom

Page 2: Perl6 web-app

MoarVM’s IO has an issue.

https://github.com/MoarVM/MoarVM/issues/165

Page 3: Perl6 web-app

Can’t pass fd between threads

Page 4: Perl6 web-app

orz

Page 5: Perl6 web-app

But we can call libc methods via NativeCall

Page 6: Perl6 web-app

First, call fork(2) via NativeCall

Page 7: Perl6 web-app

sub fork() returns Int is native { ... }

Page 8: Perl6 web-app

Easy.

Page 9: Perl6 web-app

2nd, call waitpid(2) via NativeCall

Page 10: Perl6 web-app

module private { our sub waitpid(Int $pid, CArray[int] $status, Int $options) returns Int is native { ... } }

sub waitpid(Int $pid, Int $options) is export { my $status = CArray[int].new; $status[0] = 0; my $ret_pid = private::waitpid($pid, $status, $options); return ($ret_pid, $status[0]); }

Page 11: Perl6 web-app

Easy! (Patches welcome…)

Page 12: Perl6 web-app

Then,

Page 13: Perl6 web-app

Let’s implement BSD sockets wrapper.

Page 14: Perl6 web-app

I don’t recommend to use NativeCall directly.

Page 15: Perl6 web-app

There’s too many C types/structs.

Too many wrapper types…

Page 16: Perl6 web-app

Write dll in C. And call it via NativeCall.

Page 17: Perl6 web-app

Raw::Socket

BSD socket wrapper for Perl6

Page 18: Perl6 web-app

Then, write httpd.

Page 19: Perl6 web-app

Support features

• parse request

• send response

• pre-fork

• shotgun - reload code

• Win32 support ← NEW!

Page 20: Perl6 web-app

Demo

Page 21: Perl6 web-app

soozy.fushihara.net #perl6

Page 22: Perl6 web-app

Thanks!