Documentation ¶
Overview ¶
Package counter contains varias counter tools
Index ¶
- type ChildParallelCounter
- type Counter
- type Int64CounterItf
- type ParallelCounter
- type RotateCounter
- func NewRotateCounter(rotatePoint int64) (*RotateCounter, error)
- func NewRotateCounterFromN(n, rotatePoint int64) (*RotateCounter, error)
- func NewRotateCounterFromNWithCtx(ctx context.Context, n, rotatePoint int64) (*RotateCounter, error)
- func NewRotateCounterWithCtx(ctx context.Context, rotatePoint int64) (*RotateCounter, error)
- type Uint32Counter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChildParallelCounter ¶
ChildParallelCounter child of ParallelCounter
func (*ChildParallelCounter) CountN ¶
func (c *ChildParallelCounter) CountN(n int64) (r int64)
CountN count n
type Counter ¶
Counter int64 counter
Example ¶
counter := NewCounter() counter.Count() counter.CountN(10) counter.Get() // get current count
Output:
func NewCounterFromN ¶
NewCounterFromN create Counter from custom number
type Int64CounterItf ¶
Int64CounterItf counter for int64
type ParallelCounter ¶
ParallelCounter parallel count with child counter
func NewParallelCounter ¶
func NewParallelCounter(quoteStep, rotatePoint int64) (*ParallelCounter, error)
NewParallelCounter get new parallel counter
func NewParallelCounterFromN ¶
func NewParallelCounterFromN(n, quoteStep, rotatePoint int64) (*ParallelCounter, error)
NewParallelCounterFromN get new parallel counter
func (*ParallelCounter) GetChild ¶
func (c *ParallelCounter) GetChild() *ChildParallelCounter
GetChild create new child
func (*ParallelCounter) GetQuote ¶
func (c *ParallelCounter) GetQuote(step int64) (from, to int64)
GetQuote child request new quote from parent
type RotateCounter ¶
RotateCounter rotate counter
Example ¶
counter, err := NewRotateCounter(10) if err != nil { panic(err) } counter.Count() // 1 counter.CountN(10) // 1
Output:
func NewRotateCounter ¶
func NewRotateCounter(rotatePoint int64) (*RotateCounter, error)
NewRotateCounter create new RotateCounter with threshold from 0
func NewRotateCounterFromN ¶
func NewRotateCounterFromN(n, rotatePoint int64) (*RotateCounter, error)
NewRotateCounterFromN create new RotateCounter with threshold from N
func NewRotateCounterFromNWithCtx ¶
func NewRotateCounterFromNWithCtx(ctx context.Context, n, rotatePoint int64) (*RotateCounter, error)
NewRotateCounterFromNWithCtx create new RotateCounter with threshold from N
func NewRotateCounterWithCtx ¶
func NewRotateCounterWithCtx(ctx context.Context, rotatePoint int64) (*RotateCounter, error)
NewRotateCounterWithCtx create new RotateCounter with threshold from 0
func (*RotateCounter) Count ¶
func (c *RotateCounter) Count() int64
Count increse and return the result
func (*RotateCounter) CountN ¶
func (c *RotateCounter) CountN(n int64) (r int64)
CountN increse N and return the result
type Uint32Counter ¶
type Uint32Counter struct {
// contains filtered or unexported fields
}
Uint32Counter uint32 counter
func NewUint32Counter ¶
func NewUint32Counter() *Uint32Counter
NewUint32Counter return new Uint32Counter from 0
func NewUint32CounterFromN ¶
func NewUint32CounterFromN(n uint32) *Uint32Counter
NewUint32CounterFromN return new Uint32Counter from n
func (*Uint32Counter) Count ¶
func (c *Uint32Counter) Count() uint32
Count increse and return the result
func (*Uint32Counter) CountN ¶
func (c *Uint32Counter) CountN(n uint32) uint32
CountN increse N and return the result
func (*Uint32Counter) Get ¶
func (c *Uint32Counter) Get() uint32
Get return current counter's number
func (*Uint32Counter) Set ¶
func (c *Uint32Counter) Set(n uint32)
Set overwrite the counter's number