-
Notifications
You must be signed in to change notification settings - Fork 12
Allow the user to configure the http client #72
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
base: main
Are you sure you want to change the base?
Conversation
Ik not a fan of this implementation. What is the options array. Nobody had a clue what could in there |
Sure, how about a |
Well internally it uses guzzle as client however it is plugable with any psr http client. What is the actual usecase to extend this config since the http client is not exposed and just for internal use |
Thanks! Our use-case simply put is that we require different timeouts based on the request context. Now, if we could effectively plug in our own instance of the http client, we can configure it as we want of course! I had another look but I see that |
@brecht-vermeersch what is your view |
I am not a fan of exposing all guzzle config. We should pick and choose the useful ones so we keep the freedom of switching the client in the future. The options should be an object instead of an array. I would add a config object for every client. BlobClientOptions, BlobContainerClientOptions, ... Each with a property called timeout |
I can certainly make that change. One thing though, does it really make sense to create a separate options object as you mentioned? All these classes instantiate the same type of |
Having a different options class per client gives us more flexibility in the future. We can add other client options independent of each other. In the client option classes we can have a shared class for http options. ex. readonly class BlockBlobClientOptions {
public __construct(
public ?string $someOptionOnlyForBlockBlobs = null,
public ?HttpClientOptions = null
) {}
}
readonly class BlobContainerClientOptions {
public __construct(
public ?HttpClientOptions = null
) {}
}
... other clients
readonly class HttpClientOptions {
public __construct(public ?int $timeout = null) {}
} |
This PR allows you to pass an array to configure the http client. We use this to control the timeout limit, for example.
The options array expects a
http
key:That way other options can be added later (like additional middleware, for example)
I wasn't immediately sure how to test for this change, and did not look into it any further. If you like to see some tests for this change and have any suggestions, please let me know :)