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: method ->withTimeout(secs) #220

Closed
1 task done
aagjalpankaj opened this issue Jul 25, 2024 · 2 comments · Fixed by #221
Closed
1 task done

Feat: method ->withTimeout(secs) #220

aagjalpankaj opened this issue Jul 25, 2024 · 2 comments · Fixed by #221
Assignees

Comments

@aagjalpankaj
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the new feature

Sometimes our self-hosted gitlab is unreachable due to some maintenance activities. In that case, it takes more than 1 min to return the cached value or the default value. Can we add method ->withTimeout(secs)?

Is your feature request related to a problem? (optional)

Sometimes our self-hosted gitlab is unreachable due to some maintenance activities. In that case, it takes more than 1 min to return the cached value or the default value.

Describe alternatives you've considered (optional)

set_time_limit

Additional context (optional)

No response

@RikudouSage
Copy link
Collaborator

There's no unified way to set a timeout for the PSR http client abstraction (at least I don't know of any), that needs to be done in the http client you use.

For guzzle you can do it like this:

    $httpClient = new Client([
        RequestOptions::TIMEOUT => 2,
    ]);

For Symfony like this:

    $httpClient = HttpClient::create([
        'timeout' => 2,
    ]);
    $httpClient = new Psr18Client($httpClient);

If you use a different http client, there's probably a way to set a default timeout.

Then you do it like this:

$unleash = UnleashBuilder::create()
    ->withAppName($appName)
    ->withAppUrl($appUrl)
    ->withInstanceId($instanceId)
    ->withHttpClient($httpClient) // <-- this is the important part
    ->build()
;

@RikudouSage
Copy link
Collaborator

I've added it as an example in #221

@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Jul 25, 2024
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 a pull request may close this issue.

2 participants