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

          taskqGolang 異步任務(wù)/作業(yè)隊(duì)列

          聯(lián)合創(chuàng)作 · 2023-09-29 13:23

          taskq 是一個(gè)帶有 Redis、SQS、IronMQ 和內(nèi)存后端的 Golang 異步任務(wù)/作業(yè)隊(duì)列。

          特性:

          • Redis、SQS、IronMQ 和內(nèi)存后端。
          • 自動(dòng)縮放用于獲取(fetcher)和處理消息(worker)的 goroutines 的數(shù)量。
          • 全局速率限制。
          • 工人的全球限制。
          • 調(diào)用一次 - 刪除具有相同名稱的重復(fù)消息。
          • 使用指數(shù)退避自動(dòng)重試。
          • 當(dāng)隊(duì)列中的所有消息都失敗時(shí)自動(dòng)暫停。
          • 用于處理失敗消息的后備處理程序。
          • 消息批處理。它用于 SQS 和 IronMQ 后端批量添加/刪除消息。
          • 使用 snappy / s2 自動(dòng)壓縮消息。

          API overview

          t := myQueue.RegisterTask(&taskq.TaskOptions{
              Name:    "greeting",
              Handler: func(name string) error {
                  fmt.Println("Hello", name)
                  return nil
              },
          })
          
          // Say "Hello World".
          err := myQueue.Add(t.WithArgs(context.Background(), "World"))
          if err != nil {
              panic(err)
          }
          
          // Say "Hello World" with 1 hour delay.
          msg := t.WithArgs(ctx, "World")
          msg.Delay = time.Hour
          _ = myQueue.Add(msg)
          
          // Say "Hello World" once.
          for i := 0; i < 100; i++ {
              msg := t.WithArgs(ctx, "World")
              msg.Name = "hello-world" // unique
              _ = myQueue.Add(msg)
          }
          
          // Say "Hello World" once with 1 hour delay.
          for i := 0; i < 100; i++ {
              msg := t.WithArgs(ctx, "World")
              msg.Name = "hello-world"
              msg.Delay = time.Hour
              _ = myQueue.Add(msg)
          }
          
          // Say "Hello World" once in an hour.
          for i := 0; i < 100; i++ {
              msg := t.WithArgs(ctx, "World").OnceInPeriod(time.Hour)
              _ = myQueue.Add(msg)
          }
          
          // Say "Hello World" for Europe region once in an hour.
          for i := 0; i < 100; i++ {
              msg := t.WithArgs(ctx, "World").OnceInPeriod(time.Hour, "World", "europe")
              _ = myQueue.Add(msg)
          }
          
          瀏覽 24
          點(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青青草免费 | 新国产在线观看色情 |