-
Notifications
You must be signed in to change notification settings - Fork 4
feat(sse): added ext/sse #59
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
Reviewer's Guide by SourceryThis pull request introduces the Sequence diagram for joining a client to the SSE serversequenceDiagram
participant Client
participant Server
participant Streamer
Client->>Server: Join(ctx, id, streamer)
Server->>Server: Lock()
Server->>Server: Check if client exists
alt Client exists
Server->>Client: Get existing client
else Client does not exist
Server->>Client: Create new client
Server->>Server: Store client
end
Server->>Client: Connect(ctx, streamer)
Client->>Streamer: Assign streamer
Server->>Streamer: Header().Set("Content-Type", "text/event-stream")
Server->>Streamer: Header().Set("Cache-Control", "no-cache")
Server->>Streamer: Header().Set("Connection", "keep-alive")
Server->>Server: Unlock()
Server-->>Client: Return client
Sequence diagram for broadcasting an event to all connected clientssequenceDiagram
participant Server
participant Client1
participant Client2
Server->>Server: RLock()
Server->>Server: Iterate through clients
loop For each client
Server->>Client1: Send(event)
Server->>Client2: Send(event)
end
Server->>Server: RUnlock()
Client1->>Client1: Marshal event data to JSON
Client1->>Streamer: Write event name and data
Client1->>Streamer: Flush()
Client2->>Client2: Marshal event data to JSON
Client2->>Streamer: Write event name and data
Client2->>Streamer: Flush()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Here's the code health analysis summary for commits Analysis Summary
|
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.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding an example usage to the package documentation.
- The
Wait
method on theClient
struct doesn't seem to do anything other than block until the context is done - is this intentional?
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
==========================================
- Coverage 94.27% 90.81% -3.46%
==========================================
Files 56 58 +2
Lines 2305 2363 +58
==========================================
- Hits 2173 2146 -27
- Misses 98 188 +90
+ Partials 34 29 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@sourcery-ai review |
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.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding an example usage to the package documentation.
- The
Client.Connect
method doesn't seem to do much - is it really needed?
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 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.
@sourcery-ai review |
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.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding an example of how to use the SSE server in a README or example file.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 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.
Changed
Fixed
Added
ext/sse
Tests
Tasks to complete before merging PR:
make unit-test
to check for any regressions 📋make lint
to check for any issuesSummary by Sourcery
Introduce
ext/sse
package for server-sent events (SSE) functionality.New Features:
ext/sse
package for server-sent events (SSE) functionality, includingServer
,Client
,Event
, andStreamer
interfaces.CI:
Tests: