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

Improve throttler implementation #101

Open
gastonfournier opened this issue Jan 16, 2025 · 0 comments
Open

Improve throttler implementation #101

gastonfournier opened this issue Jan 16, 2025 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@gastonfournier
Copy link
Contributor

Describe the feature request

Currently, throttler exposes a lot of methods and requires the client to follow a protocol for it to work properly. Instead, throttler should just wrap the code you want to execute and handle skips internally.

If anyone feels like contributing this might be a good option

Background

No response

Solution suggestions

        return throttler.execute {
            Log.d(TAG, "Refreshing toggles")
            val response = doFetchToggles(ctx)
            fetcherHeartbeatFlow.emit(HeartbeatEvent(response.status, response.error?.message))
            return@execute response
        }.orElseGet {
            Log.i(TAG, "Skipping refresh toggles due to throttling")
            fetcherHeartbeatFlow.emit(HeartbeatEvent(Status.THROTTLED))
            return ToggleResponse(Status.THROTTLED)
        }

This is just a sketch to avoid having to do

but needs to be looked at in more detail.

@gastonfournier gastonfournier added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jan 16, 2025
@gastonfournier gastonfournier moved this from New to For later in Issues and PRs Jan 16, 2025
@gastonfournier gastonfournier changed the title Improve throttler Improve throttler implementation Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: For later
Development

No branches or pull requests

1 participant