rigeon 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d89da22436efc252e202d2a45f6c2e64f3d4d31f
4
+ data.tar.gz: 36a1ab680dd0964c62a1769269dc3f4d94ca619e
5
+ SHA512:
6
+ metadata.gz: 3f970861d7538c7e3d498d40637a1ce5cd4f9c0b767260b73c2a77be73f6cbc94a0b6edf02f77098243135e2b3551ecc3a856efc92563de4ddd39772624cbdbd
7
+ data.tar.gz: dca6c1ca0216b71bfaf9f45649fbbc9d6a0415bba1438fa781b3d67ccdccdfbd96ae7df412b3dae16048b53c58418dab2fec03620b6d850aecb7c04c9d20b738
data/lib/rigeon.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+ require 'concurrent'
3
+ require 'redis'
4
+ require 'redis/connection/hiredis'
5
+
6
+ require_relative 'rigeon/version'
7
+ require_relative 'rigeon/publisher'
8
+ require_relative 'rigeon/subscriber'
9
+
10
+ # Base Module
11
+ module Rigeon
12
+ # Static method that return 1 redis client
13
+ # The URL to the client is expected to be defined in REDIS_URL env. var
14
+ # If the REDIS_URL is not defined, use the default localhost redis url
15
+ #
16
+ # @return [Redis] client used by submodules
17
+ def self.client
18
+ @client ||= Redis.new(url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'))
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ module Rigeon
2
+ # Encapsulate the publisher methods
3
+ module Publisher
4
+ # Method that publish messages to redis specific channel
5
+ # @params channel [String] containing the name of the channel to publish
6
+ # the message to
7
+ # @params message [Hash] containing the message event/object that will
8
+ # serialized to json then published to redis specific channel
9
+ #
10
+ # @returns [Integer] indicating the redis client response on publishing
11
+ # the message to certain channel
12
+ def publish(channel, message)
13
+ Rigeon.client.publish channel, message.to_json
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module Rigeon
2
+ # Encapsulate the subscriber methods
3
+ module Subscriber
4
+ # Method that subscribe to redis specific channel
5
+ # @params channel [String] containing the name of the channel to subscribe
6
+ # to and call the callback with the recieved message
7
+ # @params callback [String] containing the name of the callback method
8
+ # that is expected to be defined on the class subscribing to the channel
9
+ #
10
+ # @returns [eval] call to the callback method with the message recieved
11
+ def subscribe(channel, callback)
12
+ Rigeon.client.subscribe channel do |event|
13
+ event.message do |_channel, message|
14
+ message = JSON.parse(message)
15
+ send(callback, message)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ # Gem Version
2
+ module Rigeon
3
+ VERSION = '0.1.1'
4
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rigeon do
4
+ it 'has a version number' do
5
+ expect(Rigeon::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rigeon'
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rigeon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ahmed Abdel-Razzak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: vcr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: hiredis
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.6'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.6'
125
+ - !ruby/object:Gem::Dependency
126
+ name: redis
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.2'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.2'
139
+ description:
140
+ email:
141
+ - abdelrazzak.ahmed@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - lib/rigeon.rb
147
+ - lib/rigeon/publisher.rb
148
+ - lib/rigeon/subscriber.rb
149
+ - lib/rigeon/version.rb
150
+ - spec/rigeon_spec.rb
151
+ - spec/spec_helper.rb
152
+ homepage: https://github.com/artmees/rigeon
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.5.0
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: wrapper for implementing PUB/SUB pattern across distributed system
176
+ test_files: []
177
+ has_rdoc: