Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DependencyInjection] Addshuffle env processor#46883

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.2fromostrolucky:env-shuffle
Jul 10, 2022

Conversation

@ostrolucky
Copy link
Contributor

@ostroluckyostrolucky commentedJul 7, 2022
edited
Loading

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PRwaiting on approval of feature

Motivation of this: We are specifying list of hosts for Redis cluster as env var. The way redis library unfortunately works is that it always takes first host and tries to connect to it (and after initial connection is done successfully, only then jump to other nodes). This makes first host under load much more than others. This env var processor could be used to solve it and distribute the load better.

KvRae reacted with rocket emoji
Copy link
Contributor

@ro0NLro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

IIUC you could seedshuffle usingmt_srand in tests

ostrolucky and dmaicher reacted with thumbs up emojiostrolucky reacted with rocket emoji
@ostroluckyostroluckyforce-pushed theenv-shuffle branch 3 times, most recently from4c15709 tod18d383CompareJuly 8, 2022 07:34
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

works for me, here are some comments

@ostroluckyostroluckyforce-pushed theenv-shuffle branch 3 times, most recently from2caa9e5 toa921ed4CompareJuly 9, 2022 08:55
@94noni
Copy link
Contributor

Can/will this be chainable with the « env(csv:FOO) » env processor?
Like doing « env(shuffle:csv:FOO) »

@ostrolucky
Copy link
ContributorAuthor

of course

94noni reacted with thumbs up emoji

@fabpot
Copy link
Member

Thank you@ostrolucky.

}

if ('shuffle' ===$prefix) {
\is_array($env) ?shuffle($env) :thrownewRuntimeException(sprintf('Env var "%s" cannot be shuffled, expected array, got "%s".',$name,get_debug_type($env)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

IMHO this is "abusing" ternary, the more "classical"

if (!\is_array($env)) {thrownewRuntimeException(sprintf('Env var "%s" cannot be shuffled, expected array, got "%s".',$name,get_debug_type($env)));            }shuffle($env);

would be better

jvasseur and alamirault reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Subjective

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Indeed, hence "IMHO" 😉 but I can try "more objective" arguments:

  • it's not using the expression result (BTW: shuffle() always returns true [historically could also return false], and if designed today would probably be: void; andthrow wasn't usable as/in an expression before PHP 8.0)
  • it's inconsistent with all the rest of the file (even the general codebase)

Dunno if the CS tool could flag it?

@fabpotfabpot mentioned this pull requestOct 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@fabpotfabpotfabpot approved these changes

+2 more reviewers

@ro0NLro0NLro0NL left review comments

@guilliamxavierguilliamxavierguilliamxavier left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

7 participants

@ostrolucky@94noni@fabpot@nicolas-grekas@ro0NL@guilliamxavier@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp