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: add option to limit concurrency #4

Merged

Conversation

costela
Copy link
Member

@costela costela commented Oct 10, 2023

This adds an option to limit the circuit's concurrency:

circuit := hoglet.NewCircuit(
        func(context.Context, any) (any, error) { return nil, nil },
        hoglet.NewEWMABreaker(10, 0.9),
        hoglet.WithConcurrencyLimit(100, false),
    )

The limit may be non-blocking (fail immediately) or blocking (holding off on calls over limit).

When blocking, context cancellation is respected to avoid requests piling up, but these do not count towards the failure rate. This means the circuit will not open just by having too many calls time out while waiting for a slot.

@costela costela marked this pull request as ready for review October 11, 2023 16:35
limiter.go Outdated Show resolved Hide resolved
limiter.go Outdated Show resolved Hide resolved
hoglet.go Show resolved Hide resolved
Copy link
Member

@obitech obitech left a comment

Choose a reason for hiding this comment

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

LGTM

@costela costela merged commit 3e71eea into refactor-breaker-to-link-call-to-result Oct 27, 2023
1 check passed
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.

3 participants