1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

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

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

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

        特性:

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

        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
        點贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

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

        手機(jī)掃一掃分享

        編輯 分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            精品人妻系列 | 噗呲少妇嗯啊与公 | 欧美另类操逼 | 国产一区二区三区免费看 | 欧美伦理一区二区 | 美国十次导航 | 猛操美女 | 高清无码在线观看免费 | 日本一级黄色操逼视频 | 熟女久久伊人 |