flowcount

package
v0.0.0-...-2828958 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedisConfDo

func RedisConfDo(commandName string, args ...interface{}) (interface{}, error)

func RedisConfPipline

func RedisConfPipline(pip ...func(c redis.Conn)) error

Types

type FlowCounter

type FlowCounter struct {
	// 当服务多的时候使用map方便,但是需要加锁
	RedisFlowCountMap map[string]*RedisFlowCountService
	// 当服务比较少的时候使用 slice 便利,减少锁的开销
	RedisFlowCountSlice []*RedisFlowCountService
	Locker              sync.RWMutex
}
var FlowCounterHandler *FlowCounter

func NewFlowCounter

func NewFlowCounter() *FlowCounter

func (*FlowCounter) GetCounter

func (counter *FlowCounter) GetCounter(serviceName 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) *RedisFlowCountService

func (*RedisFlowCountService) GetDayData

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

func (*RedisFlowCountService) GetDayKey

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

func (*RedisFlowCountService) GetHourData

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

func (*RedisFlowCountService) GetHourKey

func (o *RedisFlowCountService) GetHourKey(t time.Time) 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