gRPC Server with golang

gRPC Server with golang

golang.tokyo # 24 の資料です。
https://golangtokyo.connpass.com/event/129067/

E63ab48ccdf309256f858dd2424d8b03?s=128

abemotion

May 20, 2019
Tweet

Transcript

  1. HPMBOHUPLZP H31$4FSWFSXJUIHPMBOH HPMBOHUPLZP !BCFNPUJPO

  2. HPMBOHUPLZP ࣗݾ঺հ !BCFNPUJPO DPDPOBMB 4FSWFS4JEF&OHJOFFS ։ൃج൫νʔϜ (P3BJMT$BLF1)1 5XJUUFSBCFNPUJPO ςχεొࢁ

  3. HPMBOHUPLZP εΩϧͷϑϦʔϚʔέοτ ݸਓͷ஌ࣝɾεΩϧɾܦݧΛؾܰʹചങ ొ࿥ձһ਺ສਓ ίίφϥ๏཯૬ஊ ίίφϥϋϯυϝΠυ

  4. HPMBOHUPLZP ৽ϓϩϑΟʔϧϖʔδ ˠɹϚΠΫϩαʔϏεߏ੒Ͱ։ൃ ɹɹHPMBOHΞοϓσʔτ ɹɹɹɹɹʢEFQˠ(P.PEVMFTʣ

  5. HPMBOHUPLZP ηογϣϯ಺༰ ϚΠΫϩαʔϏεߏ੒ͷ"1*(BUFXBZΛ H31$4FSWFS$MJFOUͱͯ͠ߏஙͨ͠ܦݧΛݩʹ࿩͠·͢ H31$ͷ֓ཁʙߟྀͨ͠τϐοΫΛղઆ

  6. HPMBOHUPLZP γεςϜߏ੒ "1*(BUFXBZ HPMBOH ɾ1SPpMF4FSWJDF 3BJMT ͷ ઃܭʙ։ൃ·Ͱ୲౰ /VYU&YQSFTT HPMBOH

    3BJMT H31$ H31$ "1*(BUFXBZ 1SPpMF4FSWJDF 1SPpMF8FC
  7. HPMBOHUPLZP ΞδΣϯμ H31$֓ཁ H31$4FSWFS$MJFOU H31$Τϥʔॲཧ HPHSQDNJEEMFXBSF

  8. HPMBOHUPLZP H31$֓ཁ

  9. HPMBOHUPLZP H31$֓ཁ (PPHMF͕։ൃͨ͠31$'SBNFXPSL )551Ͱ௨৴ 1SPUPDPM#VGGFSTͰΠϯλʔϑΣʔεఆٛ ༷ʑͳݴޠʹରԠ $ ɺ+BWBɺ1ZUIPOɺ(Pɺ3VCZɺ$ ๛෋ͳࣄྫ (PPHMFɺ/&5'-*9ɺ$*4$0

    ࠃ಺اۀͷ࠾༻΋૿͖͍͑ͯͯΔ
  10. HPMBOHUPLZP H31$ϝϦοτ QSPUPϑΝΠϧͰΠϯλʔϑΣΠε࢓༷ΛҰݩ؅ཧ QSPUPϑΝΠϧ͕"1*࢓༷ॻ୅ΘΓʹ αʔόଆͱҟͳΔ։ൃݴޠ༻ͷΫϥΠΞϯτίʔυ΋ࣗಈੜ੒ ෳ਺ݴޠʹରԠ͓ͯ͠ΓɺϚΠΫϩαʔϏε޲͖ ίʔυͷࣗಈੜ੒Ͱɺຊདྷ࣌ؒΛ͔͚Δ΂͖ػೳ࣮૷ʹूத ύϑΥʔϚϯεߴ଎

  11. HPMBOHUPLZP H31$։ൃͷྲྀΕ QSPUPϑΝΠϧఆٛ ιʔείʔυͷࣗಈੜ੒ αʔόͷ࣮૷ ΫϥΠΞϯτͷ࣮૷

  12. HPMBOHUPLZP QSPUPDίϚϯυ QSPUPϑΝΠϧ͔Βɺ֤ݴޠ༻ͷΫϥεɾؔ਺΁ม׵ͨ͠ ϑΝΠϧΛࣗಈੜ੒ͯ͘͠ΕΔ$PNQJMFS IUUQTHJUIVCDPNQSPUPDPMCVGGFSTQSPUPCVG QSPUPDQSPUP@QBUI*.1035@1"5)HP@PVU%45@%*3 QBUIUPpMFQSPUP .BLFpMFʹఆٛ͠ɺίϚϯυԽ QSPUPϑΝΠϧ͸ϦϙδτϦ؅ཧ͠HJUTVCNPEVMF

  13. HPMBOHUPLZP H31$4FSWFS$MJFOU

  14. HPMBOHUPLZP γεςϜߏ੒ /VYU&YQSFTT HPMBOH 3BJMT H31$ H31$ "1*(BUFXBZ 1SPpMF4FSWJDF 1SPpMF8FC

    H31$$MJFOU H31$4FSWFS
  15. HPMBOHUPLZP QSPUPఆٛ TZOUBY 1SPUPDPM#VGGFSTόʔδϣϯࢦఆ QBDLBHF ໊લিಥΛආ͚ΔͨΊʹ࢖༻ ֤αʔϏεͰ͸ϦϙδτϦ͝ͱʹ੾͍ͬͯ·͢ PQUJPO ֤ݴޠͰQBDLBHF͕ͲͷΑ͏ʹղऍ͞ΕΔ͔

  16. HPMBOHUPLZP γεςϜߏ੒ /VYU&YQSFTT HPMBOH 3BJMT H31$ H31$ "1*(BUFXBZ 1SPpMF4FSWJDF 1SPpMF8FC

    H31$4FSWFS H31$$MJFOU
  17. HPMBOHUPLZP QSPUPఆٛ TFSWJDF 31$Λఆٛɻ Ϧιʔε୯ҐͰϑΝΠϧ໊ͱରԠؔ܎ NFTTBHF ϦΫΤετϨεϙϯεͷσʔλߏ଄ఆٛ ֤ϑΟʔϧυ͸໊લɾܕɾ਺஋λάΛ࣋ͭ JOUJOUɺTUSJOHɺCPPMɺSFQFBUFE JNQPSU

    ଞύοέʔδϑΝΠϧͷσʔλߏ଄Λ࢖༻
  18. HPMBOHUPLZP "1*(BUFXBZ ϑϨʔϜϫʔΫΛ༻͍ͣʹ։ൃ ·ͩσϑΝΫτελϯμʔυͳ͘ɺෛ࠴Խճආ ඪ४ύοέʔδ֎෦ϥΠϒϥϦ ύοέʔδߏ੒ ϨΠϠΞʔΩςΫνϟ-JHIUXFJHIU%%% JOUFSGBDFɿϦΫΤετϋϯυϥ BQQMJDBUJPO͍ΘΏΔϏδωεϩδοΫ EPNBJO͍ΘΏΔϞσϧɻߏ଄ମఆٛͳͲ

    JOGSBTUSVDUVSFσʔλΞΫηεͷ࣮૷ ͦ΋ͦ΋૬ޓࢀর͢ΔͱΤϥʔ
  19. HPMBOHUPLZP H31$4FSWFSىಈ

  20. HPMBOHUPLZP JOUFSGBDFT૚

  21. HPMBOHUPLZP BQQMJDBUJPO૚

  22. HPMBOHUPLZP H31$Τϥʔॲཧ

  23. HPMBOHUPLZP H31$Τϥʔॲཧ ಠࣗͷΤϥʔίʔυ͕༻ҙ͞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·͔͞ͷࣗ෼Ͱ੔ܗʜ  Ұํ[BQ 6CFS੡ ߴ଎ɻͪΐͬͺ΍ɻ

    ΤϥʔϨϕϧ͋Γ ग़ྗܗࣜͷબ୒Մ ࢖͍ํɾه๏͕ಛघ
  32. HPMBOHUPLZP H31$4FSWFS$MJFOU-PHHJOH

  33. HPMBOHUPLZP H31$4FSWFS$MJFOU-PHHJOH ্هϝιου΋͋Δ͕ɺ 1BZMPBE͕ͦͷ··ϩάʹग़ྗ͞ΕΔͷ͸ΑΖ͘͠ͳ͍ɻ ϦΫΤετ஋ͷϩΪϯά͸֤ϝιου಺Ͱݸผग़ྗ

  34. HPMBOHUPLZP 3FUSZ

  35. HPMBOHUPLZP HJUIVCDPNHSQDFDPTZTUFNHPHSQDNJEEMFXBSFSFUSZ 

  36. HPMBOHUPLZP HJUIVCDPNHSQDFDPTZTUFNHPHSQDNJEEMFXBSFSFUSZ $BMM0QUJPOʹ༷ʑͳΦϓγϣϯͷઃఆ͕Մೳ 8JUI#BDLPGG 3FUSZͷִؒ࣌ؒ 8JUI$PEFT 3FUSZ͢ΔΤϥʔίʔυ σϑΥϧτ͸ɺ%FBEMJOF&YDFFEFE$BODFMFE 8JUI.BY ࠷େ3FUSZճ਺

  37. HPMBOHUPLZP H31$Ͱࠔͬͨ͜ͱ /6--ڐ༰Ͱ͸ͳ͍ H31$ࣗମ͕/6--Λ૝ఆ͍ͯ͠ͳ͍ /6--ͷଘࡏ͠ͳ͍ੈքʂ /6--͸͍ΘΏΔσϑΥϧτ஋ѻ͍ ɺۭจࣈɺGBMTF  ˠ࣮૷্͸ͦ͜·ͰࠔΒͳ͔͕ͬͨɺࣾ಺ͷཧղΛಘΔ·Ͱʹ͕͔͔࣌ؒͬͨ ࣌ࠁܕ

    H31$ʹ͸࣌ࠁܕ͕༻ҙ͞Ε͍ͯΔ DPNHPPHMFQSPUPCVG5JNFTUBNQ  ੜ੒ม׵͕େม ϝιουͭ΋ͭ΋࿈݁ͯ͠ɺɺʣ ͪΌΜͱௐ΂ͯΈͨΒɺத਎͸JOUͩͱ͍͏͜ͱ͕൑໌ ଞࣾ͞Μͷࣄྫ΋ฉ͍ͯ݁ہJOUʹ Τϥʔίʔυʹ׳Ε͕ඞཁ ʮ͕ฦ͖ͬͯͨʂʯʮͩͬͯʂʯˡͳΜͱͳ͘Θ͔Δ ʮΤϥʔ൪ͳΜ͚ͩͲʁʯˡΘ͔Βͳ͍
  38. HPMBOHUPLZP ·ͱΊ ੩తܕ෇͚HPMBOHʷεΧϥʔܕH31$ ࣄલʹίϯύΠϧՄͩ͠ݎ࿚ʂ૬ੑ࠷ߴʂ 8FC্ͷهࣄͰݟͨ ʮϦϦʔε͔ͯ͠Β΄ͱΜͲόάͳ͍ʯ ˠϗϯτͩͬͨ ࣮૷ʹ΋ΑΔͱࢥ͍·͕͢  (P%PDͷϝιουઆ໌͸ɺӳจߦͷΈͱ͔βϥ

    ݁ہιʔεΛಡΉ͜ͱʹͳΔ ͜Ε͕͔ͳΓֶͼʹͳͬͨ HPMBOH޷͖ʂָ͍͠ʂ͡Όͳ͖Ό೉͍͠ த਎·ͰݟͯڍಈΛ஌ͬͯΔͱ҆৺ײ͕ҧ͏