Documentation ¶
Overview ¶
Package hitcounter augments the message-server with a store to track hits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockedValue ¶
type BlockedValue struct { Since float64 Value interface{} }
BlockedValue is a value that is blocked by the system.
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock represents an integer clock that starts at 0.
type Direction ¶
type Direction struct { Store *store.ShardMap Name string CleanUpTime float64 MaxHits float64 WindowSize float64 }
Direction is a tracked resource. See package config for definition of its member variables.
func (*Direction) BlockedValues ¶
func (d *Direction) BlockedValues() []BlockedValue
Returns the list of all values in the map that have IsBlocked == true.
type HitCounter ¶
type HitCounter struct { Clock *Clock Count *RunningCount Directions map[string]*Direction Logger *logger.Logger }
HitCounter is a server that tracks several directions.
func NewHitCounter ¶
func NewHitCounter(directions []Direction, l *logger.Logger) *HitCounter
NewHitCounter returns an initialized *HitCounter.
func (*HitCounter) HandleRequest ¶
func (h *HitCounter) HandleRequest(direction string, value interface{}) bool
type RunningCount ¶
type RunningCount struct {
// contains filtered or unexported fields
}
RunningCount is a counter where every increment is temporary. After the duration has passed, the counter decrements.
func NewRunningCount ¶
func NewRunningCount(Granularity int, Duration time.Duration) *RunningCount
NewRunningCount returns an initialized *RunningCount.
func (*RunningCount) Inc ¶
func (r *RunningCount) Inc()
Inc increments the count by 1. This increment will expire after the RunningCount's duration.