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

Initialize the limit #100

Open
liuuujr opened this issue May 30, 2024 · 1 comment
Open

Initialize the limit #100

liuuujr opened this issue May 30, 2024 · 1 comment

Comments

@liuuujr
Copy link

liuuujr commented May 30, 2024

There are three ways to initialize a "Limit", which are "PerSecond(rate int)", "PerMinute(rate int)", "PerHour(rate int)". But the Limit generated by these three functions,the values of its "Rate" and "Burst" fields are equal。So I'd like to create a few more functions that initialize the LIMIT, which can specify the "rate" field and the "burst" field separately。

func PerHourWithCapacity(rate int, capacity int) Limit {
	return Limit{
		Rate:   rate,
		Period: time.Hour,
		Burst:  capacity,
	}
}
@tikhomirovv
Copy link

tikhomirovv commented Jun 19, 2024

@liuuujr

The Limit is public, so you can configure it in your code to suit any needs. I don't think it's possible (or necessary) to cover every single case in a package.

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

No branches or pull requests

2 participants