timewheel

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

timewheel

Documentation

Index

Constants

View Source
const (
	DownSide TriggerDirection = 0
	UpSide   TriggerDirection = 1

	LevelTrigger TriggerMethod = 0
	EdgeTrigger  TriggerMethod = 1
)

Variables

View Source
var TypeFactoryRegister *typeFactoryRegister

Functions

func Sleep

func Sleep(d time.Duration, tw *TimeWheel)

Types

type AfterCountFunc

type AfterCountFunc interface {
	AfterCount(msg Message) (err error)
}

type Aggregate

type Aggregate struct {
	*Counter
}

func NewAggregate

func NewAggregate(tw *TimeWheel, size uint64, d time.Duration, valueType string) (aggregate *Aggregate, err error)

func (*Aggregate) AfterCount

func (aggregate *Aggregate) AfterCount(msg Message) (err error)

type Counter

type Counter struct {
	Output chan Message
	// contains filtered or unexported fields
}

func NewCounter

func NewCounter(tw *TimeWheel, size uint64, d time.Duration, msgType string) (counter *Counter, err error)

func (*Counter) Add

func (c *Counter) Add(msg Message)

func (*Counter) Clean

func (c *Counter) Clean()

func (*Counter) Stop

func (c *Counter) Stop()

type EMA

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

func NewEMA

func NewEMA(alpha float64) (ema *EMA)

func (*EMA) AfterCount

func (ema *EMA) AfterCount(n uint64)

func (*EMA) Value

func (ema *EMA) Value() float64

type Message

type Message interface {
	proto.Message
	Type() string
	NewCounter(tw *TimeWheel, size uint64, d time.Duration) (*Counter, error)
	Add(Message)
	Clean()
}

type OutputFile

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

func NewOutputFile

func NewOutputFile(path string) (o *OutputFile, err error)

func (*OutputFile) AfterCount

func (o *OutputFile) AfterCount(msg Message) (err error)

type ThresholdTrigger

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

func NewThresholdTrigger

func NewThresholdTrigger(alterChan chan<- uuid.UUID, threshold uint64, direction TriggerDirection, method TriggerMethod) (trigger *ThresholdTrigger)

func (*ThresholdTrigger) AfterCount

func (trigger *ThresholdTrigger) AfterCount(n uint64)

type Ticker

type Ticker struct {
	C chan time.Time
	// contains filtered or unexported fields
}

func NewTicker

func NewTicker(d time.Duration, tw *TimeWheel) (ticker *Ticker)

func (*Ticker) Stop

func (t *Ticker) Stop()

type TimeWheel

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

func NewSubTimeWheel

func NewSubTimeWheel(size uint64, d time.Duration, subTw *TimeWheel) (tw *TimeWheel, err error)

func NewTimeWheel

func NewTimeWheel(size uint64, d time.Duration, subTw *TimeWheel) (tw *TimeWheel, err error)

func (*TimeWheel) NewTicker

func (tw *TimeWheel) NewTicker(d time.Duration) (ticker *Ticker)

func (*TimeWheel) NewTimer

func (tw *TimeWheel) NewTimer(d time.Duration) (timer *Timer)

func (*TimeWheel) Sleep

func (tw *TimeWheel) Sleep(d time.Duration)

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

type Timer

type Timer = Ticker

func NewTimer

func NewTimer(d time.Duration, tw *TimeWheel) (timer *Timer)

func (*Timer) Reset

func (t *Timer) Reset(d time.Duration) bool

type TriggerDirection

type TriggerDirection uint64

type TriggerMethod

type TriggerMethod uint64

type TypeFactory

type TypeFactory func() (msg Message)

type Uint64

type Uint64 struct {
	pb.Uint64
}

func (*Uint64) Add

func (c *Uint64) Add(msg Message)

func (*Uint64) Clean

func (c *Uint64) Clean()

func (*Uint64) NewCounter added in v0.0.2

func (c *Uint64) NewCounter(tw *TimeWheel, size uint64, d time.Duration) (*Counter, error)

func (*Uint64) Type added in v0.0.2

func (c *Uint64) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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