ååã«åºãã®ã2020å¹´ã§ãåãçã¾ãã¦ããã¯åå ãã¦ããªãã£ãã®ã ãã©ã声ãããã¦ããã£ã¦ãid:tkzwtks, id:akiymã¨åºãã
ãã®2人ã¨ã¯2017å¹´ã«ãä¸ç·ã«åºå ´ãã¦ããã®ã¨ãã¯æãããã¼ã«ã飲ã¿ãæ¨æãã¦ããã
æºå
æºåã¯ã»ã¼ãªã«ããã¦ãªãã¦ããããªããã°â¦ã¨ãä½åº¦ããã£ããã«æ¸ãè¾¼ãã ãããã ã£ãã
èªåã®ããã°ãè¦è¿ãã¦ããããããªã®ãã£ã¦ããªãã¨ãçºãã¦ãããè¦è¿ãã¨ãæ
ã¦ãªããã¨ããç²¾ç¥é¢ã®TRYãå¤ãã
å人ã®ã¹ãã«ã¨ãã¦ã¯ãæè¡çã«ã¯4å¹´åããä½ãé²æ©ãã¦ããªããã©ãæ®æ®µã®ä»äºãå¿ãããããããè½ã¡çãã¦è¡åãããã¿ãããªã¹ãã«ã¯ä¸ãã£ã¦ãã¦ããã¨æãã
æ風å
é湯ã®æ風åã«è¡ã£ã¦ãé´¨å·ãçºãã¦ãããªãã£ã¹ã«åãã£ãã
é´¨å·ã®ãããããããã¨ã¦ã¤ããªãã¦ããã®æ°æã¡ãããåæ³ãªã®ãï¼è¦å¶ããã»ããããã®ã§ã¯ãã¨ä¸å®ã«ãªãã
è¨èª
æ®ãã®äºäººã¯Goãå¾æã ãã©ãåãGoã¯æ¨æ¶ç¨åº¦ã«ããèªã¿æ¸ãã§ããªããã¨ãããã¨ããNode.jsãé¸ãã ãããããã¨ããã§ç¡çãã¦ä½¿ã£ã¦ãããªãã¨ç¿å¾ã§ããªãã®ã ãªâ¦ã¨æãã
TypeScriptã§åãã¤ãã¦ãã®ã¯ä¾¿å©ã ãã©ãSQLå
ã®ã«ã©ã åã¨ããã¼ãã«åã¨ããæ¥ãã§ã¿ã¤ãã³ã°ãã¦ãã©ãã©ãééããã®ã§ãå®è¡æã¨ã©ã¼ã¯ããåºã¦ããã
Promiseãä½ã£ã¦awaitããã»ã£ããããã«ãããã¨ã§éã«éåæå¦çãæ¸ããã®ã好ããªã®ã ãã©ãä»åã¯ãã¾ã使ããªãã£ãã
決æ¸ã·ã¹ãã ãå¼ã³åºããããã¯ã¬ã¹ãã³ã¹ãå¾
ãããè£ã§ãªã¯ã¨ã¹ãæãã£ã±ãªãã«å¤ãã¦ã¿ãããfailãã¦ãã¾ã£ãã
ããã¥ã¡ã³ããèªã
以åãæ¬æ¦ã«åºãã¨ãã«ãAPIã®ä»æ§æ¸ã«ãã³ããé ããã¦ããã®ãè¦éãã¦ããã®ãè¨æ¶ã«æ®ã£ã¦ãã¦ããããããããã¥ã¡ã³ããæåã«èªã人éã«ãªã£ãã
å®è£
ãéã«åããªãããã¯ãç¥ããªãç¥èãããã¾ã¾çµããã»ãããã¤ãã¹ã大ããã¨æãã
ãªã¼ã¸ã§ã³ã2åãããã¨ããServer Sent Eventsã«å¯¾å¿å¯è½ãã¨ãã決æ¸ãµã¼ãã¼ã¯åªçæ§ã®ããã«ããã®ããããåçã§ãã¾ããã¨ãããã³ããæ¸ããã¦ãããåªçæ§ãæ
ä¿ããããã®ãããã¯åãã¦è¦ãã
ãããã大ä¼ã«åºã¦ä¸ã¤æã¡å¸°ããç¥èãå¢ããã®ã¯å¬ããã
docs.stripe.com
ã³ã¼ããçºãã
è¡åãææªãªã®ã ãã©ãVSCodeã®Remote SSHã§ãµã¼ãã¼ã«å
¥ã£ã¦ããã®ã¾ã¾ã¤ãªãã£ã±ãªãã«ãã¦ãããgit pullããªãã¦ãããããã¤ãããã³ã¼ãããã®ã¾ã¾èªããã®ã§ãåæ ãæ©ãã
ã³ã¼ããæ¤ç´¢ããããVSCodeå
ã®ã¿ã¼ããã«ã§ãã°ãçºãããã便å©ã«ä½¿ã£ã¦ããããã¹ã£ã¦ãµã¼ãã¼å
ã®ãã¡ã¤ã«ãæ¸ãæãã¦ãã¾ããã¨ããã°ãã°ãã£ãã
SQLãç´æ¥æ¸ããã¦ããã®ã§ãUPDATEãã¨ããSELECTãã¨ãã§æ¢ãã¦ãã¤ã£ãã¿ã©ãããã¡ã¢ãã¦ãããã
ããã®ããæ¹ã¯ãã£ã¨ããã®ãããã¯ããã¨ããã³ã¡ã³ãã«ã¤ã£ãã¿ã©ãããæ¸ããã¦ãã¦å©ãã£ãã
ãã¼ãã¼ãã«è§¦ããªã
2人ã«ç»é¢ã«ã¤ãªãã§å®è£
ãã¦ããã£ã¦ãåã¯æ¨ªãããããã¹ãããããããã¥ã¡ã³ãã«ããã¨ããã¯ããããããã¨ã解説ããããã³ã¼ããçºãã¦ãå¤ãªå ´æãæ¢ããããã¨ããä½å¶ã§ãã»ã¼ä¸æ¥éãããã
- ãã¼ã¿ã®éæ£è¦å
- chairsã«latitude, longitudeããããã
- chairsã«can_assignã«ã©ã ã足ãã¦ãäºç´å¯è½ãªãtrueã¨ãããããããã«ãã
- ãããã³ã°ã®èª¿æ´
- ä¸åº¦ã«å
¨ridesãéãã¦é ã«ãããã³ã°ãããããã«
- 座æ¨ãè¦ãã¨ã0ä»è¿ã¨300ä»è¿ã«ã¯ã©ã¹ã¿ãã§ãã¦ããã®ã§ãé
è»è·é¢ã§è¶³åããã¦ãè¿ãã®æ¤
åãå²ãå½ã¦ãããã«
- è·é¢/ã¹ãã¼ãã§æè¦æéãè¨ç®ãã¦æå°åããããã«
- ãªãããã¾ãé«è©ä¾¡ã«ã¯ã¤ãªããããè¬ã ã£ã
- ãµã¼ãã¼3å°ã«
- DBãã¢ããªx2ãã¨ãã3å°
- ãããã³ã°é »åº¦ãä¸ãã¦ãè¯ãæ¡ä»¶ã®æ¤
åãä½ãã®ãå¾
ã¤ããã«
- é »åº¦ãä¸ããã¨ãããã¼ã ããã¦ããããã
å¤æ¹ãããã«ãªã£ã¦ãServer Sent Eventãã£ã¦ãããªãã¨ãæã¡ä¸ãã§è©±ã«ã¤ãã¦ãããªããããã£ã¨ãããã¨è¨ã£ã¦ãå®è£
ãå§ãããã®ã®ããã¾ãåããæ念ããã
honoã«streamSSEã¨ããã¤ã³ã¿ã¼ãã§ã¤ã¹ããã£ã¦ãå®è£
ãããããªããåãã¦ããããã«ã¯è¦ããã®ã ãã©ããããã³ã°ãåããªããªã£ãã
ã¿ãããããã³ãã¯ã·ã§ã³ãåãããã¨ããµã¼ãã¼ãµã¤ãã®å¦çãç¶è¡ãã¦ããããã«è¦ãã¦ãSQLãæµãç¶ãã¦ããã使ã£ããã¨ãªãæè¡ãããããæ©ä¼ã«ãããªã使ãã®ã¯ä¸å¯è½ã¨ãããã¨ããããã
ããæéããªããããããããããã¨è¨ã£ã¦ããªãã¸ã§ã³ã1æéåãããæ»ãã¦çµäºã
ãªã®ã§ãä»ååã®ã³ã¼ãã¯1è¡ãå
¥ã£ã¦ãªãã
ãããã³ã°ã¯ããã¡ãã£ã¨ããã§ããããããªããã¨æã£ã¦ãæ¤
åãã¡ã®è¡ãå
ãå°çäºå®æå»ã¯è¨ç®ã§ããã®ã§ãçµããã®ãå¾
ã£ã¦ãããã¦ãããã¨ãã£ãäºç´ã¢ã«ã´ãªãºã ã¯ã©ãï¼ã¨ããäºç´ãã§ãã¦ããä¸å®æéã¯è¯ãæ¡ä»¶ãæ¢ããã©ãã¿ã¤ãããªããã°æã¡åã£ã¦ãããã³ã°ãããã®ã¯ã©ãï¼ã¨ã話ãã¦ãã®ã ãã©ãå®è£
ãéã«åããªãã£ãã
ããããèæ
®ãããããã£ã¨ãããªãã®ã§ã¯ãã¨èããã®ã¯æ¥½ããã£ãã
ã»ã«ã¤ç³»
é湯ã«è¡ã£ãå¹æããã£ã¦ãããã¤ã«ãªãè½ã¡çãã¦é²ããããã
æåã®æ¹ã«ãã¨ãã«ãªã¼ãã¼ãã¼ããè¦ã¦ãªãã£ãã®ã ãã©ããããã ãã ãããããããªã£ã¦ãã¦ããã®ã¾ã¾è¦ãªãã¾ã¾çµããããã¨æ±ºããã
ãã®çµæãã¾ã£ããç¦ããã¨ãªãããã¡ã¯ãã¡ãããã¯ãããã¨ããã»ã«ã¤ç³»ãªæ°åã«ãªããã
ããã¾ãç¹æ°ãæ°ã«ãããè½ã¡çãã¦è¡åããçµæã26ä½ã«å
¥ããã®ã§ãæå¤ãªçµæã ã£ãã30ä½ä»¥å
ã¯æ¬æ¦åºå ´ç¸å½ã®ã¹ã³ã¢ã¨ãããã¨ã ããNode.jsã§åºããã¼ã ã®ä¸ã§ã¯ä¸ä½ã®ã¹ã³ã¢ã ã£ãã
ä»åã¯ããã ã¨ã³ããã¤ã³ããéãããã°ãããã¨ãããã®ã§ããªãããã¸ãã¹ãã¸ãã¯ãç解ãã¦æ¹åãããã¨ããåé¡ã§ããããããããããããã¨æ¥½ãããã
ã·ãã¥ã¬ã¼ã¿ãããã§ãã¦ããããåºé¡ã®åç»ãã¯ãªãªãã£ãé«ãããã®ãããå´åãããã£ã¦ããâ¦ã¨ãã®ã®ãã¦ããã
åºé¡è
ãã¹ã¿ãããã¹ãã³ãµã¼ãåå è
ã®ã¿ãªãã¾ã楽ãã大ä¼ãç¨æãã¦ãã ããããããã¨ããããã¾ããã
ä¹
ãã¶ãã«åºããã©ãçãåãåé¡ã解ãã¦ãã¨ãä»å¾ä¸å¹´éã¯ä¸é話ã®ãã¿ã«ãªãããåå ãã¦ããã£ãã¨æãã