relaxdb 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/relaxdb/net_http_server.rb +22 -5
- data/lib/relaxdb/server.rb +5 -0
- data/lib/relaxdb/taf2_curb_server.rb +4 -0
- metadata +3 -3
data/Rakefile
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
module RelaxDB
|
2
2
|
|
3
3
|
class Server
|
4
|
+
|
5
|
+
attr_reader :host, :port
|
4
6
|
|
5
7
|
def initialize(host, port)
|
6
8
|
@host = host
|
7
9
|
@port = port
|
8
10
|
end
|
9
|
-
|
11
|
+
|
12
|
+
def cx
|
13
|
+
unless @cx && @cx.active?
|
14
|
+
@cx = Net::HTTP.start(@host, @port)
|
15
|
+
end
|
16
|
+
@cx
|
17
|
+
end
|
18
|
+
|
19
|
+
def close_connection
|
20
|
+
@cx.finish if @cx
|
21
|
+
end
|
22
|
+
|
10
23
|
def delete(uri)
|
11
24
|
request(Net::HTTP::Delete.new(uri))
|
12
25
|
end
|
@@ -30,14 +43,18 @@ module RelaxDB
|
|
30
43
|
end
|
31
44
|
|
32
45
|
def request(req)
|
33
|
-
|
34
|
-
|
35
|
-
|
46
|
+
begin
|
47
|
+
res = cx.request(req)
|
48
|
+
rescue
|
49
|
+
@cx = nil
|
50
|
+
res = cx.request(req)
|
51
|
+
end
|
52
|
+
|
36
53
|
if (not res.kind_of?(Net::HTTPSuccess))
|
37
54
|
handle_error(req, res)
|
38
55
|
end
|
39
56
|
res
|
40
|
-
end
|
57
|
+
end
|
41
58
|
|
42
59
|
def to_s
|
43
60
|
"http://#{@host}:#{@port}/"
|
data/lib/relaxdb/server.rb
CHANGED
@@ -29,6 +29,11 @@ module RelaxDB
|
|
29
29
|
|
30
30
|
# URL encode slashes e.g. RelaxDB.delete_db "foo%2Fbar"
|
31
31
|
def delete_db(name)
|
32
|
+
# Close the http connection as CouchDB will keep a file handle to the db open
|
33
|
+
# if the http connection remains open - this will result in CouchDB throwing
|
34
|
+
# emfile errors after a significant number of databases are deleted.
|
35
|
+
@server.close_connection
|
36
|
+
|
32
37
|
@logger.info("Deleting database #{name}")
|
33
38
|
@server.delete("/#{name}")
|
34
39
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 2
|
9
|
+
version: 0.5.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Paul Carey
|
@@ -14,7 +14,7 @@ autorequire: relaxdb
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-13 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|