common

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 2 Imported by: 0

Documentation

Overview

Package common .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateStartTimeMilli

func CalculateStartTimeMilli(curTimeMs int64, interval int64) int64

CalculateStartTimeMilli 计算起始滑窗

Types

type SlidingWindow

type SlidingWindow struct {
	// contains filtered or unexported fields
}

SlidingWindow 滑窗通用实现

func NewSlidingWindow

func NewSlidingWindow(slideCount int, intervalMs int) *SlidingWindow

NewSlidingWindow 创建滑窗

func (*SlidingWindow) AcquireCurrentValues

func (s *SlidingWindow) AcquireCurrentValues(curTimeMs int64) (uint32, uint32, *Window)

AcquireCurrentValues 获取上报数据

func (*SlidingWindow) AddAndGetCurrentLimited

func (s *SlidingWindow) AddAndGetCurrentLimited(curTimeMs int64, value uint32) (uint32, *Window)

AddAndGetCurrentLimited 原子增加,并返回当前bucket

func (*SlidingWindow) AddAndGetCurrentPassed

func (s *SlidingWindow) AddAndGetCurrentPassed(curTimeMs int64, value uint32) (uint32, *Window)

AddAndGetCurrentPassed 原子增加,并返回当前bucket

func (*SlidingWindow) TouchCurrentPassed

func (s *SlidingWindow) TouchCurrentPassed(curTimeMs int64) (uint32, *Window)

TouchCurrentPassed 获取上报数据

type Window

type Window struct {
	// 起始时间
	WindowStart int64
	// 通过数
	PassedValue uint32
	// 被限流数
	LimitedValue uint32
}

Window 单个窗口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL