https://github.com/streamdp/golimiter
Golang library to limiting something
https://github.com/streamdp/golimiter
Last synced: 11 months ago
JSON representation
Golang library to limiting something
- Host: GitHub
- URL: https://github.com/streamdp/golimiter
- Owner: streamdp
- License: gpl-3.0
- Created: 2025-01-20T14:09:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-21T16:48:53.000Z (about 1 year ago)
- Last Synced: 2025-04-12T15:13:55.695Z (11 months ago)
- Language: Go
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Golimiter
Library to limiting something: https request, loops, sends to the channel & etc.
Written on **golang** and used [microcache](https://github.com/streamdp/microcache) library.
### Usage
Example library usage for limiting **doSomething()** function on 10 calls per second:
```go
package main
import (
"context"
"time"
"github.com/streamdp/golimiter"
)
func main() {
l := golimiter.New(context.Background(), time.Minute)
if l.Allow("key1", 10, time.Second) {
doSomething()
}
}
```