Module: NebulousStomp
- Defined in:
- lib/nebulous_stomp.rb,
lib/nebulous_stomp/param.rb,
lib/nebulous_stomp/target.rb,
lib/nebulous_stomp/message.rb,
lib/nebulous_stomp/request.rb,
lib/nebulous_stomp/version.rb,
lib/nebulous_stomp/listener.rb,
lib/nebulous_stomp/msg/body.rb,
lib/nebulous_stomp/msg/header.rb,
lib/nebulous_stomp/redis_helper.rb,
lib/nebulous_stomp/redis_handler.rb,
lib/nebulous_stomp/stomp_handler.rb,
lib/nebulous_stomp/redis_handler_null.rb,
lib/nebulous_stomp/stomp_handler_null.rb
Overview
NebulousStomp
A little module that implements The Nebulous Protocol, a way of passing data over STOMP between different systems. Specifically, it allows you to send a message, a Request, and receive another message in answer, a Response. (Which is not something STOMP does, out of the box).
This library covers two specific use cases (three if you are picky):
1) Request-Response: a program that consumes incoming , works out what to
send in response, and sends it.
2) Question-Answer: a program that sends a request and then waits for a response; the other
end of the Request-Response use case. We support optional caching of responses in Redis,
to speed things up if your program is likely to make the same request repeatedly within a
short time.
3) Since we are talking to Redis, we expose a basic, simple interface for you to talk to it
yourself.
These are the externally-facing classes:
* Listener -- implements the request-response use case
* Message -- a Nebulous-Stomp
* NebulousStomp -- main class
* RedisHelper -- implements the Redis use case
* Request -- implements the Request-Response use case; a wrapper for Message
* Target -- represents a single Target
These classes are used internally:
* Param -- helper class to store and return configuration
* RedisHandler -- internal class to wrap the Redis gem
* RedisHandlerNull -- a "mock" version of RedisHandler for use in testing
* StompHandler -- internal class to wrap the Stomp gem
* StompHandlerNull -- a "mock" version of StompHandler for use in testing
Defined Under Namespace
Modules: Msg, Param Classes: ConnectionError, Listener, Message, NebulousError, NebulousTimeout, RedisHandler, RedisHandlerNull, RedisHelper, Request, StompHandler, StompHandlerNull, Target
Constant Summary collapse
- VERSION =
Nebulous version number
"3.1.1"
Class Method Summary collapse
-
.add_target(name, targetHash) ⇒ Object
:call-seq: NebulousStomp.add_target(name, targetHash) -> Target.
-
.get_target(name) ⇒ Object
:call-seq: NebulousStomp.get_target(name) # -> Target.
-
.init(paramHash = {}) ⇒ Object
:call-seq: NebulousStomp.init(paramHash) -> (nil).
-
.logger ⇒ Object
:call-seq: NebulousStomp.logger.info(__FILE__) { “message” }.
-
.on? ⇒ Boolean
:call-seq: Nebulous.on? -> Boolean.
-
.redis_on? ⇒ Boolean
:call-seq: Nebulous.redis_on? -> Boolean.
-
.set_logger(logger) ⇒ Object
:call-seq: NebulousStomp.set_logger(Logger.new STDOUT).
Class Method Details
.add_target(name, targetHash) ⇒ Object
:call-seq: NebulousStomp.add_target(name, targetHash) -> Target
Add a Nebulous target called <name> with a details as per <targetHash>.
<targetHash> must contain a send queue and a receive queue, or a NebulousError will be raised. Have a look in NebulousStomp::Target for the default hash you are overriding here.
Note that Param expects the target hash to have a :name key. We don’t; we add it in.
90 91 92 93 94 |
# File 'lib/nebulous_stomp.rb', line 90 def self.add_target(name, targetHash) t = NebulousStomp::Target.new targetHash.merge(name: name) Param.add_target(t) t end |
.get_target(name) ⇒ Object
:call-seq:
NebulousStomp.get_target(name) # -> Target
Given a target name, return the Target object.
102 103 104 |
# File 'lib/nebulous_stomp.rb', line 102 def self.get_target(name) Param.get_target(name) end |
.init(paramHash = {}) ⇒ Object
:call-seq: NebulousStomp.init(paramHash) -> (nil)
Initialise library for use and override default options with any in <paramHash>.
The default options are defined in Nebulous::Param.
74 75 76 77 |
# File 'lib/nebulous_stomp.rb', line 74 def self.init(paramHash={}) Param.set(paramHash) nil end |
.logger ⇒ Object
:call-seq:
NebulousStomp.logger.info(__FILE__) { "message" }
Return a Logger instance to log things to. If one was not given to Param, return a logger instance that uses a DevNull IO object, that is, goes nowhere.
123 124 125 |
# File 'lib/nebulous_stomp.rb', line 123 def self.logger Param.get_logger || Logger.new( DevNull.new ) end |
.on? ⇒ Boolean
:call-seq:
Nebulous.on? -> Boolean
True if Nebulous is configured to be running
133 134 135 136 |
# File 'lib/nebulous_stomp.rb', line 133 def self.on? h = Param.get(:stompConnectHash) !(h.nil? || h.empty?) end |
.redis_on? ⇒ Boolean
:call-seq:
Nebulous.redis_on? -> Boolean
True if the Redis cache is configured to be running
144 145 146 147 |
# File 'lib/nebulous_stomp.rb', line 144 def self.redis_on? h = Param.get(:redisConnectHash) !(h.nil? || h.empty?) end |
.set_logger(logger) ⇒ Object
:call-seq:
NebulousStomp.set_logger(Logger.new STDOUT)
Set an instance of Logger to log stuff to.
112 113 114 |
# File 'lib/nebulous_stomp.rb', line 112 def self.set_logger(logger) Param.set_logger(logger) end |