siberite-client 0.8.0 → 0.8.1
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.
- checksums.yaml +4 -4
- data/README.md +52 -36
- data/lib/siberite/client.rb +2 -2
- data/lib/siberite/client/stats_helper.rb +1 -1
- data/lib/siberite/client/version.rb +1 -1
- data/spec/siberite/client_spec.rb +7 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19cec6243d11d059f7bfad4a2702e46b969f9296
|
4
|
+
data.tar.gz: dd21e35e459f5ab3216b64a8aca1c4ff345646cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e30ee5a79714a7fc193dc6c811104948a489f068ded661cb28c2ab5de317c1e0a53ed5ba8eb502cd70c2ebc739b45e794f33fcf082886a5f4c5be463db6397c
|
7
|
+
data.tar.gz: 81ab9257eca26190fede54f31f9db721dad780161bf04d95fd3fe5bb63087bf7999188abd88e444425d0511a49f045bb0d3bd4e5b18cdeeeb69b2b895ac5b515
|
data/README.md
CHANGED
@@ -1,63 +1,79 @@
|
|
1
|
-
##
|
2
|
-
|
3
|
-
siberite-client is a library that allows you to talk to a [Siberite](http://github.com/robey/siberite) queue server from ruby. As Siberite uses the memcache protocol, siberite-client is implemented as a wrapper around the memcached gem.
|
1
|
+
## Talk to Siberite queue server from Ruby
|
4
2
|
|
3
|
+
Siberite-client is a library that allows you to talk to a [Siberite](http://github.com/bogdanovich/siberite) queue server from ruby.
|
4
|
+
As Siberite uses the memcache protocol, siberite-client is implemented as a wrapper around the memcached gem.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
|
-
|
8
|
+
Add this line to your application's Gemfile:
|
9
9
|
|
10
|
-
|
10
|
+
```ruby
|
11
|
+
gem 'siberite-client'
|
12
|
+
```
|
11
13
|
|
14
|
+
And then execute:
|
12
15
|
|
13
|
-
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
14
19
|
|
15
|
-
|
20
|
+
$ gem install siberite-client
|
16
21
|
|
17
|
-
|
22
|
+
## Basic Usage
|
23
|
+
|
24
|
+
`Siberite::Client.new` takes a list of servers and an options hash.
|
25
|
+
See the [rdoc for Memcached](http://blog.evanweaver.com/files/doc/fauna/memcached/classes/Memcached.html) for an explanation of what the various options do.
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
$queue.get('a_queue') # => 'foo'
|
27
|
+
```ruby
|
28
|
+
require 'siberite'
|
22
29
|
|
30
|
+
@queue = Siberite::Client.new('localhost:22133')
|
31
|
+
@queue.set('a_queue', 'foo')
|
32
|
+
@queue.get('a_queue') # => 'foo'
|
33
|
+
```
|
23
34
|
|
24
35
|
## Client Proxies
|
25
36
|
|
26
37
|
siberite-client comes with a number of decorators that change the behavior of the raw client.
|
27
38
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
$queue = Siberite::Client::Blocking.new(Siberite::Client.new('localhost:22133'))
|
32
|
-
$queue.get('empty_queue') # does not return until it pulls something from the queue
|
39
|
+
```ruby
|
40
|
+
@queue = Siberite::Client.new('localhost:22133')
|
41
|
+
@queue.get('empty_queue') # => nil
|
33
42
|
|
43
|
+
@queue = Siberite::Client::Blocking.new(Siberite::Client.new('localhost:22133'))
|
44
|
+
@queue.get('empty_queue') # does not return until it pulls something from the queue
|
45
|
+
```
|
34
46
|
|
35
47
|
## Configuration Management
|
36
48
|
|
37
49
|
Siberite::Config provides some tools for pulling queue config out of a YAML config file.
|
38
50
|
|
39
|
-
|
40
|
-
|
51
|
+
```ruby
|
52
|
+
Siberite::Config.load 'path/to/siberite.yml'
|
53
|
+
Siberite::Config.environment = 'production' # defaults to development
|
41
54
|
|
42
|
-
|
55
|
+
@queue = Siberite::Config.new_client
|
56
|
+
```
|
43
57
|
|
44
58
|
This tells siberite-client to look for `path/to/siberite.yml`, and pull the client configuration out of
|
45
59
|
the 'production' key in that file. Sample config:
|
46
60
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
```yaml
|
62
|
+
defaults: &defaults
|
63
|
+
distribution: :random
|
64
|
+
timeout: 2
|
65
|
+
connect_timeout: 1
|
66
|
+
|
67
|
+
production:
|
68
|
+
<<: *defaults
|
69
|
+
servers:
|
70
|
+
- siberite01.example.com:22133
|
71
|
+
- siberite02.example.com:22133
|
72
|
+
- siberite03.example.com:22133
|
73
|
+
|
74
|
+
development:
|
75
|
+
<<: *defaults
|
76
|
+
servers:
|
77
|
+
- localhost:22133
|
78
|
+
show_backtraces: true
|
79
|
+
```
|
data/lib/siberite/client.rb
CHANGED
@@ -18,9 +18,9 @@ module Siberite
|
|
18
18
|
DEFAULT_OPTIONS = {
|
19
19
|
:retry_timeout => 0,
|
20
20
|
:exception_retry_limit => 5,
|
21
|
-
:timeout => 0
|
21
|
+
:timeout => 0,
|
22
22
|
:gets_per_server => 100,
|
23
|
-
:get_timeout_ms =>
|
23
|
+
:get_timeout_ms => false
|
24
24
|
}.freeze
|
25
25
|
|
26
26
|
# Exceptions which are connection failures we retry after
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Siberite::Client::StatsHelper
|
2
2
|
STATS_TIMEOUT = 3
|
3
|
-
QUEUE_STAT_NAMES = %w{items
|
3
|
+
QUEUE_STAT_NAMES = %w{items open_transactions}
|
4
4
|
|
5
5
|
def sizeof(queue)
|
6
6
|
stat_info = stat(queue)
|
@@ -19,14 +19,14 @@ describe Siberite::Client do
|
|
19
19
|
|
20
20
|
it "gets from the same server :gets_per_server times" do
|
21
21
|
client = @client.instance_variable_get(:@read_client)
|
22
|
-
mock(client).get("a_queue
|
22
|
+
mock(client).get("a_queue", true).times(102).returns('item')
|
23
23
|
|
24
24
|
102.times { @client.get("a_queue") }
|
25
25
|
end
|
26
26
|
|
27
27
|
it "gets from a different server when the last result was nil" do
|
28
28
|
client = @client.instance_variable_get(:@read_client)
|
29
|
-
mock(client).get("a_queue
|
29
|
+
mock(client).get("a_queue", true).returns(nil).twice
|
30
30
|
|
31
31
|
2.times { @client.get("a_queue") }
|
32
32
|
end
|
@@ -113,8 +113,8 @@ describe Siberite::Client do
|
|
113
113
|
@client.set("test-queue-name", 97)
|
114
114
|
|
115
115
|
stats = @client.stats
|
116
|
-
%w{uptime time version
|
117
|
-
cmd_get cmd_set
|
116
|
+
%w{uptime time version curr_connections total_connections
|
117
|
+
cmd_get cmd_set queues}.each do |stat|
|
118
118
|
stats[stat].should_not be_nil
|
119
119
|
end
|
120
120
|
|
@@ -133,7 +133,9 @@ describe Siberite::Client do
|
|
133
133
|
stub(@client).servers { [server] * 2 }
|
134
134
|
stats_for_two_servers = @client.stats
|
135
135
|
|
136
|
-
stats_for_two_servers['
|
136
|
+
expect(stats_for_two_servers['cmd_get']).to eq(
|
137
|
+
2 * stats_for_one_server['cmd_get']
|
138
|
+
)
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siberite-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Freels
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-11-
|
13
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: memcached
|