Documentation ¶
Index ¶
- Constants
- type InMemRateLimiter
- func (r *InMemRateLimiter) Decrease(sz uint64)
- func (r *InMemRateLimiter) Enabled() bool
- func (r *InMemRateLimiter) Get() uint64
- func (r *InMemRateLimiter) GetTick() uint64
- func (r *InMemRateLimiter) Increase(sz uint64)
- func (r *InMemRateLimiter) RateLimited() bool
- func (r *InMemRateLimiter) Reset()
- func (r *InMemRateLimiter) Set(sz uint64)
- func (r *InMemRateLimiter) SetFollowerState(nodeID uint64, sz uint64)
- func (r *InMemRateLimiter) Tick()
- type RateLimiter
Constants ¶
const ( // ChangeTickThreashold is the minimum number of ticks required to update // the state of the rate limiter. ChangeTickThreashold uint64 = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InMemRateLimiter ¶
type InMemRateLimiter struct {
// contains filtered or unexported fields
}
InMemRateLimiter is the struct used to keep tracking the in memory rate log size.
func NewInMemRateLimiter ¶
func NewInMemRateLimiter(maxSize uint64) *InMemRateLimiter
NewInMemRateLimiter creates and returns a rate limiter instance.
func (*InMemRateLimiter) Decrease ¶
func (r *InMemRateLimiter) Decrease(sz uint64)
Decrease decreases the recorded in memory log size by sz bytes.
func (*InMemRateLimiter) Enabled ¶
func (r *InMemRateLimiter) Enabled() bool
Enabled returns a boolean flag indicating whether the rate limiter is enabled.
func (*InMemRateLimiter) Get ¶
func (r *InMemRateLimiter) Get() uint64
Get returns the recorded in memory log size.
func (*InMemRateLimiter) GetTick ¶
func (r *InMemRateLimiter) GetTick() uint64
GetTick returns the internal logical clock value.
func (*InMemRateLimiter) Increase ¶
func (r *InMemRateLimiter) Increase(sz uint64)
Increase increases the recorded in memory log size by sz bytes.
func (*InMemRateLimiter) RateLimited ¶
func (r *InMemRateLimiter) RateLimited() bool
RateLimited returns a boolean flag indicating whether the node is rate limited.
func (*InMemRateLimiter) Reset ¶
func (r *InMemRateLimiter) Reset()
Reset clears all recorded follower states.
func (*InMemRateLimiter) Set ¶
func (r *InMemRateLimiter) Set(sz uint64)
Set sets the recorded in memory log size to sz bytes.
func (*InMemRateLimiter) SetFollowerState ¶
func (r *InMemRateLimiter) SetFollowerState(nodeID uint64, sz uint64)
SetFollowerState sets the follower rate identiified by nodeID to sz bytes.
func (*InMemRateLimiter) Tick ¶
func (r *InMemRateLimiter) Tick()
Tick advances the internal logical clock.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter is the struct used to keep tracking consumed memory size.
func NewRateLimiter ¶
func NewRateLimiter(max uint64) *RateLimiter
NewRateLimiter creates and returns a rate limiter instance.
func (*RateLimiter) Decrease ¶
func (r *RateLimiter) Decrease(sz uint64)
Decrease decreases the recorded in memory log size by sz bytes.
func (*RateLimiter) Enabled ¶
func (r *RateLimiter) Enabled() bool
Enabled returns a boolean flag indicating whether the rate limiter is enabled.
func (*RateLimiter) Get ¶
func (r *RateLimiter) Get() uint64
Get returns the recorded in memory log size.
func (*RateLimiter) Increase ¶
func (r *RateLimiter) Increase(sz uint64)
Increase increases the recorded in memory log size by sz bytes.
func (*RateLimiter) RateLimited ¶
func (r *RateLimiter) RateLimited() bool
RateLimited returns a boolean flag indicating whether the node is rate limited.
func (*RateLimiter) Set ¶
func (r *RateLimiter) Set(sz uint64)
Set sets the recorded in memory log size to sz bytes.