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

Implemented ping support for Celluloid and EventMachine. #236

Merged
merged 6 commits into from Dec 22, 2018

Conversation

Projects
None yet
2 participants
@dblock
Copy link
Collaborator

dblock commented Oct 31, 2018

Closes #223

@RodneyU215 Want to code review this?

@dblock dblock force-pushed the dblock:em-celluloid-ping branch from 7f618f3 to 7c71e5c Oct 31, 2018

@RodneyU215

This comment has been minimized.

Copy link
Collaborator

RodneyU215 commented Oct 31, 2018

Celluloid and EventMachine need to ensure that the timers are canceled on disconnect. This prevents the connection from being reestablished when the user intentionally closes it. This was achieved for async-websocket by surfacing the #cancel method on @timers:

module Slack
  module RealTime
    module Concurrency
      module Async
        class Reactor < ::Async::Reactor
          def_delegators :@timers, :cancel
        end

        class Socket < Slack::RealTime::Socket
          def disconnect!
            super
            @reactor.cancel
          end
        end
      end
    end
  end
end
@RodneyU215

This comment has been minimized.

Copy link
Collaborator

RodneyU215 commented Oct 31, 2018

We also have to implement a #restart! method for both Celluloid and EventMachine. This method is responsible for updating web socket url to the new one and kicking off the run_loop again. Here's initial approach we took in async-websocket. Note: there's going to be a snag around how client is passed.

module Slack
  module RealTime
    module Concurrency
      module Async
        class Socket < Slack::RealTime::Socket
          def restart_async(client, new_url)
            @url = new_url
            @last_message_at = current_time
            return unless @reactor
            @reactor.async do
              client.run_loop
            end
          end
        end
      end
    end
  end
end
@dblock

This comment has been minimized.

Copy link
Collaborator Author

dblock commented Nov 1, 2018

Made some progress, but definitely could use help with the other TODOs, especially with proper tests that fail in Celluloid/EM and pass in async rn.

@dblock

This comment has been minimized.

Copy link
Collaborator Author

dblock commented Dec 10, 2018

@RodneyU215 if you want to help with this one, that'd be greatly appreciated, I won't have time for it for a while

@RodneyU215

This comment has been minimized.

Copy link
Collaborator

RodneyU215 commented Dec 11, 2018

Thanks for the nudge! I'll work on it this week.

RodneyU215 added some commits Dec 15, 2018

Implementing the restart method as well as updating the close method …
…so that EventMachine continues running until disconnect! is called.
@RodneyU215

This comment has been minimized.

Copy link
Collaborator

RodneyU215 commented Dec 15, 2018

Celluloid and EventMachine need to ensure that the timers are canceled on disconnect.

I tested this for EventMachine (via faye-websocket) and all timers are canceled when EventMachine.stop is called. I've not been able to find a comparable method in Celluloid however. Instead Celluloid continues to have an issue where the Actor crashes even after the main thread has been closed.

We also have to implement a #restart! method for both Celluloid and EventMachine.

I've implemented the #restart! method for EventMachine. You can find that PR here. I've not had much success with Celluloid, but can make another attempt in a few days.

Side note: celluloid-io appears to be unmaintained do we still want to continue to support it?

Merge pull request #1 from RodneyU215/em-celluloid-ping
Implementing restart_async for EventMachine
@dblock

This comment has been minimized.

Copy link
Collaborator Author

dblock commented Dec 16, 2018

@RodneyU215 I think we should at least try supporting celluloid. While unmaintained there's a slew of bots out there using it, including my own :)

I am going to merge this on green. How do I reproduce the problem with Celluloid?

@dblock dblock merged commit 407fd9f into slack-ruby:master Dec 22, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dblock

This comment has been minimized.

Copy link
Collaborator Author

dblock commented Dec 22, 2018

I merged this. Let's move from here.

@RodneyU215

This comment has been minimized.

Copy link
Collaborator

RodneyU215 commented Dec 22, 2018

@dblock Thanks for moving things forward. The issue with Celluloid surfaced by just running the integration tests. Starting tomorrow I'll have some free time over the next couple weeks to dig deeper into that issue.

@dblock dblock deleted the dblock:em-celluloid-ping branch Dec 27, 2018

@dblock

This comment has been minimized.

Copy link
Collaborator Author

dblock commented Jan 8, 2019

@RodneyU215 Could really use some help here so we can get the next release out, haven't had much time to deal with Celluloid and EM, but would be happy to test on some production bots. Integration tests seem to pass, so...

@RodneyU215

This comment has been minimized.

Copy link
Collaborator

RodneyU215 commented Jan 10, 2019

@dblock I believe EM is stable; I'm still working on verifying that Celluloid works as expected. I'm glad to hear that the integration tests are passing. This leads me to believe that it's likely an issue for me locally.

I've got a few other things to get through at work before Friday but I'll continue working on it this weekend and follow up by Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.