Class: Sensu::Transport::Base
- Inherits:
-
Object
- Object
- Sensu::Transport::Base
- Defined in:
- lib/sensu/transport/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#logger ⇒ Logger
The Sensu logger object.
Class Method Summary collapse
-
.connect(options = {}) ⇒ Transport
Connects to the transport.
-
.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
Sets the after reconnect callback.
-
#before_reconnect(&callback) ⇒ Proc
Sets 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
Sets the error callback.
-
#publish(type, pipe, message, options = {}) {|info| ... } ⇒ Object
Publish a message to the transport.
-
#stats(funnel, options = {}, &callback) ⇒ 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.
12 13 14 15 16 |
# File 'lib/sensu/transport/base.rb', line 12 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.
10 11 12 |
# File 'lib/sensu/transport/base.rb', line 10 def logger @logger end |
Class Method Details
.connect(options = {}) ⇒ Transport
Connects to the transport.
64 65 66 67 68 69 |
# File 'lib/sensu/transport/base.rb', line 64 def self.connect(={}) ||= {} transport = self.new transport.connect() transport end |
.descendants ⇒ Object
Discover available transports (Subclasses)
136 137 138 139 140 |
# File 'lib/sensu/transport/base.rb', line 136 def self.descendants ObjectSpace.each_object(Class).select do |klass| klass < self end end |
Instance Method Details
#ack(*args, &callback) ⇒ Object
Alias for acknowledge()
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.
117 118 119 |
# File 'lib/sensu/transport/base.rb', line 117 def acknowledge(info, &callback) callback.call(info) if callback end |
#after_reconnect(&callback) ⇒ Proc
Sets the after reconnect callback.
41 42 43 |
# File 'lib/sensu/transport/base.rb', line 41 def after_reconnect(&callback) @after_reconnect = callback end |
#before_reconnect(&callback) ⇒ Proc
Sets the before reconnect callback.
32 33 34 |
# File 'lib/sensu/transport/base.rb', line 32 def before_reconnect(&callback) @before_reconnect = callback end |
#close ⇒ Object
Close the transport connection.
58 |
# File 'lib/sensu/transport/base.rb', line 58 def close; end |
#connect(options = {}) ⇒ Object
Transport connection setup.
48 |
# File 'lib/sensu/transport/base.rb', line 48 def connect(={}); end |
#connected? ⇒ TrueClass, FalseClass
Indicates if connected to the transport.
53 54 55 |
# File 'lib/sensu/transport/base.rb', line 53 def connected? false end |
#on_error(&callback) ⇒ Proc
Sets the error callback.
23 24 25 |
# File 'lib/sensu/transport/base.rb', line 23 def on_error(&callback) @on_error = callback end |
#publish(type, pipe, message, options = {}) {|info| ... } ⇒ Object
Publish a message to the transport.
81 82 83 84 |
# File 'lib/sensu/transport/base.rb', line 81 def publish(type, pipe, , ={}, &callback) info = {:error => nil} callback.call(info) if callback end |
#stats(funnel, options = {}, &callback) ⇒ Object
Transport funnel stats, such as message and consumer counts.
130 131 132 133 |
# File 'lib/sensu/transport/base.rb', line 130 def stats(funnel, ={}, &callback) info = {} callback.call(info) end |
#subscribe(type, pipe, funnel = nil, options = {}) {|info, message| ... } ⇒ Object
Subscribe to a transport pipe and/or funnel.
98 99 100 101 102 |
# File 'lib/sensu/transport/base.rb', line 98 def subscribe(type, pipe, funnel=nil, ={}, &callback) info = {} = '' callback.call(info, ) end |
#unsubscribe {|info| ... } ⇒ Object
Unsubscribe from all transport pipes and/or funnels.
108 109 110 111 |
# File 'lib/sensu/transport/base.rb', line 108 def unsubscribe(&callback) info = {} callback.call(info) if callback end |