Skip to content

Allow specifying timeouts for API requests #297

@azambon

Description

@azambon

Sometimes it happens that Contentful is used to serve contents that are not critical for a website, such as background images.
In these situations it would be preferrable to use short timeouts for these non-critical requests, so that a slow response from Contentful will not impair the operation of the whole website.

I'm aware that it is possible to specify a custom GuzzleHttp client (with a custom timeout value) in the ClientOptions, but that is quite cumbersome to change just one configuration option, and it only allows one to set a single, global timeout value for all requests that will use that client. Being able to specify a timeout value on a request-by-request basis would allow far more flexibility.

I was thinking of an options argument to be added to all Contentful\Delivery\Client\ClientInterface methods that involve API calls, with a default value of an empty array. When one specifies something in there, those values are merged with the underlying client option for just that request.
Of course changing the interface would be a BC break. Not for those who merely call the interface methods, but for everyone who implements it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions