-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: chat room #64
feat: chat room #64
Conversation
Codecov Report
@@ Coverage Diff @@
## main #64 +/- ##
==========================================
+ Coverage 73.96% 79.90% +5.94%
==========================================
Files 212 52 -160
Lines 15447 1717 -13730
==========================================
- Hits 11425 1372 -10053
+ Misses 4022 345 -3677
|
10b31a8
to
b66ed25
Compare
This will have to go in after #63 |
9169dc1
to
d049326
Compare
I think, initially we should focus on doing chat via the GQL subscription model. Secondly, this design makes use of tokio's broadcast channels. This is great for a single instance application but if we scale this app our horizontally, instances of the application need to be able to receive the chat messages which are sent to other nodes in the cluster. The only realistic way to go about the 2nd point is to have an event emitting system. Currently we use postgres for a database. Postgres does support a pubsub model and can be used as a fanout event emitter. For postgres, as a pubsub I am not entirely sure of the performance around that. I know it is very nice because we can have events (such as updates, inserts, deletes) trigger pubsub so a simple query Redis, redis is very very battle tested and their pubsub is currently what powers 7tv event sub and we have never had any issues with the scalability of that (when it comes to the actual event sub, not the long lived connections) The disadvantage to redis is we will have to emit an event (on insert) manually. Also redis is unreliable (it does not care if anyone is listening to the event) in this case its fine because chat messages can be dropped and its not very important. Both are super strong cases. If postgres is performant enough I would opt to go for that. Perhaps as part of this ticket you could look at the relative performance of how postgres scales with subscriptions and triggers on inserts / updates / deletes ect. |
ecfd053
to
ab864c9
Compare
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.
very good start!
8f6103c
to
5d3fa70
Compare
Added chat functionality to the backend and frontend, enabling users to send and receive messages in real-time.
96bcfd0
to
0284620
Compare
Proposed changes
This PR adds chat functionality to the backend and frontend, enabling users to send and receive messages in real-time. The backend now uses a Redis pool to publish messages to channels and a single Redis connection to retrieve messages and pass them on to the user's subscription.
When a user enters a chat, they will send a subscription request to the server responsible for handling all messages for that chat. The max message length is 500 and the amount of messages that will be visible on the chat is 300.
Types of changes
What types of changes does your code introduce to Scuffle?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
Closes #39