-
Notifications
You must be signed in to change notification settings - Fork 223
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
HTTP SSE 消息上报模式 #701
HTTP SSE 消息上报模式 #701
Conversation
审阅者指南 by Sourcery该拉取请求实现了一种新的 HTTP SSE 消息报告模式,作为现有 HTTP 客户端反向连接方法的替代方案。它引入了一个新的 "httpSseServers" 连接器配置,类似于 "httpServers" 配置,并增加了 "reportSelfMessage" 选项。实现包括处理 SSE 连接、事件分发以及与现有 OneBot 组件的集成。 HTTP SSE 消息报告流程的序列图sequenceDiagram
participant Client as SSE Client
participant Server as HTTP SSE Server
participant Adapter as OB11ActiveHttpSSEAdapter
participant Core as NapCat Core
Client->>Server: GET /_events
Server->>Adapter: createSseSupport()
Adapter->>Client: Establish SSE Connection
Note over Adapter: Add client to sseClients[]
loop Event Emission
Core->>Adapter: onEvent(event)
loop For each connected client
Adapter->>Client: Send SSE event data
end
end
Client-->>Adapter: Connection closed
Note over Adapter: Remove client from sseClients[]
HTTP SSE 实现的类图classDiagram
class IOB11NetworkAdapter {
<<interface>>
+onEvent(event)
}
class OB11PassiveHttpAdapter {
+handleRequest(req, res)
+onEvent(event)
}
class OB11ActiveHttpSSEAdapter {
-sseClients: Response[]
+handleRequest(req, res)
+onEvent(event)
-createSseSupport(req, res)
}
class HttpSseServerConfig {
+name: string
+enable: boolean
+reportSelfMessage: boolean
}
IOB11NetworkAdapter <|-- OB11PassiveHttpAdapter
OB11PassiveHttpAdapter <|-- OB11ActiveHttpSSEAdapter
OB11ActiveHttpSSEAdapter ..> HttpSseServerConfig : uses
文件级变更
提示和命令与 Sourcery 交互
自定义您的体验访问您的仪表板以:
获取帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request implements a new HTTP SSE message reporting mode as an alternative to the existing HTTP client reverse connection method. It introduces a new "httpSseServers" connector configuration, similar to the "httpServers" configuration, with an additional "reportSelfMessage" option. The implementation includes handling SSE connections, event dispatching, and integration with existing OneBot components. Sequence diagram for HTTP SSE message reporting flowsequenceDiagram
participant Client as SSE Client
participant Server as HTTP SSE Server
participant Adapter as OB11ActiveHttpSSEAdapter
participant Core as NapCat Core
Client->>Server: GET /_events
Server->>Adapter: createSseSupport()
Adapter->>Client: Establish SSE Connection
Note over Adapter: Add client to sseClients[]
loop Event Emission
Core->>Adapter: onEvent(event)
loop For each connected client
Adapter->>Client: Send SSE event data
end
end
Client-->>Adapter: Connection closed
Note over Adapter: Remove client from sseClients[]
Class diagram for HTTP SSE implementationclassDiagram
class IOB11NetworkAdapter {
<<interface>>
+onEvent(event)
}
class OB11PassiveHttpAdapter {
+handleRequest(req, res)
+onEvent(event)
}
class OB11ActiveHttpSSEAdapter {
-sseClients: Response[]
+handleRequest(req, res)
+onEvent(event)
-createSseSupport(req, res)
}
class HttpSseServerConfig {
+name: string
+enable: boolean
+reportSelfMessage: boolean
}
IOB11NetworkAdapter <|-- OB11PassiveHttpAdapter
OB11PassiveHttpAdapter <|-- OB11ActiveHttpSSEAdapter
OB11ActiveHttpSSEAdapter ..> HttpSseServerConfig : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
嘿 @Stapxs - 我已经审查了你的更改并发现了一些需要解决的问题。
阻塞性问题:
- HTTP 方法比较应该使用大写的 'GET'(链接)
整体评论:
- 考虑为 SSE 客户端实施最大连接限制,以防止无界连接可能导致的内存问题
- 为 SSE 写入操作添加错误处理,以优雅地处理写入失败并防止影响其他客户端连接
以下是我在审查期间关注的内容
- 🔴 一般性问题:1 个阻塞性问题,1 个其他问题
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English
Hey @Stapxs - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- HTTP method comparison should use uppercase 'GET' (link)
Overall Comments:
- Consider implementing a maximum limit for SSE clients to prevent potential memory issues with unbounded connections
- Add error handling for SSE write operations to gracefully handle failed writes and prevent affecting other client connections
Here's what I looked at during the review
- 🔴 General issues: 1 blocking issue, 1 other issue
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Quality Gate passedIssues Measures |
支持使用更轻量的 http sse 进行消息上报,作为 http client 反向连接的可选替代品。
新增连接器:httpSseServers
配置文件继承自 httpServers,增加 reportSelfMessage 配置:
Summary by Sourcery
新功能:
Original summary in English
Summary by Sourcery
New Features: