siberite-client 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19cec6243d11d059f7bfad4a2702e46b969f9296
4
- data.tar.gz: dd21e35e459f5ab3216b64a8aca1c4ff345646cf
3
+ metadata.gz: f667417977971354ef3c6d06d2d9526f73960674
4
+ data.tar.gz: c70be62871788f345bef4a2d45d4980e73117b08
5
5
  SHA512:
6
- metadata.gz: 8e30ee5a79714a7fc193dc6c811104948a489f068ded661cb28c2ab5de317c1e0a53ed5ba8eb502cd70c2ebc739b45e794f33fcf082886a5f4c5be463db6397c
7
- data.tar.gz: 81ab9257eca26190fede54f31f9db721dad780161bf04d95fd3fe5bb63087bf7999188abd88e444425d0511a49f045bb0d3bd4e5b18cdeeeb69b2b895ac5b515
6
+ metadata.gz: 1c080b76344a9afe9611f052beb6b548cb8752e62d9461b95136355d11ba90992cb291c0301251a112fe87ea6595a9534c9453927ed25cef767d5b71f9b5ab07
7
+ data.tar.gz: 229b296a8f33d3ec558e1988645bf5ff63764ec86a7df98566c1d6b1a8b9048cd9956f00d541379ff45d8736bdbf37c49ded86a13d09e87b355b475a76f32fd5
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.2.0
6
+
7
+ before_install:
8
+ - wget https://github.com/bogdanovich/siberite/releases/download/v0.6/siberite-0.6-linux_x86_64.tgz -O /tmp/siberite.tar.gz
9
+ - tar -xvf /tmp/siberite.tar.gz && cd siberite*
10
+ - ./siberite > siberite.log 2>&1 &
11
+
12
+ install:
13
+ - bundle install
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![License][License-Image]][License-Url] [![Build][Build-Status-Image]][Build-Status-Url] [![Gem Version][Gem-Image]][Gem-Url]
1
2
  ## Talk to Siberite queue server from Ruby
2
3
 
