<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>

          NATS Go云消息系統(tǒng)

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

          NATS Go 是 NATS 的 Go 客戶端。

          安裝:

          # Go client
          go get github.com/nats-io/nats
          # Servers
          # gnatsd
          go get github.com/nats-io/gnatsd
          # nats-server (Ruby)
          gem install nats

          基礎編碼使用

          nc, _ := nats.Connect(nats.DefaultURL)
          c, _ := nats.NewEncodedConn(nc, nats.JSON_ENCODER)
          defer c.Close()
          // Simple Publisher
          c.Publish("foo", "Hello World")
          // Simple Async Subscriber
          c.Subscribe("foo", func(s string) {
              fmt.Printf("Received a message: %s\n", s)
          })
          // EncodedConn can Publish any raw Go type using the registered Encoder
          type person struct {
               Name     string
               Address  string
               Age      int
          }
          // Go type Subscriber
          c.Subscribe("hello", func(p *person) {
              fmt.Printf("Received a person: %+v\n", p)
          })
          me := &person{Name: "derek", Age: 22, Address: "585 Howard Street, San Francisco, CA"}
          // Go type Publisher
          c.Publish("hello", me)
          // Unsubscribing
          sub, err := c.Subscribe("foo", nil)
          ...
          sub.Unsubscribe()
          // Requests
          var response string
          err := nc.Request("help", "help me", &response, 10*time.Millisecond)
          // Replying
          c.Subscribe("help", func(subj, reply string, msg string) {
              c.Publish(reply, "I can help!")
          })
          // Close connection
          c.Close();
          瀏覽 23
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <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>
                  黄片一级二级三级 | 99久久精品人妻无码一区二区蜜桃 | 国产女人操B | 欧美黄色电影一区二区在线播放 | 91中文字日产乱幕4区 |