レガシーPerlと「今」を組み合わせ、開発を継続し続ける方法

 レガシーPerlと「今」を組み合わせ、開発を継続し続ける方法

YAPC::Fukuoka 2017 HAKATAでロリポップのコアAPIについて話しました。

1b838da2065660793d5b26f2cdc32de7?s=128

Kazuhiko Yamashita

July 01, 2017
Tweet

Transcript

  1. ʙ1FSMόϦόϦॻ͚Δͬͯਧ͍ͯϖύϘʹೖࣾ͠·ͨ͠ʙ ࢁԼ࿨඙(.01FQBCP *OD :"1$'VLVPLB)","5" ϨΨγʔ1FSMͱʮࠓʯΛ૊Έ߹ Θͤɺ։ൃΛܧଓ͠ଓ͚Δํ๏

  2. IUUQTUFOTOBQPODPN νʔϑςΫχΧϧϦʔυ ࢁԼ࿨඙!QZBNB ϗεςΟϯάࣄۀ෦

  3. IUUQTUOTKQ

  4. None
  5. ࠷ॳʹ͓఻͑͠·͢ɺ ๻͸όʔδϣϯΞοϓ͠ͳ͍ଆͷ ਓؒͰ͢

  6. ϩϦϙοϓͷ؆қγεςϜߏ੒ਤ 1FSM ϩϦϙοϓͷίΞ"1*͸1FSM  .Z42-4FSWFS 'SPOU"1* 3BJMT ;FOE ਃ͠ࠐΈαΠτ ίΞ"1*

    ϑϩϯτ"1* ϗεςΟϯάαʔό܈ .BJM4FSWFS 8FC4FSWFS ܖ໿৘ใ΍αʔό৘ใΛ ίϯτϩʔϧ αʔόϓϩϏδϣχϯάͷ ࣮ߦࢦࣔ
  7. None
  8. 

  9. wඇৗʹγϯϓϧͳ"1*Ͱ͋ΔͨΊɺੵۃతͳόʔδϣϯΞοϓͷಈػ ͕ͳ͔ͬͨ w಺෦"1*ͳͷͰɺϑϩϯτܥαʔόͱൺ΂ΔͱɺόʔδϣϯΞοϓͷ ༏ઌ౓͕Լ͕ͬͯ͠·͏ w$1"/ͱͷဃ཭͕େ͖͘ͳΓɺͲΜͲΜόʔδϣϯΞοϓ͕ࠔ೉ʹ ͳ͍͖ͬͯɺ਎ಈ͖͕औΕͳ͍ ϖύϘݻ༗ͷࣄ৘ ͳͥ1FSM

  10. wόʔδϣϯΞοϓίετΛ෷͏ʹͯ͠΋ɺ1FSMͷॻ͖खΛूΊΔ͜ͱ ͕ͦΕͳΓʹࠔ೉Ͱ͋Δ w৽ن։ൃҊ݅Ͱ1FSM͕બ୒ࢶʹೖΓͮΒ͍͜ͱ͔Βࢢ৔ʹগͳ͍ wࣾ಺ʹ͓͍ͯ΋ϝϯςφ͕ඇৗʹݶΒΕ͖ͯͭͭ͋Γɺݹࢀϝϯόʔ ͔ଞݴޠͰͦΕͳΓʹ࿅౓͕͋ΔΤϯδχΞ 1FSMͷࣄ৘ ͳͥ1FSM

  11. ϩϦϙοϓʂ͸·ͩ·ͩ੒௕աఔ αʔϏε͕ਐԽ͢ΔͳΒ͹ɺ "1*΋ܧଓత։ൃ͕ඞཁ

  12. ܧଓత։ൃΛߦ͏ͨΊʹ৐Γӽ͑ͨ΋ͷ wڞ༻αʔόΛར༻ͨ͠։ൃ؀ڥ wϝϯςφϯε͞Ε͍ͯͳ͍Ϣχοτςετ wΦϖϨʔγϣϯͷΦʔτϝʔγϣϯԽ

  13. ڞ༻αʔόΛར༻ͨ͠։ൃ؀ڥ

  14. ڞ༻αʔόΛར༻ͨ͠։ൃ؀ڥ %FW"1* .Z42-4FSWFS .BJM4FSWFS 8FC4FSWFS ैདྷ ։ൃ؀ڥΛίϯςφԽ͠ɺ ڞ༻ʹΑΔϦιʔεڝ߹Λແ͘͢ $POUBJOFS ݱࡏ

    %FW"1* .Z42- 4FSWFS .PDL.BJM .PDL8FC
  15. ڞ༻αʔόΛར༻ͨ͠։ൃ؀ڥ 1FSMͷ؀ڥ͔ΒUBSH[Ͱ ϞδϡʔϧΛશͯநग़͠ίϯςφԽ $ tar zcvf site_perl.tar.gz /usr/lib64/perl5/site_perl/5.8.8 # in

    docker # tar zxvf site_perl.tar.gz # docker commit xxxxx private.pepabo.com/coreapi:latest
  16. ϝϯςφϯε͞Ε͍ͯͳ͍ Ϣχοτςετ

  17. ϝϯςφϯε͞Ε͍ͯͳ͍Ϣχοτςετ ଞͷίϯϙʔωϯτͱີ݁߹ͳͷͰ ςετ͕ॻ͖ͮΒ͍ɺࣦഊ͠΍͍͢ %FW"1* 8FC4FSWFS XFCFYBNQMFKQ ਃ͠ࠐΈ 8FCαʔόʹFYBNQMFKQͷ σΟϨΫτϦΛ࡞੒ 8FCαʔόͷਃࠐΈςετ

    FYBNQMFKQͷਃࠐ৘ใ͕%#ʹ͋Δͳ͍ 8FC4FSWFSͱ઀ଓ͞Ε͍ͯΔ͍ͳ͍ 8FC4FSWFSͷσΟϨΫτϦ͸͋Δͳ͍
  18. ϝϯςφϯε͞Ε͍ͯͳ͍Ϣχοτςετ .PDLԽ %#ͷঢ়ଶΛ࣋ͨͳ͍

  19. ϝϯςφϯε͞Ε͍ͯͳ͍Ϣχοτςετ 5FTU.PDL(VBSEΛར༻͠ɺ ֎෦ίϯϙʔωϯτ͸શͯ.PDLԽ my $mock = mock_guard(‘Hosting::Server::API::Ext', +{ run =>

    sub { my($self, $params) = @_; switch ($params->{'parameters'}) { case /—domain=example.com/ { return { key => $dummy_key, }; } } }, });
  20. ϝϯςφϯε͞Ε͍ͯͳ͍Ϣχοτςετ 5FTUNZTRMEΛར༻͠ɺ ςετσʔλͷিಥΛճආ͢Δ sub new { my %self; my $class

    = shift; $self->{mysqld} = Test::mysqld->new(my_cnf => {'port' => '3306'}, copy_data_from => 't/data/mysql'); $self->{dbh} = DBI->connect($self->{mysqld}->dsn, '', '') or die 'cannot connect to db'; return bless $self, $class; } UEBUBNZTRM .Z42- UFTUDBTF" UFTUDBTF# .Z42- ϕʔεσʔλΛݩʹ ৽نΠϯελϯεىಈ ςετέʔε͝ͱʹ࢖༻͢Δ %#͕ҟͳΔͨΊ ΫϦʔχϯά͕ෆཁ
  21. ϝϯςφϯε͞Ε͍ͯͳ͍Ϣχοτςετ 5FTU%#MPBE@pYUVSFΛར༻͠ɺ ςετϨίʔυͷ४උΛ༰қʹͨ͠ UEBUBNZTRM .Z42- UFTUDBTF" UFTUDBTF# .Z42- ϕʔεσʔλΛݩʹ ৽نΠϯελϯεىಈ

    DBTF@BZNM EPNBJOFYBNQMFDPN VTFSVTFS@ QBUIIPNFVTFS@ ʜ
  22. ϝϯςφϯε͞Ε͍ͯͳ͍Ϣχοτςετ %SPOFJPͰࣗಈςετ࣮ߦ IUUQTXXXTMJEFTIBSFOFUVE[VSBESPOFJP PQFOTUBDL %PDLFS4XBSN 7. ESPOFJP 7. 7. 7.

    7. 7. 7.
  23. ΦϖϨʔγϣϯͷ ΦʔτϝʔγϣϯԽ

  24. ΦϖϨʔγϣϯͷΦʔτϝʔγϣϯԽ MJHIUIUUQEͷ੍໿͕͋Γɺ खಈͰσϓϩΠ͢Δӡ༻ σϓϩΠαʔόʹϩάΠϯ͠ɺHJUDMPOF EFQMPZTIΛ࣮ߦ͢Δ ର࿩తϓϩϯϓτʹΑΓHJUQVMMͳͲΛ࣮ߦ STZODͰσϓϩΠઌʹ഑෍ ଴ػܥαʔόͷGBTUDHJɺMJHIUUQEΛ࠶ىಈ खಈͰಈ࡞֬ೝ ݱ༻ܥαʔόͷGBTUDHJɺMJHIUUQEΛ࠶ىಈ

    σϓϩΠखॱ खॱ͕ଟ͘ɺ͕͔͔࣌ؒΔɺଋറ͞ΕΔ ಈ࡞֬ೝ͕ਓʹґଘ͍ͯ͠Δ ࠶ىಈ࿙ΕͳͲΛ๷͙͜ͱ͕ग़དྷͳ͍ ՝୊
  25. $BQJTUSBOP

  26. ΦϖϨʔγϣϯͷΦʔτϝʔγϣϯԽ $BQJTUSBOPΛར༻͠ɺ σϓϩΠ͔Βಈ࡞֬ೝ·ͰΛࣗಈԽ CVOEMFFYFD TUBHJOHEFQMPZ KFOLJOKPC TMBDLOPUJGZ CVOEMFFYFD QSPEVDUJPOEFQMPZ εςʔδϯάσϓϩΠޙɺ

    MJHIUUQE΍GBTUDHJͷ࠶ىಈ ࣗಈͰΠϯςάϨʔγϣϯςετΛ ࣮ߦ ςετͷ݁ՌΛ4MBDL௨஌ ਖ਼ৗͰ͋Ε͹ຊ൪؀ڥ΁ σϓϩΠ
  27. ΦϖϨʔγϣϯͷΦʔτϝʔγϣϯԽ ͋ΒΏΔΦϖϨʔγϣϯΛ 3BLFͰ࣮ݱ ɾSBLFEFQMPZσϓϩΠͷҰ࿈ͷྲྀΕΛ࣮ߦ ɾSBLFEPDLFS։ൃ؀ڥͷEPDLFSΛىಈ ɾSBLFEC%#εΩʔϚͷߋ৽

  28. ͜Ε͘Β͍΍Δͱɺ ʮ͜ΕͳΜ͔։ൃग़དྷΔΜ͡ΌͶʁʯ ײ͕ৢ੒͞ΕΔ

  29. ೔ʑ։ൃӡ༻͢Δٕज़͸ΑΓྑ͍΋ͷΛબͼ͍ͨ ։ൃ͕ग़དྷΔঢ়ଶʹͳͬͨͱͯ͠΋ ָ؍తͳঢ়گͰ͸ͳ͍ w1FSMΛ࢖͍ଓ͚Δ৔߹ɺ࠷৽ͷઃܭ΍ɺϞδϡʔϧΛར༻͢Δػձ ͸ͳ͍ wϝϯςφ͕ݮΔͱ͍͏͜ͱ͸ɺকདྷతʹ͸ةػతঢ়گΛট͘Մೳੑ͕ ͋Δ

  30. /FYU4UFQ (PMBOH

  31. 8IZ 3VTUͱൺ΂ͯ৘ใྔ͕ଟ͍͜ͱ΍ɺ ग़དྷΔ͜ͱͷࠩҟ͕গͳ͍ wੈքతʹීٴͨ͠എܠ͕͋Γɺ೔ຊޠͷ৘ใ΋๛෋Ͱ͋Δ wՄൖੑ͕ඇৗʹߴ͍ͨΊɺӡ༻4IFMMͷஔ͖׵͑ʹద͍ͯ͠Δ wϗεςΟϯά͸αʔό͕঎ࡐͳͷͰɺςετͷͳ͍πʔϧ͸࢖͍ͨ͘ ͳ͍ wงғؾͰ͍͍ͩͨ ߴ଎ʹಈ͘

  32. ϑϨʔϜϫʔΫͷબ୒ طଘͷॲཧ͕ඇৗʹγϯϓϧͰ͋ΔͨΊ &DIPΛબ୒ͨ͠ wখ͞ͳϓϩδΣΫτͰ3FWFMͱ&DIPΛൺֱ։ൃͨ͠ w3FWFM͸όονॲཧͳͲ΋αϙʔτ͓ͯ͠Γɺ3BJMTͬΆ͞͸͋ͬͨ ͕ɺ֮͑Δ͜ͱ΋ଟ͍ w&DIP͸࣮૷͕ബ͘ɺϛυϧ΢ΣΞ͕ॻ͖΍͍͢ɺ͋Δఔ౓εΫϦϓ ςΟϯά͕ඞཁͳ͜ͱͰϝϯόʔͷ(PMBOHͷशಘʹ΋ͪΐ͏Ͳྑ͍ ϘϦϡʔϜʹࢥ͑ͨ

  33. ࠔ͍ͬͯΔ͜ͱ (PMBOHͰ03.͸݁ߏͭΒ͍ w42-ΛͳΔ΂͘ॻ͖ͨ͘ͳ͔ͬͨͷͰɺHPSNΛબ୒ͨ͠ w"DUJWF3FDPSEͰҭͬͨͷͰɺϦϨʔγϣϯͷख͕ؒ݁ߏͭΒ͍ w3FMBUFE΍1SFMPBEͳͲϦϨʔγϣϯઌͷϨίʔυΛऔಘ͢Δํ๏͕ ෳ਺͋ͬͯɺ(PMBOHͬΆ͘ͳ͍ wϞσϧͷҾ਺͕੩తܕ෇͚ͳͨΊѻ͍ͮΒ͍͜ͱ͔Βɺ$POUSPMMFS͕ %#ʹؔ৺Λ࣮࣋ͭ૷͕ੈͷதʹଟ͍

  34. CVU ͔͠͠

  35. ݁Ռͱͯ͠গͮͭ͠ΠϯϑϥνʔϜʹ (PMBOH͕ࠜ෇͖ॳΊɺ ςετΛॻ͘श׳΋͍͖ͭͯͨ

  36. ࠷ޙʹ wܧଓత։ൃ͕Մೳͳঢ়گ͕࡞ΕΔɺηΩϡϦςΟతͳ ཁ͕݅ͳ͚Ε͹ແཧʹόʔδϣϯΛ্͛Δඞཁ͸ͳ͍ wࡢࠓͷݴޠͷݯྲྀ͸1FSMʹ͋Δͱײ͡Δ͘Β͍1FSMʹ ͸Ϟδϡʔϧॆ࣮ͯ͠ΔͷͰࠓ෩ʹ΋ͳΕΔ w/FYU4UFQ͸ྲྀߦΓ͚ͩͰͳ͘ɺνʔϜϚονϯά΋ ߟ͑ͨબ୒Λ͠Α͏

  37. ܅΋ϖύϘͰಇ͔ͳ͍͔ʁ ࠷৽ͷ࠾༻৘ใΛνΣοΫˠ !QC@SFDSVJU