kestrel-client 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,16 +1,81 @@
1
- # kestrel-client: Talk to Kestrel queue server from Ruby
1
+ ## kestrel-client: Talk to Kestrel queue server from Ruby
2
+
3
+ kestrel-client is a library that allows you to talk to a [Kestrel](http://github.com/robey/kestrel) queue server from ruby. As Kestrel uses the memcache protocol, kestrel-client is implemented as a wrapper around the memcached gem.
4
+
5
+
6
+ ## Installation
7
+
8
+ you will need to install memcached.gem, though rubygems should do this for you. just:
9
+
10
+ sudo gem install kestrel-client
11
+
12
+
13
+ ## Basic Usage
14
+
15
+ `Kestrel::Client.new` takes a list of servers and an options hash. 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.
16
+
17
+ require 'kestrel'
18
+
19
+ $queue = Kestrel::Client.new('localhost:22133')
20
+ $queue.set('a_queue', 'foo')
21
+ $queue.get('a_queue') # => 'foo'
22
+
23
+
24
+ ## Client Proxies
25
+
26
+ kestrel-client comes with a number of decorators that change the behavior of the raw client.
27
+
28
+ $queue = Kestrel::Client.new('localhost:22133')
29
+ $queue.get('empty_queue') # => nil
30
+
31
+ $queue = Kestrel::Client::Blocking.new(Kestrel::Client.new('localhost:22133'))
32
+ $queue.get('empty_queue') # does not return until it pulls something from the queue
33
+
34
+
35
+ ## Configuration Management
36
+
37
+ Kestrel::Config provides some tools for pulling queue config out of a YAML config file.
38
+
39
+ Kestrel::Config.load 'path/to/kestrel.yml'
40
+ Kestrel::Config.environment = 'production' # defaults to development
41
+
42
+ $queue = Kestrel::Config.new_client
43
+
44
+ This tells kestrel-client to look for `path/to/kestrel.yml`, and pull the client configuration out of
45
+ the 'production' key in that file. Sample config:
46
+
47
+ defaults: &defaults
48
+ distribution: :random
49
+ timeout: 2
50
+ connect_timeout: 1
51
+
52
+ production:
53
+ <<: *defaults
54
+ servers:
55
+ - kestrel01.example.com:22133
56
+ - kestrel02.example.com:22133
57
+ - kestrel03.example.com:22133
58
+
59
+ development:
60
+ <<: *defaults
61
+ servers:
62
+ - localhost:22133
63
+ show_backtraces: true
64
+
65
+
66
+ ## License
2
67
 
3
68
  Copyright 2010 Twitter, Inc.
4
69
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
70
+ Licensed under the Apache License, Version 2.0 (the "License");
71
+ you may not use this file except in compliance with the License.
72
+ You may obtain a copy of the License at
8
73
 
9
- http://www.apache.org/licenses/LICENSE-2.0
74
+ http://www.apache.org/licenses/LICENSE-2.0
10
75
 
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
76
+ Unless required by applicable law or agreed to in writing, software
77
+ distributed under the License is distributed on an "AS IS" BASIS,
78
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79
+ See the License for the specific language governing permissions and
80
+ limitations under the License.
16
81
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kestrel-client}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Freels", "Rael Dornfest"]
12
- s.date = %q{2010-02-11}
12
+ s.date = %q{2010-02-12}
13
13
  s.description = %q{Ruby client for the Kestrel queue server}
14
14
  s.email = %q{rael@twitter.com}
