Upgrade to Pro — share decks privately, control downloads, hide ads and more …

某人気アプリのクローンをPerlで作る(予定

B5582ce2d9959dfcff0384a07003e188?s=47 mackee
July 12, 2014

 某人気アプリのクローンをPerlで作る(予定

Yop - Yo private -
kuiperbelt + Amon2

B5582ce2d9959dfcff0384a07003e188?s=128

mackee

July 12, 2014
Tweet

Transcript

  1. ๭༗໊ΞϓϦͷΫϩʔϯΛ PerlͰ࡞Δʢ༧ఆ @mackee_w Mishima.pm 2014-07-12

  2. ୭ • @mackee_w / Ϛίϐʔ / ϑΝογϣϯϙΤϜ • Yokohama.pm ෭Ϧʔμʔ

    • ๭໘ന๏ਓ ઌ೔GoΛ΍Δͱ͍͕ͬͨPerlΛ΍ ΊΔͱݴ֮ͬͨ͑͸ͳ͍ͧͱ͍͏ࢥ͍
  3. ๭༗໊ΞϓϦͱ͸

  4. ͜Ε͔ͳʁ

  5. ͜Ε͔ͳʁ

  6. ͜Ε͔ͳʁ

  7. ͜ΕɾɾɾɾͰ͢

  8. Yoͱ͸ ໊લΛࢦఆͯ͠ʮYoʯͱૹΕΔΞϓϦ ϋΠίϯςΩετ͔ͭάϩʔόϧͰΦϙνϡχςΟͳίϛϡχέʔ γϣϯΛ࣮ݱ͢ΔࠓϋΠτΡΤϯςΟٴͼौ୩ք۾ʹਓؾͷSNS ΞϓϦέʔγϣϯ ࠓ͔ΒpapixʹૹΓ·͢

  9. ͳͥYoΛͭ͘Δ͔ • ๻ͷۈΊ͍ͯΔ໘ന๏ਓʹ͸ϓϥΠϕʔτ Gyazo΍ϓϥΠϕʔτGistͳͲطଘαʔϏεͷ ΦϯϓϨ൛ʢʁʣΈ͍ͨͳͷΛαΫοͱॻ͍ ͯஔ͍͍ͯ·͢ • YoͰίϛϡχέʔγϣϯऔΕΔͳΒΫϩʔζ υͳYo΋धཁ͕͋ΔͷͰ͸ʁ

  10. Yo private

  11. ུͯ͠Yop

  12. ·ͩදଆ࡞ͬͯΔͱ͜Ζ αʔόαΠυΛ঺հ

  13. Yoʹඞཁͳཁૉ • ໊લΛܾΊΔ(࠷ۙ͸ύεϫʔυ΋ೖͬͨ • ϓογϡ௨஌

  14. ໊લΛܾΊΔ • ͳΜ͔ೖྗͯ͠΋Β͍APIͳΓϑΥʔϜͳΓͰ ૹͬͯ΋Β͏ • ૹ͖ͬͯͯ΋Β໊ͬͨલΛόϦσʔγϣϯ͠ ͯDBʹಥͬࠐΉ • ͦΕΛΑ͠ͳʹҾ͚ΔΑ͏ʹ͢Δ

  15. ׳Ε͍ͯΔAmon2Ͱ ૊ΜͰΈΔ

  16. amon2-setup.pl Yop

  17. Yop::Web::Dispather

  18. Yop::Model::Member

  19. t/model/member.t

  20. ࢖͍ͬͯΔCPANϞδϡʔϧ • JSON::Types • Data::Validator • Time::Piece::Plus • Furl

  21. ςετͷ΄͏ • Test::Time • Test::Fatal • Test::Mock::Guard • Path::Tiny

  22. PerlͰϓογϡ௨஌ • Protocol::Websocket • Amon2ʹ΋WebSocketϓϥάΠϯ͸͋Δ • PocketIO • Socket.IOͷผ࣮૷

  23. Perl + ඇಉظ = AnyEvent • ίωΫγϣϯΛͭͳ͗ͬͺͳ͠ʹ͠ͳ͍ͱ͍ ͚ͳ͍ͷͰඇಉظඞਢ • ͦ͜ͰAnyEvent

    • ͔͠͠AnyEventʹ͸᠘͕……
  24. ίʔϧόοΫ஍ࠈ • AΛ΍ͬͨΒBΛ΍ͬͯͦΕ͕͓ΘͬͨΒCΛ ΍ͬͯ…… • ίʔϧόοΫ͕ωετ͍ͯͬͯ͠Α͘Θ͔Β ͳ͍͜ͱʹͳΔʂ • Promise::Defferedͱ͍͏ճආํ๏΋͋Δ

  25. AnyEvent + DBI = blocking… • DBIΛͦͷ··࢖͏ͱϒϩοΩϯάIOͳͷͰ ౰વΠϕϯτϧʔϓΛࢭΊΔ • WebSocketͩͱίωΫγϣϯҡ࣋Ͱ͖ͳ͔ͬ

    ͨΓ͢Δ • ࣮ࡍͦΜͳʹ໰୊ͳΒͳ͍આ΋͋Δ
  26. DBI on AnyEvent • AnyEvent::DBI • ͦͷ໊ͷ௨Γ • forkΛར༻ τϥϯβΫγϣϯ͕ࠞ͟Δ໰୊

    • AnyEvent::DBI::MySQL • MySQLઐ༻ • txn࢖͑ͳ͍ؾ͕͢ΔΜͰ͚͢ΕͲͲ͏ͳΜͰ͠ΐ͏͔
  27. Gearmanͱ͔ʹ೚ͤΔ • Gearman δϣϒΩϡʔϫʔΧʔ • Gearman::Client͸ϒϩοΩϯάIO • AnyEvent::Gearman::Client͸Mooseͷґଘ࣋ ͪͳͷͰ͋Μ·Γ࢖͍ͨ͘ͳ͍ײ͕͡க͠· ͢(࣋පͷMooseΞϨϧΪʔʁ

  28. ඇಉظ͸Perl͔Β௥͍ग़͢ʂ

  29. Kuiperbelt Asyncronous Protocol Proxy

  30. Kuiperbeltͱ͸ • ಉظϞσϧ(preforkϞσϧ)ͷΞϓϦέʔγϣ ϯͱ࿈ܞ͢Δ͜ͱΛ૝ఆͨ͠ඇಉظϓϩτί ϧͷίωΫγϣϯϓʔϧ • ࠓͷͱ͜ΖHTTP Stream(Long polling/ Comet)ͷΈରԠ

    • Golang੡ github.com/mackee/kuiperbelt
  31. ίωΫγϣϯ࣌

  32. kuiperbelt Yop(Amon2) PAPIX

  33. kuiperbelt Yop(Amon2) PAPIX ᶃTUSFBNDPOOFDU

  34. kuiperbelt Yop(Amon2) PAPIX ᶃTUSFBNDPOOFDU ᶄ66*%ΛؚΜͩ+40/

  35. kuiperbelt Yop(Amon2) PAPIX ᶃTUSFBNDPOOFDU ᶄ66*%ΛؚΜͩ+40/ ᶅKPJOVVJE66*%OBNF1"1*9

  36. YopΛૹΔͱ͖

  37. kuiperbelt Yop(Amon2) PAPIX MOZNION

  38. kuiperbelt Yop(Amon2) PAPIX MOZNION ᶃTFOEUBSHFU@OBNF1"1*9

  39. kuiperbelt Yop(Amon2) PAPIX MOZNION ᶃTFOEUBSHFU@OBNF1"1*9 ᶄTUSFBNTFOE66*%1"1*9ͷ66*%

  40. kuiperbelt Yop(Amon2) PAPIX MOZNION ᶃTFOEUBSHFU@OBNF1"1*9 ᶄTUSFBNTFOE66*%1"1*9ͷ66*% ᶅDPOOFDUΛ࢖ͬͯNFTTBHF:PQΛૹ৴

  41. PerlͰॻ͖΍͍͢ͱ͜Ζ͸Perl ͦͷଞ͸ؙ౤͛

  42. σόοά؀ڥ • ҎԼͷ΋ͷΛProcletͰଋͶΔ • Yop(Starlet) • kuiperbelt • Ҏ্ͷ΋ͷΛҰͭͷϙʔτͰड͚ΔͨΊʹ Plack::App::Proxy(Twiggy)

    • ຊ൪؀ڥ͸nginxͰଋͶΔ͔ͳ͋ • ଋͶΔͷ͸ΫϩεΦϦδϯରԠΊΜͲ͍ͷͰ
  43. ·ͱΊ • ϑϩϯτ͕શવ࡞Εͯͳ͍ͷͰؼͬͨΒຊؾ ग़͢ • Component / Vue.js / Polymerͱ͔࢖͍͍ͨ

    • Amon2Ͱ͕͢࢓ࣄಉ͡Α͏ͳײ͡+๻ͷΞϨ ϯδͱݴ͏ײ͡Ͱ͢ɻڵຯ͕͋Ε͹Ͳ͏ͧɻ ͋ͱͰ্͛Δ