2020
12-22
12-22
golang频率限制 rate详解
golang.org/x/time/rate提对速度进行限制的算法l:=rate.NewLimiter(1,3)//一个参数为每秒发生多少次事件,第二个参数是最大可运行多少个事件(burst)Limter提供三中主要的函数Allow,Reserve,Wait.大部分时候使用WaitWait/WaitN当没有可用事件时,将阻塞等待c,_:=context.WithCancel(context.TODO())for{l.Wait(c)fmt.Println(time.Now().Format("04:05.000"))}输出07:35.05507:35.05507:35.05507:36.06007:37.0590...
继续阅读 >
组件—评分基础用法<divclass="block"><spanclass="demonstration">默认不区分颜色</span><el-ratev-model="value1"></el-rate></div><divclass="block"><spanclass="demonstration">区分颜色</span><el-ratev-model="value2":colors="colors"></el-rate></div><script>exportdefault{data(){return{value1:null,value2:null,colors:['#99A9BF','#F7BA2A','#FF9900']//等同于{2:'#9...