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

feat: allow functional nil limiter.Met implementation #4

Merged

Conversation

LucasRoesler
Copy link
Member

Ensure that Met() is functional and false when the limiter is nil. This makes it a bit easier to work with because you can assume the cl.Met is always callable. Reducing the number of required nil checks.

This is helpful to simplify the implementation for openfaas/of-watchdog#144

Ensure that Met() is functional when the limiter is nil. This makes it a
bit easier to work with because you can assume the `cl.Met` is always
callable. Reducing the number of required nil checks.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
@@ -11,6 +11,13 @@ import (
"time"
)

func Test_Met_FalseWhenNil(t *testing.T) {
var cl *ConcurrencyLimiter
if cl.Met() != false {
Copy link
Member

Choose a reason for hiding this comment

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

I didn’t know it was possible to execute methods against a nil reference. TIL

@alexellis alexellis merged commit 9f00ae1 into openfaas:master Jun 17, 2024
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