Skip to content
Distributed rate limiting on Go
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
gateway
.gitignore
.travis.yml
LICENSE
README.md
counter.go
counter_test.go
example_test.go
go.mod
go.sum

README.md

go-counter

Build Status Coverage Status GoDoc Go Report Card

Distributed rate limiting with pluggable storage for storing counters state.

Basic usage

// Create new Counter
c, _ := counter.New(1, time.Millisecond*100)
// Increment counter and get remainder
if v, err := c.Count("key"); err != nil {
	if e, ok := err.(counter.TTLError); ok {
		// Use e.TTL() if need
	} else {
		// Handle err
	}
} else {
	// Counter value equals 1
	// Remainder value (v) equals 0
	// Next c.Count("key") call will return TTLError
}

Example usage

You can’t perform that action at this time.