counter

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ceil

type Ceil struct {
	Num int32
}

type CeilList

type CeilList struct {
	Ceils map[*Counter]*Ceil
	Unix  int64
}

type Counter

type Counter struct {
	Duration       int64 // 统计时长 单位秒
	Quite          int64 // 静默期 单位秒
	Max            int32 // 触发notify的最大值
	CurrentNum     int32 // 秒级别的统计数据量
	LastNotifyUnix int64 // 最后的notify时间
	Handler        Handler
	Mata           map[string]interface{}
}

func NewCounter

func NewCounter(duration int64, quite int64, max int32) *Counter

func (*Counter) Add

func (c *Counter) Add(i int32)

func (*Counter) AddHandle

func (c *Counter) AddHandle(fn Handler)

func (*Counter) Notify

func (c *Counter) Notify(t time.Time, sum int32)

type Handler

type Handler func(c *Counter, t time.Time, sum int32)

type Timeline

type Timeline struct {
	Container  []*CeilList `json:"container"`    // 数据容器
	MaxMemTime int64       `json:"max_mem_time"` // 最大记忆秒数
	Counters   []*Counter  `json:"counters"`
	Context    context.Context
}

func NewTimeline

func NewTimeline(max_mem_time int64, ctx context.Context) *Timeline

func (*Timeline) AddCounter

func (l *Timeline) AddCounter(c *Counter) error

func (*Timeline) CounterSum

func (l *Timeline) CounterSum(c *Counter, t time.Time) int32

对counter 单独计数

func (*Timeline) Loop

func (l *Timeline) Loop()

func (*Timeline) Notify

func (l *Timeline) Notify(t time.Time)

func (*Timeline) Pop

func (l *Timeline) Pop(unix int64)

pop过期数据

func (*Timeline) Push

func (l *Timeline) Push(unix int64)

收集数据

func (*Timeline) Save

func (l *Timeline) Save()

func (*Timeline) Start

func (l *Timeline) Start()

func (*Timeline) StartWithContext

func (l *Timeline) StartWithContext(ctx context.Context)

Jump to

Keyboard shortcuts

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