2019-05-01ãã1ã¶æéã®è¨äºä¸è¦§
SQLã¢ã³ããã¿ã¼ã³ã¨ããæ¬ãããã¾ãã ãã®æ¬ã®1ç« ãã¸ã§ã¤ã¦ã©ã¼ã¯ï¼ä¿¡å·ç¡è¦ï¼ãã¸ã§ã¤ã¦ã©ã¼ã¯ã§ç´¹ä»ããã¦ãããããªãã¼ã¿ãtsvãã¡ã¤ã«ã¨ãã¦æå ã«ããå ´åã«ãSQLã§ã¯ãªãã·ã§ã«ã§ãªãã¨ãããã話ã§ãã ã¸ã§ã¤ã¦ã©ã¼ã¯ tsvãã¡ã¤ã« SQL vs ã·ã§â¦
ååãå¥goroutineã§çºçããã¨ã©ã¼ãã³ããªã³ã°ããã¾ãããå ·ä½çã«ã¯ãµãã¹ã¯ã©ã¤ãã¸ã®æ¸ãè¾¼ã¿ã§ã¨ã©ã¼ãçºçããå ´åã«ãµãã¹ã¯ãªãã·ã§ã³ã®åé¤å¦çããããã«ãã¾ãããä»åã¯ã context.Context ã使ã£ã¦goroutineãåæ¢ãããã¨ã§ãã¯ã©ã¤ã¢ã³ããâ¦
ååã®ç¶ããå¥ã®goroutineã§çºçããã¨ã©ã¼ãerror channelã使ã£ã¦ãã³ããªã³ã°ãã¦ã¿ããã¨æãã¾ãããã³ããªã³ã°ã®å¦çã§mapã使ã£ãã®ã§ãããgoroutineã»ã¼ãã«ãããã sync.Map ã使ã£ã¦ã¿ã¾ããã ç®æ¬¡ã handleSub ã§ã¨ã©ã¼ å¥goroutineãåãåâ¦
ååãgoroutine, channel, selectã使ã£ã¦ Broker ãå®è£ ãã¾ããããã® Broker ããµã¼ãã¼ã§å©ç¨ããMQTTã§ã¡ãã»ã¼ã¸ãé éãã¦ã¿ã¾ãã ãã®åã« <-chan chan<- []byte ã¨ããåãèªã¿ã¥ããã®ã§ type ã使ã£ã¦å¯¾å¿ãã¾ãããã®å¾ãèªã¿æ¸ãå¯è½ãªchanneâ¦
ååã¯goroutineã使ã£ã¦ãè¤æ°ã¯ã©ã¤ã¢ã³ãã¨åæã«æ¥ç¶ã§ããããã«ãã¾ãããä»åã¯ãè¤æ°ã®goroutineéãchannelãã¤ãªãã§ã¡ãã»ã¼ã¸ããã¨ãããPublishãããã¡ãã»ã¼ã¸ãå¥ã®Subscribeãã¦ããã¯ã©ã¤ã¢ã³ãã«é éãã¾ããchannelã®ææ権ãselectãâ¦