Discover Packages
github.com/hejiangda/geektimegohomework
week5
package
Version:
v0.0.0-...-12c6a5d
Opens a new window with list of versions in this module.
Published: Mar 12, 2022
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
参考 Hystrix 实现一个滑动窗口计数器。
答:参考 hystrix-go 中的代码
Expand ▾
Collapse ▴
Documentation
¶
Number tracks a numberBucket over a bounded number of
time buckets. Currently the buckets are one second long and only the last 10 seconds are kept.
用map来保存最近10秒的数据
NewNumber initializes a RollingNumber struct.
Increment increments the number in current timeBucket.
更新数据
Max returns the maximum value seen in the last 10 seconds.
获取滑动窗口中的最大值
Sum sums the values over the buckets in the last 10 seconds.
计算滑动窗口中所有数据的和
UpdateMax updates the maximum value in the current bucket.
更新最大值
Source Files
¶
Click to show internal directories.
Click to hide internal directories.