Documentation ¶
Index ¶
Constants ¶
View Source
const ( // PtrOffSize 指针偏移量大小 PtrOffSize = uint64(8) )
Variables ¶
Functions ¶
Types ¶
type AtomicArray ¶
type AtomicArray struct {
// contains filtered or unexported fields
}
AtomicArray 封装原子操作, 底层维护 []*Bucket
func NewAtomicArray ¶
func NewAtomicArray(length uint64, bucketSize uint64, Builder BucketBuilder) *AtomicArray
NewAtomicArray 初始化 AtomicArray, startTime 为当前时间
func NewAtomicArrayWithTime ¶
func NewAtomicArrayWithTime(length uint64, bucketSize uint64, now uint64, Builder BucketBuilder) *AtomicArray
NewAtomicArrayWithTime 初始化 AtomicArray, 需要手动传入 startTime 作为时间戳
type BucketBuilder ¶
type BucketBuilder interface { // NewEmptyBucket 生成一个空桶 NewEmptyBucket() interface{} // Reset 重置桶 Reset(b *Bucket, startTime uint64) *Bucket }
BucketBuilder Bucket 生成器
type LeapArray ¶
type LeapArray struct {
// contains filtered or unexported fields
}
LeapArray 基于 Bucket 实现的 leap array 例如: bucketSize == 200ms,intervalSize == 1000ms,所以n = 5 假设当前是 时间是888ms 构建下图
B0 B1 B2 B3 B4 |_______|_______|_______|_______|_______| 1000 1200 1400 1600 800 (1000) ^ time=888
func NewLeapArray ¶
func NewLeapArray(n uint64, intervalSize uint64, builder BucketBuilder) (*LeapArray, error)
NewLeapArray 初始化 leap array
type SlidingWindow ¶
type SlidingWindow interface { // Shutdown 优雅关闭 Shutdown() // AddIndex 添加指标信息 AddIndex(k string, v uint) // Show 展示信息 Show() []interface{} // contains filtered or unexported methods }
SlidingWindow 滑动窗口接口化
Click to show internal directories.
Click to hide internal directories.