redismq 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in redismq.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'rake'
8
+ end
data/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  A cheap and naive implementation of topic exchanges on top of Redis.
4
4
 
5
+ This project came about to help me decouple some smaller projects that already rely on Redis and don't need the weight of another dependancy.
6
+
7
+ It is working well enough, but there are some limitations that you should be aware of:
8
+
9
+ * all logic is client-side ; there is no central broker to ensure that everyone is playing by the rules
10
+ * `publish` is O(n) - the larger the pool of queues-per-topic, the longer it takes to publish
11
+
12
+ If you need a really robust message bus, you should give serious consideration to [RabbitMQ](http://www.rabbitmq.com/).
13
+
5
14
  ## Installation
6
15
 
7
16
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs.push "lib"
7
+ t.test_files = FileList["spec/*_spec.rb"]
8
+ t.verbose = true
9
+ end
10
+
11
+ task :default => :test
@@ -10,19 +10,19 @@ module RedisMQ
10
10
 
11
11
  def bpop(queue, timeout=0)
12
12
  (queue, message) = redis.blpop(queue_key(queue), timeout)
13
- JSON.parse(message, :symbolize_names => true)
13
+ JSON.parse(message, symbolize_names: true)
14
14
  end
15
15
 
16
16
  def connect_to_redis
17
- url = ENV['REDISMQ_URL'] || ENV['REDISTOGO_URL'] || "redis://localhost:6379"
17
+ url = ENV['REDISMQ_URL'] || ENV['REDISTOGO_URL'] || 'redis://localhost:6379'
18
18
  uri = URI.parse(url)
19
- Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
19
+ Redis.new(host: uri.host, port: uri.port, password: uri.password)
20
20
  end
21
21
 
22
22
  def pop(queue)
23
23
  result = redis.lpop(queue_key(queue))
24
24
  return nil if result.nil?
25
- JSON.parse(result, :symbolize_names => true)
25
+ JSON.parse(result, symbolize_names: true)
26
26
  end
27
27
 
28
28
  def publish(topic, payload)
@@ -41,15 +41,11 @@ module RedisMQ
41
41
  end
42
42
 
43
43
  def queue_key(queue)
44
- "queue:#{queue}"
44
+ "rmq:queue:#{queue}"
45
45
  end
46
46
 
47
- def queue_name(queue_key)
48
- queue_key.split(':').last
49
- end
50
-
51
47
  def topic_key(topic)
52
- "topic:#{topic}"
48
+ "rmq:topic:#{topic}"
53
49
  end
54
50
  end
55
51
  end
@@ -1,3 +1,3 @@
1
1
  module RedisMQ
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+
4
+ require 'redismq'
5
+
6
+ describe RedisMQ::Client do
7
+ before do
8
+ @client = RedisMQ::Client.new
9
+ @client.flushdb
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redismq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-28 00:00:00.000000000Z
12
+ date: 2012-01-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70157200323920 !ruby/object:Gem::Requirement
16
+ requirement: &70138310998600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70157200323920
24
+ version_requirements: *70138310998600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redis
27
- requirement: &70157200323420 !ruby/object:Gem::Requirement
27
+ requirement: &70138310998020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 2.2.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70157200323420
35
+ version_requirements: *70138310998020
36
36
  description: A cheap and naive implementation of topic exchanges on top of Redis.
37
37
  email:
38
38
  - michael.gorsuch@gmail.com
@@ -49,6 +49,7 @@ files:
49
49
  - lib/redismq/client.rb
50
50
  - lib/redismq/version.rb
51
51
  - redismq.gemspec
52
+ - spec/client_spec.rb
52
53
  homepage: https://github.com/gorsuch/redismq
53
54
  licenses: []
54
55
  post_install_message:
@@ -73,4 +74,5 @@ rubygems_version: 1.8.10
73
74
  signing_key:
74
75
  specification_version: 3
75
76
  summary: A cheap and naive implementation of topic exchanges on top of Redis.
76
- test_files: []
77
+ test_files:
78
+ - spec/client_spec.rb