fix: filter channels by protocol endpoint compatibility in routing#477
Conversation
|
@claude 检查提交的代码,使用中文回复 |
|
Claude finished @szl97's task —— View job 代码审查完成
代码审查结果总体来说,这次修改解决了一个重要的路由问题,实现质量良好。以下是详细的审查意见: ✅ 优点
|
830ae82 to
d280b00
Compare
|
@claude 已修复你所说的route方法潜在不一致问题,再次review |
|
Claude finished @Jiakaic's task —— View job 代码重新审查完成
代码审查结果非常好!您已经成功修复了我之前提到的方法一致性问题。以下是详细的审查意见: ✅ 修复确认问题已解决: 第二个 // 第252-256行:新增的端点兼容性过滤
List<ChannelDB> endpointMatched = Optional.ofNullable(channels)
.orElse(Collections.emptyList())
.stream()
.filter(channel -> adaptorManager.support(endpoint, channel.getProtocol()))
.collect(Collectors.toList());一致性达成: 两个 ✅ 实现优点
✅ 技术实现细节第239行方法的改进:
代码结构: channels → endpointMatched → filteredChannels → pickMaxPriority这个过滤链条逻辑清晰,每一步都有明确的职责。 ✅ 最佳实践
📝 建议 (可选优化)
总结🎉 修复质量: 优秀 这次修复完美解决了之前识别的问题,两个 |
d280b00 to
ab2884d
Compare
… singleton Refactor AdaptorManager to static singleton pattern to resolve circular dependency issue exposed by @lazy injection in previous commit. Problem: - Previous commit used @lazy to inject AdaptorManager into ChannelRouter - This exposed circular dependency: ChannelRouter → AdaptorManager ← ChannelService → ChannelRouter - @lazy is a workaround that masks the architectural issue - Inner layer (ChannelRouter) should not depend on outer context (AdaptorManager bean) Solution: - Convert AdaptorManager to static singleton pattern with getInstance() - Remove all Spring dependency injection for AdaptorManager in ChannelRouter and ChannelService - BellaAutoConf now initializes the singleton instead of creating new instance - Direct static access eliminates circular dependency without @lazy workaround Changes: - AdaptorManager: Add private constructor, static INSTANCE field, and getInstance() method - BellaAutoConf: Call AdaptorManager.getInstance() in @bean adaptorManager() - ChannelRouter: Remove @lazy @Autowired, use AdaptorManager.getInstance().support() - ChannelService: Remove @Autowired, use AdaptorManager.getInstance().support() Impact: - Eliminates circular dependency without workarounds - Minimal code changes (15 lines) - No new components or files added - Zero performance impact (still in-memory lookup) - AdaptorManager naturally fits singleton utility pattern 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ab2884d to
8fa802e
Compare
route时,过滤,仅选择endpoint适配的Adaptor
解决的问题:假设某厂商同模型既支持/v1/chat/completions和/v1/responses,此时会存在俩Adaptor的channelDB行记录,过滤选择endpoint匹配的channel
Add endpoint matching validation in ChannelRouter to prevent routing to incompatible protocol adaptors.
Problem:
Solution:
Changes:
Impact:
🤖 Generated with Claude Code