use strict; use warnings; use utf8; use lib 'lib'; use Plusen; my $p = Plusen->bootstrap({ config => { meta => { title => 'HTTP::Engine の概要とTODO', author => 'Kazuhiro Osawa - ( Yappo )', email => 'yappo shibuya pl', }, plugins => [ { module => 'ScriptLoader::Simple' }, { module => 'Device::Term', }, { module => 'Device::Growl', }, ], }, }); __DATA__ === title: 8分くらいで覚える HTTP::Engine === title: HTTP::Engine とは === title: HTTP::Engine is list: - WSGI on Perl, Rack on Perl - Simple - Poweful - no Pluggable ;-) - use Moose; - Catalyst::Engine + Cat::Req + Cat::Res - + WSGI Power + α === title: Perlの世界のWSGI/Rack list: - mod_perl, fast cgi, 単独サーバ - HTTPの処理に特化 - sessionの処理すらない === title: web application framework's framework === title: ほぼ全てのコードに対してテストケースが書かれている === title: 利用者の必須作業 list: - use HTTP::Engine - HTTP::Engine の初期化 - Interface の設定 - request_handler を書く - HTTP::Engine を run === title: request_handler ? list: - 全てのHTTPリクエスト処理に対する基底メソッド - 引数は request object のみ - 戻り値で response object を必ず返す - 約束はこれだけ - request_handler 上で dispacher とか呼ぶべし === title: request_handler ? list: - request object = HTTP::Engine::Request - respone object = HTTP::Engine::Response - 使い方はそれぞれのPODにある === title: code code: | HTTP::Engine->new( interface => { module => 'ServerSimple', args => { port => 824242 }, request_handler => sub { my $req = shift; HTTP::Engine::Response->new( body => 'hello', ) } })->run; === title: こおど code: | 初期化( インターフェィス => { エンジンの種類 => 'ServerSimple', 設定 => { port => 824242 }, コールバック => sub { リクエストデータ受け取り helloという文字をブラウザに送る } })->サーバ起動; === title: 簡単ですね === title: Layer code: | +-------------------------------+ | Application | +-------------------------------+ | ↑ Request | Response ↓ | | ↑ Builder | Writer ↓ | | Interface | +-------------------------------+ | HTTP Server | +-------------------------------+ === title: サポートしているInterface === title: Test list: - test interface - for HTTP::Engine developer === title: CGI list: - CGI用 - 起動がとても遅い - ほとんどネタ === title: Standalone list: - HTTP::Engine単独で動くサーバ - keepalive/preforkでバグが多い - 1.0.0 までには削除される予定 === title: ServerSimple list: - Standaloneの代わり - HTTP::Server::Simple がベース - 簡単な設定でServerの挙動が変わる(予定) === title: prefork server code: | HTTP::Engine->new( interface => { module => 'ServerSimple', args => { port => 824242, net_server => 'Net::Server::PreForkSimple' }, request_handler => sub {}, })->run; === title: 何が選べるかは Net::Server みて === title: POE list: - POE based http server - Component::Server::TCP - Filter::HTTPD - 数々のPOEの資産を同時に使う時用 === title: FCGI list: - FastCGI で動くinterface - lighty + FastCGI な構成 - kawa.netさんが - Apache2 + mod_fastcgi で動くようにしてくれたみたい === title: ModPerl list: - Apache2 + mod_perl で動かすためのハンドラ - Apache との繋げ方が複雑だった - 今はPODにやり方が書いてある === title: それぞれのInterfaceはポータブルか? === title: NO list: - ModPerlは他と比べて特殊 - POE は POE::Kernel->run が必須 - FCGI, CGI, ServerSimple はだいたい同じ - event loop をどこに持つのかの違い === title: ここまで 導入編 === title: ここから TODO編 === title: Mojo list: - あまり気にしない === title: HTTP::Engine 1.0.0 list: - 仕様はほぼほぼ確定 - のこりはドキュメント - and more tests === title: 0.1.x, 0.1.x_x list: - ドキュメント書きメイン === title: wish list list: - tutorial - cookbook - how to - for quick hack - for developer's === title: とりあえず日本語から書く === title: Middleware === title: Middleware 概要 list: - App(Middle(Middle(HTTP::Engine))) - ラッキョウのようにいて - request_handler を middleare で囲む - HTTP::Engine Core には含まれない - HTTPEx::Midlleware::* - midlleware 向け hook point を明確に === title: Reverse Prxy な時の前処理などでも === title: middleware wish list list: - Session - Authentication - ReverseProxy filter - fillinform? - pre validation? - etc... etc... === title: ここらへん、wish list整備して週末のhackathoneで書きたいところ === title: non-blocking interface list: - client の接続を non-blocking - backend process も non-blocking - request_handler の中で block しつつ - main loop は non-blocking である感じ - 試しに POE で書いたが上手くいかず - IO::Async で書くにも大改修っぽい - 多分 continuation === title: lestrrat: 正直それはCoro->cede()に聞こえた === title: べ、、べつにRemedieのためなんかじゃないからね! === title: ふたつの問題 === title: http://mark.stosberg.com/blog/2008/11/startup-benchmarks-for-mojo-catalyst-titanium-httpengine-and-cgiapplication.html === title: Startup benchmarks list: - Empty Script 4.7M - CGI::Application 6.0M - (ry - Catalyst 13.5M - HTTP::Engine 14.9M === title: CGIだから遅いのは置いといてもメモリ食い過ぎ Catalyst よりでかい === title: その2 === title: "when I tried to download this module along with its dependencies, the result was over 200 Perl modules" === title: ちょっと依存多いかなぁという印象 === title: これらだけは解決しときたいところ === title: One More Thing... === title: Progress Bar DEMO (!charsbar) === title: これもMidllewareであるとかもね === title: いじょうおわりなの