15
15
  s.extra_rdoc_files = [
@@ -27,12 +27,14 @@ Gem::Specification.new do |s|
27
27
  "lib/kestrel/client/blocking.rb",
28
28
  "lib/kestrel/client/envelope.rb",
29
29
  "lib/kestrel/client/json.rb",
30
+ "lib/kestrel/client/namespace.rb",
30
31
  "lib/kestrel/client/proxy.rb",
31
32
  "lib/kestrel/client/unmarshal.rb",
32
33
  "lib/kestrel/config.rb",
33
34
  "spec/kestrel/client/blocking_spec.rb",
34
35
  "spec/kestrel/client/envelope_spec.rb",
35
36
  "spec/kestrel/client/json_spec.rb",
37
+ "spec/kestrel/client/namespace_spec.rb",
36
38
  "spec/kestrel/client/unmarshal_spec.rb",
37
39
  "spec/kestrel/client_spec.rb",
38
40
  "spec/kestrel/config/kestrel.yml",
@@ -49,6 +51,7 @@ Gem::Specification.new do |s|
49
51
  "spec/kestrel/client/blocking_spec.rb",
50
52
  "spec/kestrel/client/envelope_spec.rb",
51
53
  "spec/kestrel/client/json_spec.rb",
54
+ "spec/kestrel/client/namespace_spec.rb",
52
55
  "spec/kestrel/client/unmarshal_spec.rb",
53
56
  "spec/kestrel/client_spec.rb",
54
57
  "spec/kestrel/config_spec.rb",
data/lib/kestrel.rb CHANGED
@@ -8,3 +8,4 @@ require 'kestrel/client/proxy'
8
8
  require 'kestrel/client/envelope'
9
9
  require 'kestrel/client/blocking'
10
10
  require 'kestrel/client/unmarshal'
11
+ require 'kestrel/client/namespace'
@@ -0,0 +1,24 @@
1
+ module Kestrel
2
+ class Client
3
+ class Namespace < Proxy
4
+ def initialize(namespace, client)
5
+ @namespace = namespace
6
+ super(client)
7
+ end
8
+
9
+ def get(key, *args)
10
+ client.get(namespace(key), *args)
11
+ end
12
+
13
+ def set(key, *args)
14
+ client.set(namespace(key), *args)
15
+ end
16
+
17
+ private
18
+
19
+ def namespace(key)
20
+ "#{@namespace}:#{key}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Kestrel::Client::Namespace do
4
+ describe "Instance Methods" do
5
+ before do
6
+ Kestrel::Config.load TEST_CONFIG_FILE
7
+ @raw_kestrel_client = Kestrel::Client.new(*Kestrel::Config.default)
8
+ @kestrel = Kestrel::Client::Namespace.new('some_namespace', @raw_kestrel_client)
9
+ end
10
+
11
+ describe "#get and #set" do
12
+ describe "namespace" do
13
+ it "prepends a namespace to key on a set" do
14
+ mock(@raw_kestrel_client).set('some_namespace:a_queue', :mcguffin)
15
+ @kestrel.set('a_queue', :mcguffin)
16
+ end
17
+
18
+ it "prepends a namespace to key on a get" do
19
+ mock(@raw_kestrel_client).get('some_namespace:a_queue')
20
+ @kestrel.get('a_queue')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kestrel-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Freels
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-11 00:00:00 -08:00
13
+ date: 2010-02-12 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -43,12 +43,14 @@ files:
43
43
  - lib/kestrel/client/blocking.rb
44
44
  - lib/kestrel/client/envelope.rb
45
45
  - lib/kestrel/client/json.rb
46
+ - lib/kestrel/client/namespace.rb
46
47
  - lib/kestrel/client/proxy.rb
47
48
  - lib/kestrel/client/unmarshal.rb
48
49
  - lib/kestrel/config.rb
49
50
  - spec/kestrel/client/blocking_spec.rb
50
51
  - spec/kestrel/client/envelope_spec.rb
51
52
  - spec/kestrel/client/json_spec.rb
53
+ - spec/kestrel/client/namespace_spec.rb
52
54
  - spec/kestrel/client/unmarshal_spec.rb
53
55
  - spec/kestrel/client_spec.rb
54
56
  - spec/kestrel/config/kestrel.yml
@@ -87,6 +89,7 @@ test_files:
87
89
  - spec/kestrel/client/blocking_spec.rb
88
90
  - spec/kestrel/client/envelope_spec.rb
89
91
  - spec/kestrel/client/json_spec.rb
92
+ - spec/kestrel/client/namespace_spec.rb
90
93
  - spec/kestrel/client/unmarshal_spec.rb
91
94
  - spec/kestrel/client_spec.rb
92
95
  - spec/kestrel/config_spec.rb