3
4
  Siberite-client is a library that allows you to talk to a [Siberite](http://github.com/bogdanovich/siberite) queue server from ruby.
@@ -27,9 +28,23 @@ See the [rdoc for Memcached](http://blog.evanweaver.com/files/doc/fauna/memcache
27
28
  ```ruby
28
29
  require 'siberite'
29
30
 
30
- @queue = Siberite::Client.new('localhost:22133')
31
- @queue.set('a_queue', 'foo')
32
- @queue.get('a_queue') # => 'foo'
31
+ queue = Siberite::Client.new('localhost:22133')
32
+ queue.set('a_queue', 'foo')
33
+ queue.set('a_queue', 'bar')
34
+ queue.set('a_queue', 'baz')
35
+
36
+ queue.get('a_queue') # => 'foo'
37
+
38
+ # opens a reliable read
39
+ queue.get_open('a_queue') # => 'bar'
40
+ queue.get_close('a_queue')
41
+
42
+ # acknowledges previously opened read and opens a new one)
43
+ queue.get_close_open('a_queue') # => 'baz'
44
+
45
+ # raw format, skip marshalling
46
+ queue.set('a_queue', [1,2,3].to_json, 0, raw: true)
47
+ queue.get('a_queue', raw: true) # => "[1,2,3]"
33
48
  ```
34
49
 
35
50
  ## Client Proxies
@@ -37,13 +52,30 @@ require 'siberite'
37
52
  siberite-client comes with a number of decorators that change the behavior of the raw client.
38
53
 
39
54
  ```ruby
40
- @queue = Siberite::Client.new('localhost:22133')
41
- @queue.get('empty_queue') # => nil
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
55
+ client = Siberite::Client.new('localhost:22133')
56
+ client.get('empty_queue') # => nil
57
+
58
+ # Blocking client
59
+ queue = Siberite::Client::Blocking.new(client)
60
+ queue.get('empty_queue') # does not return until it pulls something from the queue
61
+
62
+ # Namespaced client
63
+ queue = Siberite::Client::Namespace.new('foo', client)
64
+ queue.set('work', 1) # adds message to foo:work queue
65
+
66
+ # Partitioned client
67
+ client_1 = Siberite::Client.new('siberite01.example.com:22133')
68
+ client_2 = Siberite::Client.new('siberite02.example.com:22133')
69
+ default_client = Siberite::Client.new('siberite03.example.com:22133')
70
+
71
+ client = Siberite::Client::Partitioning.new(
72
+ 'queue1' => client_1,
73
+ ['queue2', 'queue3'] => client_2,
74
+ default: default_client
75
+ )
45
76
  ```
46
77
 
78
+
47
79
  ## Configuration Management
48
80
 
49
81
  Siberite::Config provides some tools for pulling queue config out of a YAML config file.
@@ -52,7 +84,7 @@ Siberite::Config provides some tools for pulling queue config out of a YAML conf
52
84
  Siberite::Config.load 'path/to/siberite.yml'
53
85
  Siberite::Config.environment = 'production' # defaults to development
54
86
 
55
- @queue = Siberite::Config.new_client
87
+ queue = Siberite::Config.new_client
56
88
  ```
57
89
 
58
90
  This tells siberite-client to look for `path/to/siberite.yml`, and pull the client configuration out of
@@ -77,3 +109,10 @@ development:
77
109
  - localhost:22133
78
110
  show_backtraces: true
79
111
  ```
112
+
113
+ [License-Url]: http://opensource.org/licenses/Apache-2.0
114
+ [License-Image]: https://img.shields.io/hexpm/l/plug.svg
115
+ [Build-Status-Url]: https://travis-ci.org/bogdanovich/siberite-ruby
116
+ [Build-Status-Image]: https://travis-ci.org/bogdanovich/siberite-ruby.svg?branch=master
117
+ [Gem-Image]: https://badge.fury.io/rb/siberite-client.svg
118
+ [Gem-Url]: https://rubygems.org/gems/siberite-client
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ require 'rake'
5
5
  require 'rspec/core/rake_task'
6
6
 
7
7
  task :default => :spec
8
+ task :test => :spec
8
9
 
9
10
  desc "Run all specs in spec directory."
10
11
  RSpec::Core::RakeTask.new(:spec) do |t|
@@ -143,7 +143,23 @@ module Siberite
143
143
  end
144
144
 
145
145
  def peek(queue)
146
- get queue, :peek => true
146
+ get queue, peek: true
147
+ end
148
+
149
+ def get_open(queue)
150
+ get queue, open: true
151
+ end
152
+
153
+ def get_close(queue)
154
+ get_from_last queue, close: true
155
+ end
156
+
157
+ def get_close_open(queue)
158
+ get_from_last queue, close: true, open: true
159
+ end
160
+
161
+ def get_abort(queue)
162
+ get_from_last queue, abort: true
147
163
  end
148
164
 
149
165
  private
@@ -173,7 +189,7 @@ module Siberite
173
189
  end
174
190
 
175
191
  def extract_queue_commands(opts)
176
- commands = [:open, :close, :abort, :peek].select do |key|
192
+ commands = [:close, :open, :abort, :peek].select do |key|
177
193
  opts[key]
178
194
  end
179
195
 
@@ -1,3 +1,3 @@
1
1
  module Siberite
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -30,6 +30,6 @@ Gem::Specification.new do |s|
30
30
  s.add_development_dependency "rspec", "~> 3.2"
31
31
  s.add_development_dependency "rr", "~> 1.1"
32
32
  s.add_development_dependency "activesupport", "> 3.1"
33
- s.add_development_dependency "bundler", "~> 1.7"
33
+ s.add_development_dependency "bundler"
34
34
  s.add_development_dependency "rake", "~> 10.0"
35
35
  end
@@ -81,6 +81,51 @@ describe Siberite::Client do
81
81
  end
82
82
  end
83
83
 
84
+ describe "#get_open" do
85
+ it "opens a reliable read" do
86
+ @queue = "some_random_queue_#{Time.now.to_i}_#{rand(10000)}"
87
+ @client.set(@queue, "item_1")
88
+ @client.set(@queue, "item_2")
89
+ expect(@client.get_open(@queue)).to eq "item_1"
90
+ expect{ @client.get(@queue) }.to raise_error Memcached::ClientError
91
+ expect(@client.get_open(@queue)).to eq "item_1"
92
+ end
93
+ end
94
+
95
+ describe "#get_close" do
96
+ it "closes a reliable read" do
97
+ @queue = "some_random_queue_#{Time.now.to_i}_#{rand(10000)}"
98
+ @client.set(@queue, "item_1")
99
+ @client.set(@queue, "item_2")
100
+ expect(@client.get_open(@queue)).to eq "item_1"
101
+ expect{ @client.get_close(@queue) }.to_not raise_error
102
+ expect(@client.get_open(@queue)).to eq "item_2"
103
+ end
104
+ end
105
+
106
+ describe "#get_close_open" do
107
+ it "closes a reliable read" do
108
+ @queue = "some_random_queue_#{Time.now.to_i}_#{rand(10000)}"
109
+ @client.set(@queue, "item_1")
110
+ @client.set(@queue, "item_2")
111
+ expect(@client.get_open(@queue)).to eq "item_1"
112
+ expect{ @client.get(@queue) }.to raise_error Memcached::ClientError
113
+ expect(@client.get_open(@queue)).to eq "item_1"
114
+ expect(@client.get_close_open(@queue)).to eq "item_2"
115
+ end
116
+ end
117
+
118
+ describe "#get_abort" do
119
+ it "aborts a reliable read" do
120
+ @queue = "some_random_queue_#{Time.now.to_i}_#{rand(10000)}"
121
+ @client.set(@queue, "item_1")
122
+ @client.set(@queue, "item_2")
123
+ expect(@client.get_open(@queue)).to eq "item_1"
124
+ expect{ @client.get_abort(@queue) }.to_not raise_error
125
+ expect(@client.get(@queue)).to eq "item_1"
126
+ end
127
+ end
128
+
84
129
  describe "#with_retries" do
85
130
  it "retries a specified number of times" do
86
131
  mock(@client).set(anything, anything) { raise Memcached::SystemError }.times(6)
@@ -9,10 +9,12 @@ describe Siberite::Config do
9
9
  describe "load" do
10
10
  it "loads a yaml file" do
11
11
  Siberite::Config.config = nil
12
- lambda { Siberite::Config.default }.should raise_error
12
+ expect {
13
+ Siberite::Config.default
14
+ }.to raise_error Siberite::Config::ConfigNotLoaded
13
15
 
14
16
  Siberite::Config.load TEST_CONFIG_FILE
15
- lambda { Siberite::Config.default }.should_not raise_error
17
+ expect { Siberite::Config.default }.to_not raise_error
16
18
  end
17
19
  end
18
20
 
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.1
4
+ version: 0.9.0
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-24 00:00:00.000000000 Z
13
+ date: 2015-11-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: memcached
@@ -100,16 +100,16 @@ dependencies:
100
100
  name: bundler
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - '>='
104
104
  - !ruby/object:Gem::Version
105
- version: '1.7'
105
+ version: '0'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ~>
110
+ - - '>='
111
111
  - !ruby/object:Gem::Version
112
- version: '1.7'
112
+ version: '0'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rake
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +132,7 @@ extra_rdoc_files:
132
132
  - README.md
133
133
  files:
134
134
  - .gitignore
135
+ - .travis.yml
135
136
  - Gemfile
136
137
  - LICENSE
137
138
  - README.md