-
Notifications
You must be signed in to change notification settings - Fork 371
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
Expose a way to switch from one cluster/app to the other #773
Expose a way to switch from one cluster/app to the other #773
Conversation
e913a73
to
2e8aaf3
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.
Thanks for the PR @kamalbennani. I've added some comments pointing at necessary changes for the pusher
object to be fully functional after switchCluster
is called.
I think this PR needs unit testing to verify that all functionalities are working after |
Hi @MeenaAlfons Thanks for the review, I've pushed a commit to resolve all your comments. |
65ee4b3
to
819be76
Compare
Hi @MeenaAlfons, the PR is ready for another round of review. |
Hi @MeenaAlfons, would you mind reviewing the PR a second time, highly appreciate it! |
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.
Sorry for the late reply.
Upon running tests I got some errors:
1) Pusher after connecting switch cluster should resubscribe to all channels
- TypeError: this.connection.switchCluster is not a function
2) Pusher after connecting switch cluster should send events via the connection manager
- TypeError: this.connection.switchCluster is not a function
In general, I think the current tests try to mock the behavior or reconnecting by manually calling pusher.connect()
and pusher.connection.state = 'connected'
, etc. This is not helpful when testing switchCluster
because the expected behaviour we'd like to test is that the connection will be disconnected and reconnected including all the side effects of reconnection like reinitiating channel authorization and user authentication.
It would be nice if you can make such tests. I could be able to help but it will depend on my availability.
819be76
to
83f4db8
Compare
Hi @MeenaAlfons, I pushed some missing changes which would make the tests pass! sorry for that. Regarding your comment, I agree with you in theory, and I'd like to know how those tests are done today when a network switch happens, as it's the same logic that is done here. If that's not cover, I'd prefer if this could be managed by yourself or a pusher member in phase 2 if that's fine with you? Thanks. |
Hi @kamalbennani, I've changed the base branch to I still don't know when I'll be able to come around to check what needs to be done for tests to cover these changes. I think a release candidate may unblock you. Thank you. |
What does this PR do?
This PR introduces a way to tell Pusher client to switch the traffic from one cluster/app to the other.
This is super useful especially in case where Pusher is experiencing some outages allowing you to switch the traffic to a stable cluster without having to deal with resubscribing yourself all the channels and bind all the callbacks to the right events.
Usage
Checklist
npm run format
has been runCHANGELOG
.switchCluster
method to switch the Pusher client to a different cluster and re-establish all existing subscriptions and channel bindings.