Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLimiter = &RateLimiter{ Map: make(map[string]chan struct{}), Mutex: &sync.RWMutex{}, }
DefaultLimiter is the RateLimiter used by the package-level Request and NonBlockingRequest.
Functions ¶
func NonBlockingRequest ¶
NonBlockingRequest is a NonBlockingRequest with DefaultLimiter.
Types ¶
type RateLimiter ¶
RateLimiter is a simple rate limiter.
func (*RateLimiter) NonBlockingRequest ¶
func (s *RateLimiter) NonBlockingRequest(u string, perMinute int) bool
NonBlockingRequest checks if it can do a request. If it can't, it returns false, else it returns true if the request succeded.
func (*RateLimiter) Request ¶
func (s *RateLimiter) Request(u string, perMinute int)
Request is a simple request. Blocks until it can make the request.
Click to show internal directories.
Click to hide internal directories.