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 +4 -0
- data/README.md +9 -0
- data/Rakefile +9 -0
- data/lib/redismq/client.rb +6 -10
- data/lib/redismq/version.rb +1 -1
- data/spec/client_spec.rb +11 -0
- metadata +9 -7
data/Gemfile
CHANGED
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
data/lib/redismq/client.rb
CHANGED
@@ -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, :
|
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'] ||
|
17
|
+
url = ENV['REDISMQ_URL'] || ENV['REDISTOGO_URL'] || 'redis://localhost:6379'
|
18
18
|
uri = URI.parse(url)
|
19
|
-
Redis.new(:
|
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, :
|
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
|
data/lib/redismq/version.rb
CHANGED
data/spec/client_spec.rb
ADDED
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.
|
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-
|
12
|
+
date: 2012-01-29 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
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: *
|
24
|
+
version_requirements: *70138310998600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: redis
|
27
|
-
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: *
|
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
|