Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reduce connect timeout; increase logging

  • Loading branch information...
commit 79ee4ff847799686626bcaccb3985e4fcd85fcc7 1 parent 6b61031
@tmm1 authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 rmongo.rb
View
10 rmongo.rb
@@ -13,7 +13,7 @@ def initialize opts = {}
@id = 0
@responses = {}
@namespace = 'default.test'
- timeout 2
+ timeout 0.5
errback{
raise Error, 'could not connect to server'
}
@@ -35,19 +35,23 @@ def receive_data data
until @buf.empty?
# packet size
size = @buf.read(:int)
+ # log :size => size
break unless @buf.size >= size-4
# header
id, response, operation = @buf.read(:int, :int, :int)
+ # log :id => id, :response => response, :operation => operation
# body
reserved, cursor, start, num = @buf.read(:int, :longlong, :int, :int)
+ # log :reserved => reserved, :cursor => cursor, :start => start, :num => num
# bson results
results = (1..num).map do
@buf.read(:bson)
end
+ # log :results => results
if cb = @responses.delete(response)
cb.call(results)
@@ -95,6 +99,8 @@ def insert obj
:cstring, @namespace
# bson
buf.write :bson, obj
+
+ # log :execute_insert, obj
end
end
@@ -107,6 +113,8 @@ def remove obj
# bson
buf.write :bson, obj
+
+ # log :execute_remove, obj
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.