waffle 0.2.2 → 0.3.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.
- data/README.md +8 -14
- data/lib/waffle/transports/rabbitmq.rb +10 -4
- data/lib/waffle/version.rb +1 -1
- metadata +6 -6
data/README.md
CHANGED
@@ -8,31 +8,25 @@ An abstract flow publisher and subscriber.
|
|
8
8
|
|
9
9
|
Insert in your Rails Gemfile:
|
10
10
|
|
11
|
-
gem 'waffle'
|
11
|
+
gem 'waffle'
|
12
12
|
|
13
13
|
and create config file:
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
or if RabbitMQ on local machine
|
21
|
-
|
22
|
-
# production.waffle.yml
|
23
|
-
transport: rabbitmq
|
24
|
-
encoder: marshal
|
15
|
+
production:
|
16
|
+
transport: rabbitmq
|
17
|
+
encoder: marshal
|
18
|
+
url: amqp://anyhost.com:5678
|
25
19
|
|
26
20
|
## Usage
|
27
21
|
|
28
22
|
When you want to performan event, just insert this code in place, where it must occur:
|
29
23
|
|
30
|
-
Waffle::Event.
|
24
|
+
Waffle::Event.occurred 'index_page_load'
|
31
25
|
|
32
26
|
You can attach meta data to event like this:
|
33
27
|
|
34
|
-
Waffle::Event.
|
28
|
+
Waffle::Event.occurred 'index_page_load', {'user_id' => 13, 'user_name' => 'Joshua'}
|
35
29
|
|
36
30
|
or like this:
|
37
31
|
|
38
|
-
Waffle::Event.
|
32
|
+
Waffle::Event.occurred 'index_page_load', 'bingo!'
|
@@ -4,6 +4,8 @@ module Waffle
|
|
4
4
|
module Transports
|
5
5
|
class Rabbitmq
|
6
6
|
|
7
|
+
EXCHANGE = 'events'
|
8
|
+
|
7
9
|
def initialize
|
8
10
|
@bunny = Bunny.new Waffle::Config.url
|
9
11
|
@bunny.start
|
@@ -14,14 +16,18 @@ module Waffle
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def publish(flow = 'events', message = '')
|
17
|
-
@exchange = @bunny.exchange
|
18
|
-
@exchange.publish message
|
19
|
+
@exchange = @bunny.exchange EXCHANGE
|
20
|
+
@exchange.publish message, :key => flow
|
19
21
|
end
|
20
22
|
|
21
23
|
def subscribe(flow = 'events')
|
22
|
-
@exchange = @bunny.exchange
|
24
|
+
@exchange = @bunny.exchange EXCHANGE
|
23
25
|
@queue = @bunny.queue '', :durable => true, :auto_delete => true
|
24
|
-
|
26
|
+
if flow.is_a? Array
|
27
|
+
flow.each{ |f| @queue.bind @exchange, :key => f }
|
28
|
+
else
|
29
|
+
@queue.bind @exchange, :key => flow
|
30
|
+
end
|
25
31
|
|
26
32
|
@queue.subscribe do |message|
|
27
33
|
yield encoder.decode(message[:payload])
|
data/lib/waffle/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waffle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
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-03-
|
12
|
+
date: 2012-03-30 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bunny
|
16
|
-
requirement: &
|
16
|
+
requirement: &72306440 !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: *72306440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yajl-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &72306000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *72306000
|
36
36
|
description: Client part of Patty statistics server
|
37
37
|
email: alexander.lomakin@gmail.com
|
38
38
|
executables: []
|