-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Pr routing preference priority #1271
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
base: main
Are you sure you want to change the base?
Pr routing preference priority #1271
Conversation
Summary of ChangesHello @mci77777, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the authentication token routing capabilities by introducing a two-tiered selection process. It first allows for a configurable preference to determine which group of tokens (provider-based or credential-based) should be considered. Subsequently, within the chosen group, individual tokens can now be assigned a priority, enabling fine-grained control over their selection order. This provides greater flexibility and control for administrators in managing and optimizing token usage, ensuring that critical or preferred tokens are utilized effectively. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
此拉取请求为请求路由到不同凭证引入了一套复杂的优先级和偏好系统。它将路由配置重构为 preference 和 strategy 组件,并确保了与旧配置的向后兼容性。此外,还添加了用于管理认证文件优先级和路由偏好的新 API 端点。这些更改实现得很好,并为新逻辑添加了全面的测试。我的主要反馈是解决一些代码重复问题以提高可维护性。总的来说,这是对路由功能的一次坚实的增强。
| func parsePriorityValue(v any) (int, bool) { | ||
| switch raw := v.(type) { | ||
| case float64: | ||
| return int(raw), true | ||
| case int: | ||
| return raw, true | ||
| case int64: | ||
| return int(raw), true | ||
| case json.Number: | ||
| if n, err := raw.Int64(); err == nil { | ||
| return int(n), true | ||
| } | ||
| return 0, false | ||
| case string: | ||
| trimmed := strings.TrimSpace(raw) | ||
| if trimmed == "" { | ||
| return 0, false | ||
| } | ||
| n, err := strconv.Atoi(trimmed) | ||
| if err != nil { | ||
| return 0, false | ||
| } | ||
| return n, true | ||
| default: | ||
| return 0, false | ||
| } | ||
| } |
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.
sdk/auth/filestore.go
Outdated
| func parsePriorityValue(v any) (int, bool) { | ||
| switch raw := v.(type) { | ||
| case float64: | ||
| return int(raw), true | ||
| case int: | ||
| return raw, true | ||
| case int64: | ||
| return int(raw), true | ||
| case json.Number: | ||
| if n, err := raw.Int64(); err == nil { | ||
| return int(n), true | ||
| } | ||
| return 0, false | ||
| case string: | ||
| trimmed := strings.TrimSpace(raw) | ||
| if trimmed == "" { | ||
| return 0, false | ||
| } | ||
| n, err := strconv.Atoi(trimmed) | ||
| if err != nil { | ||
| return 0, false | ||
| } | ||
| return n, true | ||
| default: | ||
| return 0, false | ||
| } | ||
| } |
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.
| if index >= 2_147_483_640 { | ||
| index = 0 | ||
| } |
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.
优先级池子