Compare commits

...

2 Commits

Author SHA1 Message Date
kayos@tcp.direct d51b3642b8
Update README.md 2022-12-21 16:58:16 -08:00
kayos@tcp.direct 693cbf2c84
Fix: only print if we enabled 2022-12-21 16:57:47 -08:00
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# Rate5
[![GoDoc](https://godoc.org/github.com/yunginnanet/?status.svg)](https://godoc.org/github.com/yunginnanet/Rate5) [![Go Report Card](https://goreportcard.com/badge/github.com/yunginnanet/Rate5)](https://goreportcard.com/report/github.com/yunginnanet/Rate5) [![Go](https://github.com/yunginnanet/Rate5/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/yunginnanet/Rate5/actions/workflows/go.yml)
[![codecov](https://codecov.io/gh/yunginnanet/Rate5/branch/main/graph/badge.svg?token=R7WU58G5L7)](https://codecov.io/gh/yunginnanet/Rate5)
[![codecov](https://codecov.io/gh/yunginnanet/Rate5/branch/main/graph/badge.svg?token=R7WU58G5L7)](https://codecov.io/gh/yunginnanet/Rate5) ![five](https://img.shields.io/badge/fhjones-55555-blue)
A performant and generic ratelimitter for any golang project.

View File

@ -28,8 +28,9 @@ func (q *Limiter) setDebugEvict() {
func (q *Limiter) SetDebug(on bool) {
switch on {
case true:
atomic.CompareAndSwapUint32(&q.debug, DebugDisabled, DebugEnabled)
q.debugPrintf("rate5 debug enabled")
if atomic.CompareAndSwapUint32(&q.debug, DebugDisabled, DebugEnabled) {
q.debugPrintf("rate5 debug enabled")
}
case false:
atomic.CompareAndSwapUint32(&q.debug, DebugEnabled, DebugDisabled)
}