-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
events: Add basic downgradeable event queue support. #12926
base: main
Are you sure you want to change the base?
Conversation
Heads up @timabbott, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
Thanks @timabbott !
That re-organizing seems fine -- potentially helpful for the client, and certainly seems to enable some code reuse on the server. I'm curious if there's another difference there that potentially would be an interesting design point to discuss.
It looks like what the code does is let those messages queue up just as usual. That certainly means that when they refer to a message the client already has, the client will handle them as usual once it sees them. But it'll also be the case that some
That's likely best as an opt-in flag on the |
I think the risk of this data structure approach is that it's only good for updating the To do that well, we'd likely need to improve the data structure we currently have (with message_id -> stream/topic data) to be a more robust structure with pointers in both directions so that we can inexpensively maintain for a stream/topic pair whether it's been invalidated. Probably wouldn't be hard to do as an extension to the format here by just adding additional keys in the output format, so maybe it doesn't impact the design. (I think it's OK if we invalidate cached narrows for views that had a message added and then moved by editing, or something). So I think you're right that we should just have this code handle update_message as well. Do you think if we did that tweak, this would provide the app with all the information it'd need about messages it missed? To summarize, we'd have:
One thing that's on my mind is how to write tests for the client-side logic required, since I think it'd be really painful to be trying to track down bugs in the client-side handling of this manually. One model would be to do a reference implementation of the
For the
Agreed. In terms of a path forward for this PR, I think it's more or less mergable to make it easy to do mobile development against chat.zulip.org for working on this. (And to avoid merge conflicts, etc.). The main risk with doing so is that this could end up in a release with buggy internals or a bad interface, making us do more annoying feature-detection for future app usage. So I'd want to tweak this to have the server allowing the queue to be setup this way sit behind a feature-flag that we only enable in development and on chat.zulip.org. |
4ec3636
to
88b200c
Compare
This PR is a prototype implementation of downgradeable event queues, for use by the mobile app.
The model is that if a client includes in its /register request
downgradeable=true
, we will generate a downgradeable event queue. Afterqueue_lifespan_secs
of inactivity (and a GC run), the queue will be automatically downgraded to stop tracking high traffic events, which is currently:It instead just keeps the data from those message events required to, should the client return, add a special event to the queue of type
unread_data
containing a JSON structure in the same format as theunread_msgs
part of/register
, reusing the functions originally written to manage those. The client is expected to:unread_msgs
event to its data structures tracking unread messages. Right now this should mostly work (though the client is responsible for dealing with muted streams+topics, and I haven't implemented unread mention tracking yet).@gnprice I'd love your feedback on this.