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

Add Postgres adapter for socket communication #449

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

AndreyGoranov
Copy link
Contributor

@AndreyGoranov AndreyGoranov commented Feb 22, 2023

Since we have more than one server, we need this adapter as a way to notify all the servers of a specific event, so all the clients get notified.
For example, we receive a valid payment on only one server, and we need a way to notify all the users who might be connected to the other server.

@github-actions
Copy link

github-actions bot commented Feb 22, 2023

✅ Tests will run for this PR. Once they succeed it can be merged.

@igoychev igoychev added the run tests Allows running the tests workflows for forked repos label Feb 23, 2023
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Feb 23, 2023
@imilchev
Copy link
Contributor

Please provide context about why this is needed and what purpose does it serve

Copy link
Contributor

@imilchev imilchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to know more about this before it gets merged

@AndreyGoranov
Copy link
Contributor Author

Would like to know more about this before it gets merged

https://docs.nestjs.com/websockets/adapter
https://socket.io/docs/v4/postgres-adapter/

Comment on lines 26 to 30
CREATE TABLE IF NOT EXISTS socket_io_attachments (
id bigserial UNIQUE,
created_at timestamptz DEFAULT NOW(),
payload bytea
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tables normally should be created via schema.prisma instead of at runtime

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. I will change it, thanks!

@AndreyGoranov AndreyGoranov requested review from kachar and removed request for imilchev March 13, 2023 17:19
@igoychev igoychev added the run tests Allows running the tests workflows for forked repos label Apr 24, 2023
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Apr 24, 2023
@igoychev igoychev added the run tests Allows running the tests workflows for forked repos label Apr 24, 2023
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Apr 24, 2023
@sashko9807
Copy link
Member

If i correctly understood the socket.io adapter docs, this is only needed in cases when we want to emit messages across multiple server instances, which does not seem to be the case for us, at least for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants