Skip to content

Commit

Permalink
cosmetic change
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ committed Aug 7, 2024
1 parent e391dbc commit 80e14fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions logp/ratelimited.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ type RateLimitedLogger struct {
// NewRateLimited returns a new RateLimitedLogger. It takes a logFn, which is
// called with the count of events and the period between each call,
// and a period determining how often the log function should be called.
func NewRateLimited(
logFn func(count uint64, d time.Duration), period time.Duration) *RateLimitedLogger {
func NewRateLimited(period time.Duration, logFn func(count uint64, d time.Duration)) *RateLimitedLogger {
return &RateLimitedLogger{
period: period,
logFn: logFn,
Expand Down
10 changes: 5 additions & 5 deletions logp/ratelimited_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestRateLimitedLogger(t *testing.T) {
now := time.Now()

t.Run("Start", func(t *testing.T) {
r := NewRateLimited(func(count uint64, d time.Duration) {}, math.MaxInt64)
r := NewRateLimited(math.MaxInt64, func(count uint64, d time.Duration) {})
defer r.Stop()
r.nowFn = func() time.Time { return now }

Expand All @@ -77,7 +77,7 @@ func TestRateLimitedLogger(t *testing.T) {
})

t.Run("Start twice", func(t *testing.T) {
r := NewRateLimited(func(count uint64, d time.Duration) {}, math.MaxInt64)
r := NewRateLimited(math.MaxInt64, func(count uint64, d time.Duration) {})
defer r.Stop()

r.nowFn = func() time.Time { return now }
Expand All @@ -101,7 +101,7 @@ func TestRateLimitedLogger(t *testing.T) {
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
buff, logFn := newLogger()
r := NewRateLimited(logFn, 42*time.Second)
r := NewRateLimited(42*time.Second, logFn)
r.nowFn = func() time.Time { return now }

tch := make(chan time.Time)
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestRateLimitedLogger(t *testing.T) {

t.Run("Add", func(t *testing.T) {
buff, logFn := newLogger()
r := NewRateLimited(logFn, 42*time.Second)
r := NewRateLimited(42*time.Second, logFn)
defer r.Stop()

r.nowFn = func() time.Time { return now }
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestRateLimitedLogger(t *testing.T) {

t.Run("AddN", func(t *testing.T) {
buff, logFn := newLogger()
r := NewRateLimited(logFn, 42*time.Second)
r := NewRateLimited(42*time.Second, logFn)
defer r.Stop()

r.nowFn = func() time.Time { return now }
Expand Down

0 comments on commit 80e14fe

Please sign in to comment.