-
Notifications
You must be signed in to change notification settings - Fork 12
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
Swaps out the redis implementation for a different shard #48
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b4b5f9c
moving to a new redis shard. Fixes #46
jwoertink eb4019a
Ameba fixes
jwoertink ddd705c
Between each spec, when the server restarts, the subscribe socket see…
jwoertink 15391e9
testing to see how the CI reacts to this.
jwoertink 1366d8c
updates to redis 0.5.0 which fixes most of the spec issues.
jwoertink 2b88c1d
no need to call this restart a second time
jwoertink aba16b6
When redis dies, we lose the IO writer. Catch this so we can finish t…
jwoertink c2e500b
remove the connection from the key store when the connection is closed.
jwoertink 43dd234
merged master
jwoertink 6b11799
Moving the redis pinger logic so when the cable server shuts down, th…
jwoertink 7bf881f
applying commit changes from #54 to test in production
jwoertink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,19 +94,19 @@ describe Cable::Connection do | |
|
||
describe ".identified_by" do | ||
it "uses the right identifier name for it" do | ||
connect do |connection, socket| | ||
connect do |connection, _socket| | ||
connection.identifier.should eq("98") | ||
end | ||
|
||
connect(connection_class: ConnectionWithDifferentIndentifierTest) do |connection, socket| | ||
connect(connection_class: ConnectionWithDifferentIndentifierTest) do |connection, _socket| | ||
connection.identifier.should eq("98") | ||
end | ||
end | ||
end | ||
|
||
describe ".owned_by" do | ||
it "uses the right identifier name for it" do | ||
connect do |connection, socket| | ||
connect do |connection, _socket| | ||
connection.current_user.not_nil!.email.should eq("[email protected]") | ||
connection.organization.not_nil!.name.should eq("Acme Inc.") | ||
end | ||
|
@@ -478,7 +478,7 @@ def builds_request(token : String) | |
"Sec-WebSocket-Protocol" => "actioncable-v1-json, actioncable-unsupported", | ||
"Sec-WebSocket-Version" => "13", | ||
} | ||
request = HTTP::Request.new("GET", "#{Cable.settings.route}?test_token=#{token}", headers) | ||
HTTP::Request.new("GET", "#{Cable.settings.route}?test_token=#{token}", headers) | ||
end | ||
|
||
def builds_request(token : Nil) | ||
|
@@ -489,7 +489,7 @@ def builds_request(token : Nil) | |
"Sec-WebSocket-Protocol" => "actioncable-v1-json, actioncable-unsupported", | ||
"Sec-WebSocket-Version" => "13", | ||
} | ||
request = HTTP::Request.new("GET", "#{Cable.settings.route}", headers) | ||
HTTP::Request.new("GET", "#{Cable.settings.route}", headers) | ||
end | ||
|
||
private class DummySocket < HTTP::WebSocket | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Cable | ||
class RedisPinger | ||
private getter task : Tasker::Task | ||
|
||
def initialize(@server : Cable::Server) | ||
@task = Tasker.every(Cable.settings.redis_ping_interval) do | ||
check_redis_subscribe | ||
check_redis_publish | ||
rescue e | ||
# Restart cable if something happened | ||
Cable.restart | ||
end | ||
end | ||
|
||
def stop | ||
@task.cancel | ||
end | ||
|
||
# since @server.redis_subscribe connection is called on a block loop | ||
# we basically cannot call ping outside of the block | ||
# instead, we just spin up another new redis connection | ||
# then publish a special channel/message broadcast | ||
# the @server.redis_subscribe picks up this special combination | ||
# and calls ping on the block loop for us | ||
def check_redis_subscribe | ||
Cable.server.publish("_internal", "ping") | ||
end | ||
|
||
def check_redis_publish | ||
result = @server.redis_publish.run({"ping"}) | ||
Cable::Logger.debug { "Cable::RedisPinger.check_redis_publish -> #{result}" } | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In #54 @mjeffrey18 added the
socket.close
, but this rescue branch doesn't exist on master.... Should we be closing the socket here too? If so, then which CloseCode should be used?