counter

package
v0.0.0-...-132f7fb Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlowCountService

type FlowCountService struct {
	AppID       string        //应用ID
	Interval    time.Duration //采集频率
	TotalCount  int64         //当前总共请求数
	QPS         int64         //QPS
	Unix        int64         //上次unix时间戳
	TickerCount int64         //当前流量
}

本地统计用的counter

func NewFlowCountService

func NewFlowCountService(appID string, interval time.Duration) (*FlowCountService, error)

func (*FlowCountService) Increase

func (o *FlowCountService) Increase()

原子增加

type FlowCounter

type FlowCounter struct {
	RedisFlowCountMap   map[string]*RedisFlowCountService
	RedisFlowCountSlice []*RedisFlowCountService
	Locker              sync.RWMutex
}
var FlowCounterHandler *FlowCounter

func NewFlowCounter

func NewFlowCounter() *FlowCounter

func (*FlowCounter) GetCounter

func (counter *FlowCounter) GetCounter(serverName string) (*RedisFlowCountService, error)

type RedisFlowCountService

type RedisFlowCountService struct {
	AppID       string
	Interval    time.Duration
	QPS         int64
	Unix        int64
	TickerCount int64
	TotalCount  int64
}

func NewRedisFlowCountService

func NewRedisFlowCountService(appID string, interval time.Duration, loc *time.Location) *RedisFlowCountService

func (*RedisFlowCountService) GetDayData

func (o *RedisFlowCountService) GetDayData(t time.Time, loc *time.Location) (int64, error)

func (*RedisFlowCountService) GetDayKey

func (o *RedisFlowCountService) GetDayKey(t time.Time, loc *time.Location) string

func (*RedisFlowCountService) GetHourData

func (o *RedisFlowCountService) GetHourData(t time.Time, loc *time.Location) (int64, error)

func (*RedisFlowCountService) GetHourKey

func (o *RedisFlowCountService) GetHourKey(t time.Time, loc *time.Location) string

func (*RedisFlowCountService) Increase

func (o *RedisFlowCountService) Increase()

原子增加

Jump to

Keyboard shortcuts

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