Skip to content
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

Create NodeJS Worker for Discord Communication #5

Open
crutchcorn opened this issue Jan 26, 2025 · 2 comments
Open

Create NodeJS Worker for Discord Communication #5

crutchcorn opened this issue Jan 26, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@crutchcorn
Copy link
Member

As we're looking to add Discord communication to our server to do SSR, we need to:

Related code: playfulprogramming/playfulprogramming#1241
Related issue: #3

@crutchcorn crutchcorn added the enhancement New feature or request label Jan 26, 2025
@fennifith
Copy link
Member

Need to decide if this should be event-driven or not (e.g. if we want new messages shown immediately, or to be updated after a delay)

Possible solution, if this is event-driven:

  • "discord bot" package that runs as its own Fly service (to only run one machine at a time)
  • Runs a websocket server that accepts connections directly from astro/SSR
  • Keep track of recent messages for each channel in-memory
  • When a message is received, update recent messages and send a message to each socket connection
  • When a new client connects (e.g. if astro SSR is restarted), resend all stored messages
  • Frontend: when the websocket connection receives new messages, store them and use for any future SSR renders

If this is not event-driven:

  • Create a worker task that intermittently imports recent messages into the db
  • Create a GET /discord/[channel]/recent_messages endpoint to retrieve those messages
  • Frontend: call the recent_messages endpoint and cache the results between SSR renders

@crutchcorn
Copy link
Member Author

IMO this shouldn't be event driven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants