1 Star 0 Fork 0

Hiram/etcd-queue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.go 694 Bytes
一键复制 编辑 原始数据 按行查看 历史
Hiram 提交于 2021-03-18 14:25 . initial
/**
* @Author: hiram
* @Date: 2021/3/18 13:43
*/
package main
import (
"gitee.com/gbat/etcd-queue/etcdq"
"strconv"
"sync"
"time"
)
func writeItem(etcd *etcdq.Etcd, key string, value string, wg *sync.WaitGroup) {
defer wg.Done()
etcd.WriteItem(key, value)
}
func writeEvents(n int) {
etcd := etcdq.NewEtcd("127.0.0.1:2379", 10)
var wg sync.WaitGroup
num := 2000
for i := 0; i < num; i++ {
key := etcdq.ResourcePrefix + "apple/" + strconv.Itoa(i) + "#" + strconv.Itoa(n) + "%"
wg.Add(1)
go writeItem(&etcd, key, key, &wg)
}
wg.Wait()
etcdq.Info.Println("write events: ", n*num)
}
func main() {
for i := 0; i < 50; i++ {
writeEvents(i)
time.Sleep(time.Second*1)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/gbat/etcd-queue.git
git@gitee.com:gbat/etcd-queue.git
gbat
etcd-queue
etcd-queue
8f86345d51d0

搜索帮助

0d507c66 1850385 C8b1a773 1850385