Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrencyLimiter ¶
type ConcurrencyLimiter struct {
// contains filtered or unexported fields
}
ConcurrencyLimiter object.
func NewConcurrencyLimiter ¶
func NewConcurrencyLimiter(name string, limit int) *ConcurrencyLimiter
NewConcurrencyLimiter allocates a new ConcurrencyLimiter. This is useful for limiting the amount of functions running at once and is used to only allow a specific number of sessions to start at once.
func (*ConcurrencyLimiter) FreeTicket ¶
func (c *ConcurrencyLimiter) FreeTicket(ticket int)
FreeTicket adds the ticket back into the queue.
func (*ConcurrencyLimiter) InProgress ¶
func (c *ConcurrencyLimiter) InProgress() int32
InProgress returns how many tickets are being used.
func (*ConcurrencyLimiter) Wait ¶
func (c *ConcurrencyLimiter) Wait() (ticket int)
Wait waits for a free ticket in the queue. Functions that call wait must defer FreeTicket with thee ticket ID.
type DurationLimiter ¶
type DurationLimiter struct {
// contains filtered or unexported fields
}
DurationLimiter represents something that will wait until the ratelimit. has cleared.
func NewDurationLimiter ¶
func NewDurationLimiter(name string, limit int32, duration time.Duration) (bs *DurationLimiter)
NewDurationLimiter creates a DurationLimiter. This is useful for allowing a specific operation to run only X amount of times in a duration of Y.
func (*DurationLimiter) Lock ¶
func (l *DurationLimiter) Lock()
Lock waits until there is an available slot in the Limiter.