yakc 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -10
- data/changelog.md +9 -0
- data/lib/yakc.rb +2 -1
- data/lib/yakc/message_broadcaster.rb +3 -4
- data/lib/yakc/version.rb +1 -1
- data/yakc.gemspec +0 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f40899773656de9cfbead93243b26617837de3
|
4
|
+
data.tar.gz: da3d3e392bdf386f3ef68cea6cc216196c124787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 281696b355fa78de003ca996b79689afd581d1e3180ac4ccfae43a13813b5fc2ac6957c006a123fca061d4b19e7550902df809dbaff5a8b35c70829a09623a8a
|
7
|
+
data.tar.gz: 96b984d65af7f148485adf11b7533a3914a22a0f8ced2624b6560263867b49f1b682f95b9656a691767d7731d0350eb02721c275260677dac1d061b6674d411c
|
data/README.md
CHANGED
@@ -27,25 +27,17 @@ There are 2 main componets:
|
|
27
27
|
This is the bit of code that handles what to do with the messages once they are received. There are 2 stages to this process:
|
28
28
|
|
29
29
|
1. The message is parsed using *your* message parser(inherited from the `YAKC::Message` class) that does the parsing and validity checking.
|
30
|
-
2. The parsed message payload is broadcast
|
30
|
+
2. The parsed message payload is broadcast using `ActiveSupport::Notifications`
|
31
|
+
3: It will broadcast the message with the key: "topic::event"
|
31
32
|
|
32
33
|
To set it up:
|
33
34
|
|
34
35
|
```ruby
|
35
|
-
handler = YAKC::MessageBroadcaster.new publisher: MyBroadcaster, message_parser: MyMessageClass
|
36
|
-
# or, if you are okay with Yeller
|
37
36
|
handler = YAKC::MessageBroadcaster.new message_parser: MyMessageClass
|
38
37
|
```
|
39
38
|
|
40
39
|
And now you're ready to init the [reader](#reader)
|
41
40
|
|
42
|
-
#### Publisher Interface
|
43
|
-
|
44
|
-
If you don't like Yeller, or want something that can talk cross-process, you can implement your own.
|
45
|
-
|
46
|
-
The publisher interface is pretty simple: it has to implement
|
47
|
-
* `broadcast( message, topic )` : This is the function that handles where the messages go.
|
48
|
-
|
49
41
|
#### Message Interface
|
50
42
|
|
51
43
|
The message parser needs to implement:
|
data/changelog.md
ADDED
data/lib/yakc.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "yakc/version"
|
2
2
|
require 'active_support'
|
3
3
|
require 'active_support/core_ext/module/delegation'
|
4
|
-
require '
|
4
|
+
require 'active_support/core_ext/object'
|
5
|
+
require 'active_support/notifications'
|
5
6
|
|
6
7
|
module YAKC
|
7
8
|
autoload :Configuration, 'yakc/configuration'
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module YAKC
|
2
2
|
class MessageBroadcaster
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :message_class, :instrumenter
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@publisher = publisher
|
5
|
+
def initialize( instrumenter: FallthroughInstrumenter, message_parser: )
|
7
6
|
@message_class = message_parser
|
8
7
|
@instrumenter = instrumenter.new
|
9
8
|
raise "MessageBroadcaster must have a valid message class" unless @message_class
|
@@ -15,7 +14,7 @@ module YAKC
|
|
15
14
|
@instrumenter.instrument( msg ) do
|
16
15
|
if msg.broadcastable?
|
17
16
|
# broadcast the specific topic event
|
18
|
-
|
17
|
+
ActiveSupport::Notifications.instrument broadcast_key( topic, msg.event ), message: msg.payload
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
data/lib/yakc/version.rb
CHANGED
data/yakc.gemspec
CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "yeller"
|
22
21
|
spec.add_dependency "poseidon_cluster", "0.3.2.avvo3"
|
23
22
|
spec.add_dependency "activesupport"
|
24
23
|
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yakc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: yeller
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: poseidon_cluster
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +109,7 @@ files:
|
|
123
109
|
- Rakefile
|
124
110
|
- bin/console
|
125
111
|
- bin/setup
|
112
|
+
- changelog.md
|
126
113
|
- lib/yakc.rb
|
127
114
|
- lib/yakc/configuration.rb
|
128
115
|
- lib/yakc/fallthrough_instrumenter.rb
|