bloomrb 0.0.2 → 0.0.3
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/lib/bloomrb.rb +21 -7
- metadata +17 -37
data/lib/bloomrb.rb
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
require 'socket'
|
2
2
|
|
3
3
|
class Bloomrb
|
4
|
-
attr_accessor :host, :port
|
4
|
+
attr_accessor :host, :port, :retries
|
5
5
|
|
6
|
-
def initialize(host = 'localhost', port = 8673)
|
7
|
-
self.host
|
8
|
-
self.port
|
6
|
+
def initialize(host = 'localhost', port = 8673, retries = 5)
|
7
|
+
self.host = host
|
8
|
+
self.port = port
|
9
|
+
self.retries = retries
|
9
10
|
end
|
10
11
|
|
11
12
|
def socket
|
12
13
|
@socket ||= TCPSocket.new(host, port)
|
13
14
|
end
|
14
15
|
|
16
|
+
def disconnect
|
17
|
+
@socket.close if @socket
|
18
|
+
@socket = nil
|
19
|
+
end
|
20
|
+
|
15
21
|
def filter(name)
|
16
22
|
BloomFilter.new(name, self)
|
17
23
|
end
|
@@ -48,14 +54,20 @@ class Bloomrb
|
|
48
54
|
end
|
49
55
|
|
50
56
|
def multi(filter, keys)
|
57
|
+
return Hash.new if keys.empty?
|
58
|
+
|
51
59
|
Hash[keys.zip(execute('m', filter, *keys).split(' ').map{|r| r == 'Yes'})]
|
52
60
|
end
|
53
|
-
|
61
|
+
|
54
62
|
def any?(filter, keys)
|
63
|
+
return false if keys.empty?
|
64
|
+
|
55
65
|
!!(execute('m', filter, *keys) =~ /Yes/)
|
56
66
|
end
|
57
67
|
|
58
68
|
def all?(filter, keys)
|
69
|
+
return true if keys.empty?
|
70
|
+
|
59
71
|
!!(execute('m', filter, *keys) !~ /No/)
|
60
72
|
end
|
61
73
|
|
@@ -64,6 +76,8 @@ class Bloomrb
|
|
64
76
|
end
|
65
77
|
|
66
78
|
def bulk(filter, keys)
|
79
|
+
return "" if keys.empty?
|
80
|
+
|
67
81
|
execute('b', filter, *keys)
|
68
82
|
end
|
69
83
|
|
@@ -88,7 +102,7 @@ class Bloomrb
|
|
88
102
|
begin
|
89
103
|
socket.puts(cmd)
|
90
104
|
result = socket.gets.chomp
|
91
|
-
|
105
|
+
raise "#{result}: #{cmd[0..99]}" if result =~ /^Client Error:/
|
92
106
|
|
93
107
|
if result == 'START'
|
94
108
|
result = []
|
@@ -98,7 +112,7 @@ class Bloomrb
|
|
98
112
|
end
|
99
113
|
result
|
100
114
|
rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::EPIPE
|
101
|
-
raise if (retry_count += 1) >=
|
115
|
+
raise if (retry_count += 1) >= retries
|
102
116
|
@socket = nil
|
103
117
|
sleep(1)
|
104
118
|
retry
|
metadata
CHANGED
@@ -1,65 +1,45 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bloomrb
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Simon Kroeger
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-10-11 00:00:00 Z
|
12
|
+
date: 2012-10-11 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description: Wraps the bloomd protocol for usage in ruby projects
|
22
15
|
email: simon.kroeger@sponsorpay.com
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
18
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
19
|
+
files:
|
30
20
|
- lib/bloomrb.rb
|
31
21
|
homepage: https://github.com/SponsorPay/bloomrb
|
32
22
|
licenses: []
|
33
|
-
|
34
23
|
post_install_message:
|
35
24
|
rdoc_options: []
|
36
|
-
|
37
|
-
require_paths:
|
25
|
+
require_paths:
|
38
26
|
- lib
|
39
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
- 0
|
47
|
-
version: "0"
|
48
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
34
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
segments:
|
55
|
-
- 0
|
56
|
-
version: "0"
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
57
39
|
requirements: []
|
58
|
-
|
59
40
|
rubyforge_project:
|
60
41
|
rubygems_version: 1.8.15
|
61
42
|
signing_key:
|
62
43
|
specification_version: 3
|
63
44
|
summary: Ruby client for bloomd
|
64
45
|
test_files: []
|
65
|
-
|