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

Adds optional $config parameter to API instance constructor #51

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

vedmaka
Copy link

@vedmaka vedmaka commented Nov 20, 2022

The change adds optional $config parameter to MediaWiki instance constructor. With the optional $config param it's not possible to supply internal Guzzle client with extra parameters [1] like timeout and connect_timeout.

Additionally there is a special noretry flag added to be processed by MiddlewareFactory to allow to disable 5x retries which are enabled by default.

For example:

$api = MediaWiki::newFromEndpoint( 'https://mywiki.com', null, [
    'timeout' => 60,
    'connect_timeout' => 30,
    'noretry' => true
] );

@vedmaka vedmaka marked this pull request as ready for review November 20, 2022 21:46
@DanielWTQ
Copy link

@addshore @JeroenDeDauw would you mind taking a look at this?

@samwilson
Copy link
Member

It seems like it might be better to inject a whole $client object, rather than just the config. e.g.:

$clientFactory = new ClientFactory( [
	'timeout' => 60,
	'connect_timeout' => 30,
	'noretry' => true
] );
$api = MediaWiki::newFromPage( 'http://example.org', null, $clientFactory->getClient() );

Or, what if instead the client in an ActionApi object could be changed after instantiation? e.g.:

$api = MediaWiki::newFromPage( 'http://example.org' );
$clientFactory = new ClientFactory( [
	'timeout' => 60,
	'connect_timeout' => 30,
	'noretry' => true
] );
$api->setClient( $clientFactory->getClient() );

@DanielWTQ
Copy link

It seems like it might be better to inject a whole $client object, rather than just the config

Given how long this patch has been sitting without review, would it be possible to merge the current feature, and then do further improvements from there?

@samwilson
Copy link
Member

If this was merged there wouldn't be any point in adding a different way, I think (because we'd still want to keep it backwards compatible and so would just end up with two ways to pass in the Guzzle config). @addshore is the main maintainer here, it's up to him.

I think being able to inject a different client would be more flexible, e.g. when integrating this package into an existing application.

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.

3 participants