When the websocket API is removed in Lemmy v0.18.0, how should applications that need constant updates about new posts, comments, etc., be designed? Should polling be used, or is there a better alternative? If not, how should it be done to minimize load on the servers? Thanks in advance!

  • terribleplan@lemmy.nrd.li
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    1 year ago

    As far as I can tell here are your options:

    1. Polling. The easiest answer, and probably the only if you don’t own your instance. I would suggest running your own server or at least coordinating with the admins of your server to minimize the impact since many instances are overloaded as it is.
    2. Proxy shenanigans with your own instance. You could probably implement something that sits in front of lemmy (or something your reverse proxy sends a copy of requests to) that would get federation messages and API calls in real-time. If done as a proxy this could even act as a filter for incoming messages if you wanted.
    3. Database shenanigans with your own instance. Assuming you have access to the DB of your instance you could set up logical replication and use something like pypgoutput to handle messages from the database showing every change to every table.
    4. Wait. Maybe at some point something like webhooks or writing events to some sort of message queue/stream will be added, which would be great for moderation tooling. If instances wanted to they could then provide this information over a websocket for consumers who want/need a real-time feed (ala pushshift) without even having to run on the same hardware as the lemmy instance itself.