Skip to content

[5.8] Adds the ability to set the reconnector created by a DatabaseManager.#27845

Merged
taylorotwell merged 2 commits into
laravel:5.8from
iainconnor:5.8
Mar 13, 2019
Merged

[5.8] Adds the ability to set the reconnector created by a DatabaseManager.#27845
taylorotwell merged 2 commits into
laravel:5.8from
iainconnor:5.8

Conversation

@iainconnor

@iainconnor iainconnor commented Mar 10, 2019

Copy link
Copy Markdown
Contributor

Implements laravel/ideas#1557.

Our current use-case for wanting to customize the reconnector is wanting to add a "maximum retries" setting. When experiencing some edge-case database issues, they were exacerbated by the default reconnector "infinitely" trying to reconnect (infinitely in quotes because eventually something times out, but still has the tendency to turn a minor blip into a feedback loop).

@GrahamCampbell GrahamCampbell changed the title #1557 Adds the ability to set the reconnector created by a DatabaseManager. [5.8] Adds the ability to set the reconnector created by a DatabaseManager. Mar 11, 2019
@taylorotwell

taylorotwell commented Mar 12, 2019

Copy link
Copy Markdown
Member

So, in a service provider, what prevents you from doing something like: DB::connection('foo')->setReconnector($reconnector)... that method is already public? Maybe even something like this in a boot method of a service provider so it's only run when the DB manager is actually resolved (it's bound as "db" in the container):

$this->app->resolved('db', function ($db) {
    $db->connection('foo')->setReconnector(fn);
});

@iainconnor

Copy link
Copy Markdown
Contributor Author

I have multiple connections, so I'd need to iterate through (and configure) all of them in this block of code, when any given request may not actually utilize (and thus not have to configure) those connections.

Yes, the overhead of the configuration is (relatively) minor, but still unnecessary until I actually need to perform a query against the Db.

@taylorotwell taylorotwell merged commit 8fd4a19 into laravel:5.8 Mar 13, 2019
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