libchan ãèªãã ã®ã§ã¾ã¨ãã¦ã¿ãã
libchanã¨ã¯
libchanã¯dockerã«ä½¿ããã¦ããã©ã¤ãã©ãªã®1ã¤ã§ãå æã® DockerCon ã§çºè¡¨ãããã éåæãã¤ä¸æ¹åã®éä¿¡ãã£ãã«ãã¤ã³ããã»ã¹ã§ããããã¯ã¼ã¯è¶ãã§ãæ±ããã¨ããGoã©ã¤ãã©ãªã§ããã ä¸æ¹åã¨ã¯ãããã®ã®ããã£ãã«èªä½ããã¼ã¿ã«æ·»ãã¦ä»ã®ãã£ãã«è¶ãã«éããããªã®ã§ãè¿ä¿¡ãå¾ ã¡åãããå¿ è¦ãªãã°èªåå®ã®ãã£ãã«ãéã£ã¦ç¸æã«ä½¿ã£ã¦ããããèªåã¯ãã®ãã£ãã«ã®ä¸ã§å¾ æ©ãã¦ããã°è¯ãã
æ©ã話ãGoè¨èªã®æ©è½ã§ãããã£ãã«ããããã¯ã¼ã¯å¯¾å¿ãããããªãã®ã ãã¨æ¸ãã¦ããã
Dockerã¯ãã®DockerConã§ã¯Docker 1.0ã«å ãã¦libcontainer, libchan, libswarm, Docker Hubãçºè¡¨ãã¦ãã¦ä¸å¿ãã¼ãã¼ãã®è©±é¡ã®ï¼ã¤ã§ã¯ãã£ããã®ã®ã å人çã«ã¯libswarmãKubernetesã«æ¯ã¹ãã¨ã¤ã³ãã¯ãã¯å°ãããªã¨ããææ³ã§ãã£ãã
å®è£
ä½ããã®ãã©ã³ã¹ãã¼ãæ©æ§ã®ä¸ã«ã·ãªã¢ã©ã¤ãºãããã¡ãã»ã¼ã¸ãéãä»çµã¿ã§ãå²ã¨ã·ã³ãã«ãªé ãã§ããã
ãã©ã³ã¹ãã¼ãã¨ãã¦ã¯ä¸è¨ããµãã¼ãããã¨ããã¥ã¡ã³ãã«æ¸ãã¦ããã
ãã ããç¾å¨å®è£ ããã¦ããã®ã¯ä¸è¨ã®ã¿ã«è¦ããã
- In-memory Go channel
- Unix socket
- SPDY
ã¾ã"In-memory Go channel"ã¨ã¯ãããã®ã®ãå®éã«ã¯mutexã¨å¤æ°å ±æã§å®è£ ããã¦ãã¦chanã¯ä½¿ã£ã¦ããªãã
éä¿¡å¯è½ãªã¡ãã»ã¼ã¸ã®å®ç¾©ã¯æ¬¡ã®ããã«ãªã£ã¦ããã
type Message struct { Data []byte Fd *os.File Ret Sender }
Data
ã¯ä»»æã®ãã¤ãã¼ãã Ret
ã¯è¿ä¿¡ç¨ã«ç¸æã«éããã£ãã«ã§ããã
Ret
ã«ã¯ç¹å¥ãªå¤ã§ãã libchan.RetPipe
ãæå®ã§ãããããã使ãã¨ãã£ãã«ã®å®è£
ãåæã«è¿ä¿¡ç¨ã®éæ¹åãã£ãã«ãä½ã£ã¦éã£ã¦ãããã®ã§ãä½ç½®ééæ§ãä¿ã£ãã¾ã¾ãéä¿¡å
ã«è¿ä¿¡ãã¦ããã¨æå®ã§ããã
Fd
ã¯ããåãããªããä¸è¦ããã¨Unixã½ã±ããã®FD passingã¿ãããªãã®ãå®ç¾ããã¤ãããªã®ãã¨ãæããã"file attachment not yet implemented in unix transport"ã¨ãæ¸ãã¦ãããã"file attachment"ã¨ããã®ã¯ä½ãå¥ã®ãã®ãªã®ãããããªãã
unix.Receiver
ã®å®ç¾©ãä¸è¨ã®ããã«ãªã£ã¦ãããããããã¯ãFD passingããã¨ãæãã®ã ãã
type Receiver interface { Receive() ([]byte, *os.File, error) }
ææ³
ãã¶ã¤ã³ã¯é åçã ããã ããä½ç½®ã¥ããã¾ã ä¸å®å®ã§ããããå®è£ ãéçºéä¸ã§æªå®è£ æ©è½ãå¤ãã
ãã£ãã«ä¸ã§ãã£ãã«ãéããã¨ãããã¨ã®å¼·åãã¯Goã§chanã使ã£ã¦ããã¨ããåããã
ããããããã¯ã¼ã¯åæ£ã·ã¹ãã ã§å©ç¨ã§ããã®ã¯ã¨ã¦ã楽ãã¿ã ããã ãSPDYãã©ã³ã¹ãã¼ãã§ã®ãã£ãã«è»¢éã libchan.RetPipe
ãé¤ãã¦æªå®è£
ãªã®ã§ããã®é
åã¯ç¾æç¹ã§ã¯åæ¸ããã
ãã£ãã«å転éã®å°é£
å®éã®ã¨ãããªã¢ã¼ããã·ã³å®ã®ä»»æã®ãã£ãã«è»¢éããµãã¼ãããã¨ãªãã¨åä»ãªåé¡ã«åºä¼ãã ããã 転éããã¦ãããã£ãã«ãå転éã§ããã¨ããã®ããã®ãã©ãã¤ã ãå¼·åãããããã®ã ãããã®ãã©ã³ã¹ãã¼ãã¬ãã«ã§ã®å®è£ ã¯é¢åã«ãªãå¾ãã
ãã¼ãA, B, Cããã£ã¦ãAãçæããAå®ã®ãã£ãã«ãBã«éããBã¯ãããCã«å転éããCããã®ãã£ãã«ã«æ¸ãè¾¼ãã ã¨ããããç´ æ´ã«ã¯2éãã®å®è£ ãèããããã
- Cã¯Aã¨ç´æ¥éä¿¡ãããCã¯ãã£ãã«ãåãåã£ãæç¹ã§Aã¸ã®éä¿¡ã確ç«ãããã®ä¸ã«åãåã£ããã£ãã«ãåç¾ãã
- BãCã¨Aã®éä¿¡ãä¸ç¶ããã
è¤éãªã·ã¹ãã ã§ãã£ãã«ããã¡ãã¡ã§ããåããããã¨ãä¸ç¶ã¢ãã«ã¯ç ´ç¶»ãããã¨ãäºæ³ãããã ãã£ãã«ã®æµéçµè·¯ãéã«è¾¿ã£ã¦ã·ã¹ãã å ã®ãã¼ãããããåããããç¡é§ã«è»¢éã³ã¹ããæ¯æãã¡ãã»ã¼ã¸ãè¦ããããã ã
ä¸æ¹ã§ç´æ¥éä¿¡ã¢ãã«ã¯ã§ã¯Aã¨Cãç´æ¥éä¿¡å¯è½ã¨ã¯éããªããfirewallè¶ããNATè¶ãã®åé¡ãããããRaw TCPçµç±ã§Websocketãã£ãã«ãéã£ãå ´åã©ã£ã¡ã®ãããã³ã«ã妥å½ã¨ãè¨ããªãã
çµå±ã¯ç´æ¥éä¿¡ã¨ä¸ç¶ã®ãã¤ããªããã妥å½ã§ãããã¨èããããããã©ããã¤ããªããããã®ããéä¿¡ãã¹ãã©ãæé©åããã®ãã¨ããã«ã¼ãã£ã³ã°åé¡ãæ®ãã
å°æ¥æ§
Dockerãå®è£ ããã«ã¯ä¾¿å©ãªãã ããã¨æããåé¡ã¯ã©ãã¾ã§æ±ç¨åãã¦ãããã ãããã¨ããã¨ããã«ããã
ä¸å¿ã¯ä»»æã®è¨èªã§ã©ã¤ãã©ãªãå®è£ å¯è½ã¨æ¸ãã¦ããã®ã§ãDocker以å¤ã使ããã¨ãæ³å®ã¯ãã¦ãããã ãããããã§ããNATè¶ãã¨ãã«ã¼ãã£ã³ã°ã¨ããã©ãã¾ã§çå£ã«ãµãã¼ããã¦ãããã®ãã ãã®è¾ºã®Dockerã«ã¯å¿ è¦ãã©ããåãããªãæ©è½ã®ããã«ããããç¶ç¶çã«åãä»ãã¦ãããã®ãã誰ãããããããããæ¸ãã®ãã
競å
å¤æ§ãªãã©ã³ã¹ãã¼ãããµãã¼ãããéä¿¡ã©ã¤ãã©ãªã¨ããç¹ã§libchanã¯ããããã¾ã«ZeroMQã¨ç«¶åããã
ä¸ã®äººã®ã³ã¡ã³ã ã§ã¯ãZeroMQã¯æ©è½éå°ã ãããã¼ã¬ãã«éããããè¦ããªãæ©è½ãå¤ãã®ã大å¤ãã ããlibchanãä½ã£ãã¨ããã
å人çã«ã¯ããã«è³åããããã£ã³ãã«èªä½ã®è»¢éãã§ããã®ã¯å§åçãªé åã ããããã§ååã«å¼·åã ã ZeroMQããµãã¼ãããPublisher-Subscriberã¢ãã«ãåæéä¿¡, åæ¹åéä¿¡ã¯libchanã«æ¬ ãã¦ãããç¹ã«åé¡ã¨ãæããªãã ãã¤ãã¹ããªã¼ã ä¸ã«ãã£ãã«è»¢éãæ§ç¯ãããã¨ã«æ¯ã¹ãã¨ãPubSubãåæãåæ¹åéä¿¡ãéåæä¸æ¹å+ãã£ãã«è»¢éã§å®è£ ããã»ãã楽ã ããæ½è±¡åã¨ãã¦ã¾ã¨ãã«æããã
ããããçãããæããªããã°ä½¿ãããªãã ãããã©ãã ãã¦ã¼ã¶ã¼å±¤ãæçãã¦ããã®ãæªç¥æ°ã§ããã
çµè«
æµè¡ã£ãããããªã¨æããããããã¯ã¼ã¯è¶ãã®ãã£ãã«è»¢éã®ä»æ§ãåºã¾ã£ã¦ãããRubyãC++ã§å®è£ ããã®ãã®é¢ç½ããããããªãã ã§ãä»ã¯ä½¿ãã¨ãã§ã¯ãªãã¨æãã