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

ポイントで導入するRust

 ポイントで導入するRust

Running Rust in Production( https://d-cube.connpass.com/event/90317/ )発表資料です

D400e6d92f9a69b60d9cfdff1dc9a98e?s=128

Kazushige Tominaga

July 03, 2018
Tweet

Transcript

  1. ϙΠϯτͰಋೖ͢Δ3VTU

  2. 2 ࣗ ݾ ঺ հ Fablic, inc. —> Rakuten, inc.

    Software Engineer 5PNNZ @tooooooooomy
  3. 3 ໨ ࣍ • RustΛ࢖͓͏ͱࢥͬͨཧ༝ • RustΛ࢖͏४උ • Rustಋೖͷ͖͔͚ͬ •

    ӡ༻ͱͦͷޙ • ͓·͚
  4. 3VTUΛ࢖͓͏ͱࢥͬͨཧ༝

  5. 5 ɾຖ೥ҰͭͷݴޠΛֶश

  6. 6

  7. 7 ·ͱ΋ʹ࢖ͬͨ͜ͱͷ͋Δݴޠ(౰࣌) • PHP • JavaScript • Perl • Ocaml(ϓϩάϥϛϯάͷجૅݺΜͩఔ౓)

    • C(େֶͱ͔K&RͰͪΐΖͬͱ)
  8. 8 ࢖ͬͨ͜ͱͷ͋Δݴޠ • PHP • JavaScript • Perl • C(େֶͳͲͰͪΐΖͬͱ)

    ৽͍͜͠ͱ͕͍ͨ͠ʂ
  9. 9

  10. 10 (PͳΒ͜ͷઌ࢓ࣄͰ࢖͏͜ͱ΋͋Γͦ͏ͩͳʜ

  11. 11 (PͳΒ͜ͷઌ࢓ࣄͰ࢖͏͜ͱ΋͋Γͦ͏ͩͳʜ ϗϯτ͔ʁ

  12. 12 ࣌୅͸ɹɹɹ΄͛

  13. 3VTUΛ࢖͏४උ

  14. 14 ४උʁ

  15. 15 https://doc.rust-lang.org/book/second-edition/index.html

  16. 16 ϑϜϑϜͳΔ΄ͲʜҎ্ͷײ૝͕ग़ͳ͍

  17. 17 ಈ͘΋ͷ͕࡞Γ͍ͨ

  18. 18 https://kazu9su.com/football-matome • Α͋͘Δ2ch·ͱΊ • αʔόʔαΠυ: Rust • ΫϥΠΞϯτ: React

    + Redux
  19. 19 RustͰ΍͍ͬͯΔ͜ͱ • xmlΛऔ͖ͬͯͯDBʹอଘ • JSONΛग़ྗɹ

  20. 20 RustͰ΍͍ͬͯΔ͜ͱ • xmlΛऔ͖ͬͯͯDBʹอଘ • JSONΛग़ྗɹ ීஈ΍͍ͬͯΔͷͰΠϝʔδͰ͖Δ

  21. 21 https://github.com/kazu9su/football-matome • Libraries • Web framework • nickel •

    ORM and Query Builder • diesel • Http client(and server) • hyper • Mocking • mockito
  22. 22 https://github.com/kazu9su/football-matome • Libraries • Web framework • nickel •

    ORM and Query Builder • diesel • Http client(and server) • hyper • Mocking • mockito ࣮૷Λҙࣝ͢Ε͹͍͍͚ͩͷ ϥΠϒϥϦ͸͢Ͱʹ༻ҙ͞Ε͍ͯΔ
  23. 23 ศར

  24. 3VTUಋೖͷ͖͔͚ͬ

  25. 25 • ϥΫϚ։ൃνʔϜͰ͸ɺࣗಈԽΛଅਐ͍ͯ͠·͢ • ๻͕Joinͨ͠౰࣌(1೥લ)͸νʔϜͷਓ਺͕େ͖͘มΘΓ ࢝Ί͓ͯΓɺࣗಈԽͷػӡ͕ߴ͘ͳ͖͍ͬͯͯͨ

  26. 26 • ࣾ಺ΞϓϦڞ௨ͷϥΠϒϥϦͱͯ͠࢖͍ͬͯΔ΋ͷͷσϓϩΠϑϩʔ

  27. 27 • ࣾ಺ΞϓϦڞ௨ͷϥΠϒϥϦͱͯ͠࢖͍ͬͯΔ΋ͷͷσϓϩΠϑϩʔ

  28. 28 • ࣾ಺ΞϓϦڞ௨ͷϥΠϒϥϦͱͯ͠࢖͍ͬͯΔ΋ͷͷσϓϩΠϑϩʔ 1SPCMFN

  29. 29 • λά࡞੒εΫϦϓτʹRubyΛ࢖༻͍ͯͨͨ͠ΊɺHeroku্Ͱ౎౓ bundle install͍ͯͨ͠ • ຖճ2෼͘Β͍͔͔͍ͬͯͨ

  30. 30 • λά࡞੒εΫϦϓτʹRubyΛ࢖༻͍ͯͨͨ͠ΊɺHeroku্Ͱ౎౓ bundle install͍ͯͨ͠ • ຖճ2෼͘Β͍͔͔͍ͬͯͨ ࣗಈԽͷҙຯͶ͑

  31. 31 • ͦΜͳં

  32. 32 • ͦΜͳં

  33. 33 3VTUͷػӡ

  34. ӡ༻ͱͦͷޙ

  35. 35 ಋೖޙ

  36. 36 ແࣄ౰ॳͷ໰୊΋ղܾ͞Εͨ

  37. 37 ͔͠͠…

  38. 38 3VTUΛॻ͚Δਓ͕๻͔͍͠ͳ͍ͱ͍͏͜ͱ͕໰୊ʹʜ

  39. 39

  40. 40 ͳΒͳ͔ͬͨ

  41. 41

  42. 42 ͜Εʹؔͯ͠͸νʔϜϝϯόʔͷ͓͔͛ͳͷͰײँ͔͠ͳ͍Ͱ͢

  43. 43 ਅͷ໰୊͸ΫϩείϯύΠϧ

  44. 44 ͦΕҎ߱मਖ਼ͱ͔ͳͯ͘·ͩղܾͯ͠ͳ͍Ͱ͢ɻ νʔϜͱͯ͠ӡ༻͍ͯ͘͜͠ͱΛߟ͑ΔͱϚετͳͷͰɺ൓লʜ

  45. 45 ·ͱΊ • ࣗ෼͕खΛಈ͔ͯ͠Πϝʔδ͕Ͱ͖Δ΋ͷͰ࿅श͢Δͱศར • ๻ͷ৔߹͸؆ૉͳWebαʔϏε • ৽͍͠؀ڥͷ৔߹ɺ৽͍͜͠ͱΛ͢Δνϟϯε • ࣗಈԽͳͲɺࣄۀυϝΠϯʹ͋·Γؔ܎ͷͳ͍ͱ͜ΖΛ΍Βͤͯ΋Β͑Δνϟϯε͕ଟ͍

    • Rust࢖͑Δ͜ͱΛΞϐʔϧ͍ͯͨ͠ͷͰϝϯόʔ͔Β΋ੵۃతʹಋೖΛࢧԉͯ͠΋Βͬͨ • ෆ۩߹͕ى͖ͨΒࣗ෼ʹ೚ͤΖελΠϧͰ΍ͬͯ͠·͏ͷ͸݁ߏ͋Γͩͱࢥ͏ • ͦͷޙͷέΞΛ΍Δͷͱηοτ • νʔϜͷջͷਂ͞ͱ৽͍ٕ͠ज़ͷಋೖʹର͢Δཧղ౓ • ๻ʹίϯτϩʔϧͰ͖Δͱ͜ΖͰ͸ͳ͍ͷͰɺվΊͯνʔϜϝϯόʔʹײँ
  46. ͓·͚

  47. 3VTU5FTUUJQT

  48. 48 σϑΥϧτͰϚϧνεϨου࣮ߦ͞ΕΔ • DBͳͲΛ࢖ͬͨςετͱ͸૬ੑѱ͍ • ࣮࣭తʹWebαʔϏεͰ࢖͏৔߹͸ $cargo test -- —test-threads=1

    ͕σϑΥʹͳΔ͔΋
  49. 49 Private methodͷςετ͸ಉϑΝΠϧ಺ʹॻ͘ • ༰қʹςετͰϑΝΠϧߦ਺͕૿Ճ͍ͯ͘͠ͷͰݸਓతʹ͸෼͚ͯॻ͖͔ͨͬͨ • Privateͳϝιουʹ͸ͦͷϑΝΠϧ͔Β͔͠ΞΫηεͰ͖ͳ͍ͱ͍͏ͷ͸ɺݴΘΕͯΈ Ε͹Ұͭͷ౴͑ͳؾ΋ͨ͠ • ͋ͱ͸ͦΕͰߦ਺͕૿͑ͯݟ௨͕͠ѱ͘ͳͬͨΒઃܭΛݟ௚ͤͱ͍͏͜ͱ͔ͳͱਪଌ

  50. 50 Mocking Library Mockitoͷ࢓༷ • Javaͷಉ໊ϥΠϒϥϦͷΠϯεύΠΞʁ(ਅِෆ໌) • ࢓༷ॻಡΊ͹ॻ͍ͯ·͕͢ɺϩʔΧϧϚγϯ্ͰHTTPαʔόΛ্ཱͪ͛Δͱ͍͏΋ͷ • ίʔυ಺Ͱࢦఆͯ͠ΔURLͰΞΫηε͢ΔઌΛMockitoͰ্ཱͪ͛ͨαʔόʔʹ޲͚ΔΠϝʔδ

    • ීஈPHPͱ͔RubyͰΠϝʔδͯ͠Δ΋ͷͱ͸ҧ͏ͷͰݴٴͯ͠Έͨ
  51. ͞Βʹ͓·͚

  52. 52 ஔ͖׵͑ݩ(Ruby)ͱஔ͖׵͑ઌ(Rust)ͷൺֱ https://speakerdeck.com/kazu9su/wen-zi-lie-cao-zuo-nijian-rurubytorustfalsebi-jiao-wen-zi- lie-cao-zuo-nijian-rurubytorustfalsebi-jiao

  53. 53 3BLVUFOͰ͸<ΤϯδχΞ>Λੵۃ࠾༻தʂ

  54. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