Skip to content

Commit

Permalink
node: define a default request timeout parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
niamster committed Mar 22, 2015
1 parent b9f3bc6 commit b4d24e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/dcell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ def setup(options = {})
@lock.synchronize do
configuration = {
addr: "tcp://127.0.0.1:*",
heartbeat_rate: 5,
heartbeat_timeout: 10,
ttl_rate: 20,
heartbeat_rate: 5, # How often to send heartbeats in seconds
heartbeat_timeout: 10, # How soon until a lost heartbeat triggers a node partition
request_timeout: 10, # Timeout on waiting for the response
ttl_rate: 20, # How often update TTL in the registry
id: nil,
}.merge(options)
configuration_accessors configuration
Expand Down
9 changes: 5 additions & 4 deletions lib/dcell/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def initialize(id, addr, server=false)
@remote_dead = false
@leech = false

@heartbeat_rate = DCell.heartbeat_rate # How often to send heartbeats in seconds
@heartbeat_timeout = DCell.heartbeat_timeout # How soon until a lost heartbeat triggers a node partition
@ttl_rate = DCell.ttl_rate # How often update TTL in the registry
@heartbeat_rate = DCell.heartbeat_rate
@heartbeat_timeout = DCell.heartbeat_timeout
@request_timeout = DCell.request_timeout
@ttl_rate = DCell.ttl_rate

if server
update_ttl
Expand Down Expand Up @@ -173,7 +174,7 @@ def send_message(message, pipe=:request)
end

# Send request and wait for response
def push_request(request, pipe=:request, timeout=nil)
def push_request(request, pipe=:request, timeout=@request_timeout)
send_message request, pipe
save_request request
response = receive(timeout) do |msg|
Expand Down

0 comments on commit b4d24e6

Please sign in to comment.