Class: Sensu::Transport::Base
- Inherits:
-
Object
- Object
- Sensu::Transport::Base
- Includes:
- EM::Deferrable
- Defined in:
- lib/sensu/transport/base.rb
Instance Attribute Summary collapse
-
#logger ⇒ Logger
The Sensu logger object.
Class Method Summary collapse
-
.descendants ⇒ Object
Discover available transports (Subclasses).
Instance Method Summary collapse
-
#ack(*args, &callback) ⇒ Object
Alias for acknowledge().
-
#acknowledge(info) {|info| ... } ⇒ Object
Acknowledge the delivery of a message from the transport.
-
#after_reconnect(&callback) ⇒ Proc
Set the after reconnect callback.
-
#before_reconnect(&callback) ⇒ Proc
Set the before reconnect callback.
-
#close ⇒ Object
Close the transport connection.
-
#connect(options = {}) ⇒ Object
Transport connection setup.
-
#connected? ⇒ TrueClass, FalseClass
Indicates if connected to the transport.
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#on_error(&callback) ⇒ Proc
Set the error callback.
-
#publish(type, pipe, message, options = {}) {|info| ... } ⇒ Object
Publish a message to the transport.
-
#reconnect(force = false) ⇒ Object
Reconnect to the transport.
-
#stats(funnel, options = {}) {|info| ... } ⇒ Object
Transport funnel stats, such as message and consumer counts.
-
#subscribe(type, pipe, funnel = nil, options = {}) {|info, message| ... } ⇒ Object
Subscribe to a transport pipe and/or funnel.
-
#unsubscribe {|info| ... } ⇒ Object
Unsubscribe from all transport pipes and/or funnels.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 |
# File 'lib/sensu/transport/base.rb', line 17 def initialize @on_error = Proc.new {} @before_reconnect = Proc.new {} @after_reconnect = Proc.new {} end |
Instance Attribute Details
#logger ⇒ Logger
Returns the Sensu logger object.
15 16 17 |
# File 'lib/sensu/transport/base.rb', line 15 def logger @logger end |
Class Method Details
.descendants ⇒ Object
Discover available transports (Subclasses)
138 139 140 141 142 |
# File 'lib/sensu/transport/base.rb', line 138 def self.descendants ObjectSpace.each_object(Class).select do |klass| klass < self end end |
Instance Method Details
#ack(*args, &callback) ⇒ Object
Alias for acknowledge(). This should be superseded by a proper alias via alias_method in the transport class.
122 123 124 |
# File 'lib/sensu/transport/base.rb', line 122 def ack(*args, &callback) acknowledge(*args, &callback) end |
#acknowledge(info) {|info| ... } ⇒ Object
Acknowledge the delivery of a message from the transport.
116 117 118 |
# File 'lib/sensu/transport/base.rb', line 116 def acknowledge(info) yield(info) if block_given? end |
#after_reconnect(&callback) ⇒ Proc
Set the after reconnect callback.
46 47 48 |
# File 'lib/sensu/transport/base.rb', line 46 def after_reconnect(&callback) @after_reconnect = callback end |
#before_reconnect(&callback) ⇒ Proc
Set the before reconnect callback.
37 38 39 |
# File 'lib/sensu/transport/base.rb', line 37 def before_reconnect(&callback) @before_reconnect = callback end |
#close ⇒ Object
Close the transport connection.
68 |
# File 'lib/sensu/transport/base.rb', line 68 def close; end |
#connect(options = {}) ⇒ Object
Transport connection setup.
53 |
# File 'lib/sensu/transport/base.rb', line 53 def connect(={}); end |
#connected? ⇒ TrueClass, FalseClass
Indicates if connected to the transport.
63 64 65 |
# File 'lib/sensu/transport/base.rb', line 63 def connected? false end |
#on_error(&callback) ⇒ Proc
Set the error callback.
28 29 30 |
# File 'lib/sensu/transport/base.rb', line 28 def on_error(&callback) @on_error = callback end |
#publish(type, pipe, message, options = {}) {|info| ... } ⇒ Object
Publish a message to the transport.
80 81 82 83 |
# File 'lib/sensu/transport/base.rb', line 80 def publish(type, pipe, , ={}) info = {:error => nil} yield(info) if block_given? end |
#reconnect(force = false) ⇒ Object
Reconnect to the transport.
58 |
# File 'lib/sensu/transport/base.rb', line 58 def reconnect(force=false); end |
#stats(funnel, options = {}) {|info| ... } ⇒ Object
Transport funnel stats, such as message and consumer counts.
132 133 134 135 |
# File 'lib/sensu/transport/base.rb', line 132 def stats(funnel, ={}) info = {} yield(info) if block_given? end |
#subscribe(type, pipe, funnel = nil, options = {}) {|info, message| ... } ⇒ Object
Subscribe to a transport pipe and/or funnel.
97 98 99 100 101 |
# File 'lib/sensu/transport/base.rb', line 97 def subscribe(type, pipe, funnel=nil, ={}) info = {} = '' yield(info, ) end |
#unsubscribe {|info| ... } ⇒ Object
Unsubscribe from all transport pipes and/or funnels.
107 108 109 110 |
# File 'lib/sensu/transport/base.rb', line 107 def unsubscribe info = {} yield(info) if block_given? end |