summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-02-02 21:42:47 -0700
committermo khan <mo@mokhan.ca>2015-02-02 21:42:47 -0700
commitd62b071aa28ee7ece0393cc2fa8ac42d2b981ae0 (patch)
tree6c527c36428fc1cb10a5d8a7f124380e0792febb /app/services
parent5402200c3b6a83869a77f35b2ef9911096942dd4 (diff)
publish message to rabbit to instead of creating a new event.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/publisher.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/services/publisher.rb b/app/services/publisher.rb
new file mode 100644
index 0000000..ef940e8
--- /dev/null
+++ b/app/services/publisher.rb
@@ -0,0 +1,16 @@
+class Publisher
+ def self.publish(exchange, message = {})
+ exchange = channel.fanout("malwer.#{exchange}")
+ exchange.publish(message.to_json)
+ end
+
+ def self.channel
+ @channel ||= connection.create_channel
+ end
+
+ def self.connection
+ @connection ||= Bunny.new.tap do |connection|
+ connection.start
+ end
+ end
+end