-
Notifications
You must be signed in to change notification settings - Fork 331
[Bug] avoid frequent lookup of the routing strategy env #956
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
Conversation
pkg/plugins/gateway/util.go
Outdated
@@ -50,30 +50,20 @@ func validateStreamOptions(requestID string, user utils.User, jsonMap map[string | |||
return nil | |||
} | |||
|
|||
var defaultRoutingStrategy, defaultRoutingStrategyEnabled = utils.CheckEnvExists(EnvRoutingAlgorithm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CheckEnvExists
doesn't seem like the best name. Maybe rename it to LookupEnv
or just use os.LookupEnv directly?
Lines 33 to 38 in 6c32582
// CheckEnvExists checks if an environment variable exists. | |
// It returns the value and a boolean indicating its existence. | |
func CheckEnvExists(envVar string) (string, bool) { | |
value, exists := os.LookupEnv(envVar) | |
return value, exists | |
} |
@Jeffwan What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, rename it to LookupEnv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good.
The failed ci is not related to the modification of this pr. |
Overall look good. |
it's a little bit weird that build jobs are either canceled or skipped.. |
49ee732
to
3b016de
Compare
Signed-off-by: Iceber Gu <[email protected]>
3b016de
to
f3bd5c8
Compare
@varungup90 Did the PR pass the CI earlier or just skipped the test? the main branch test failed again. |
First time when you commented on the PR for CI failures, at that time I manually restarted the failed jobs and they succeeded. When the PR was updated with method rename, all CI job succeeded so I merged (initially also failures were not related to PR). After PR merged, there were failures again that you brought to my attention. |
@varungup90 yeah, this is kind of weird, all parallel CI jobs yesterday pass and seems my current fix doesn't help as well. I tried to build locally but I can not reproduce the issue, probably due to some arch diffs. I will spend some time later on this. If you did see they succeeded, it's probably due to other cache issues. |
Pull Request Description
[Please provide a clear and concise description of your changes here]
There's no need to check the environment variables every time a request is processed.
Related Issues
Resolves: #[Insert issue number(s)]
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]
: Corrections to existing functionality[CI]
: Changes to build process or CI pipeline[Docs]
: Updates or additions to documentation[API]
: Modifications to aibrix's API or interface[CLI]
: Changes or additions to the Command Line Interface[Misc]
: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.