Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rate.Limiter for throttling #73

Merged
merged 1 commit into from
Nov 16, 2020
Merged

Use rate.Limiter for throttling #73

merged 1 commit into from
Nov 16, 2020

Conversation

Rukenshia
Copy link
Contributor

@Rukenshia Rukenshia commented Oct 31, 2020

from my manual testing, this will no longer cause high CPU usage (as
reported in #72).

I wasn't sure how to properly test the throttling, but looking at the documentation of the rate package this should do.

I used this for testing:

package main

import (
	"log"
	"time"

	"github.com/Rukenshia/trello"
)

func main() {
	for {
		log.Printf("Creating 100 new clients")
		for i := 0; i < 100; i++ {
			client := trello.NewClient("foo", "bar")

			log.Printf("client: %v", client)
		}
		time.Sleep(5 * time.Second)
	}
}

before this change, CPU usage went up with every 5 second iteration. After the change, the CPU usage is consistently at 0%.

from my manual testing, this will no longer cause high CPU usage (as
reported in #72).
Copy link
Owner

@adlio adlio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution Rukenshia!

@adlio adlio merged commit 3939392 into adlio:master Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants