<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Wormhole JS流消息隊(duì)列系統(tǒng)

          聯(lián)合創(chuàng)作 · 2023-10-01 03:28

          Wormhole 是一個(gè)基于 Node.js 的流消息隊(duì)列系統(tǒng)。其特點(diǎn)是高性能。和 Kafka 以及 Databus 類似,Wormhole 是個(gè)高度可擴(kuò)展的發(fā)布/訂閱系統(tǒng)。在 Facebook 內(nèi)部,Wormhole 每天處理多達(dá) 1T 的消息,高峰時(shí)每秒超過 1 千萬條消息。

          Wormhole 總體架構(gòu)如下圖:

          示例代碼:

          var Wormhole = require('wormhole');
          
          net.createServer(function (client) {
              Wormhole(client, 'chat', function (msg) {
                  // All messages received from client over chat channel, such as
                  // {hello: 'World'}
              });
          
              Wormhole(client, 'auth', function (msg) {
                  // All messages received from client, such as
                  // {hello: 'World'}
                  if (msg.user == 'foo' && msg.pass == 'bar') {
                     client.write('auth', {auth: 'Thank you for logging in'});
                  }
              });
          
              // client.write now overloaded to encode data.
              client.write('auth', {auth: 'Please login!'});
              client.write('chat', {greet: 'Welcome to our server!'});
          }).listen(2122);
          var client = net.createConnection(2122, function() {
              Wormhole(client, 'chat', function (err, msg) {
                  // Messages received from server, such as
                  // {greet: 'Welcome to our server!'}
              });
              Wormhole(client, 'auth', function (err, msg) {
                  // Messages received from server on auth channel, such as
                  // {auth: 'Please login!'}
                  // {auth: 'Thank you for logging in!'}
              });
              client.write('auth', {user: 'foo', pass: 'bar'});
              client.write('chat', {hello: 'World'});
          });
          瀏覽 23
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  狗爷城中村嫖妓 | 亚洲成人黄色 | 91精品国产乱码久久久久 | 全国最大成人色图 | 在线日韩国产网站 |