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 a pool for connections #93

Closed
wants to merge 1 commit into from

Conversation

vixez
Copy link
Contributor

@vixez vixez commented Oct 19, 2021

I needed a way to make requests run in a sequence, not parallel.
This is more explained in the issue here.

The changes here introduce a Pool, so you can limit the amount of active requests by setting maxActiveRequests.
By default this is 32, feel free to change this or skip the pool altogether if not set.

This code for example will make sure all requests, including for example retrieving a token in a RetryPolicy will run one by one.

return InterceptedClient.build(
    interceptors: [
        ApiLoggingInterceptor(),
        AuthenticationInterceptor(),
    ],
    requestTimeout: HTTP_TIMEOUT,
    retryPolicy: NewTokenRetryPolicy(),
    maxActiveRequests: 1,
);

To get a token in RetryPolicy I use a seperate InterceptedClient which is also limited to one request.

@CodingAleCR
Copy link
Owner

Hey, thanks for the contribution, I'll take a closer look soon, but in the meantime:

  • It would be nice to have this feature be optional, otherwise, it might interfere with current functionalities. Maybe it can be an approach like the one used by Felix Angelov in the bloc_concurrency package, but just some thoughts about it.
  • Maybe it would also be a good idea to update the README on this and add examples. This has been something that other users of the package have requested.

@vixez
Copy link
Contributor Author

vixez commented Oct 28, 2021

Improved PR: #96

@stale
Copy link

stale bot commented Dec 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 27, 2021
@stale stale bot closed this Jan 3, 2022
@CodingAleCR CodingAleCR reopened this Jan 6, 2022
@stale stale bot removed the wontfix This will not be worked on label Jan 6, 2022
@vixez vixez closed this Jan 10, 2022
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