@!attribute [rw] logger
@return [Logger] the Sensu logger object.
Discover available transports (Subclasses)
# File lib/sensu/transport/base.rb, line 128 def self.descendants ObjectSpace.each_object(Class).select do |klass| klass < self end end
# File lib/sensu/transport/base.rb, line 12 def initialize @on_error = Proc.new {} @before_reconnect = Proc.new {} @after_reconnect = Proc.new {} end
Alias for acknowledge()
# File lib/sensu/transport/base.rb, line 114 def ack(*args, &callback) acknowledge(*args, &callback) end
Acknowledge the delivery of a message from the transport.
@param info [Hash] message information, eg. contains its id. @yield [info] passes acknowledgment info to an optional callback/block.
# File lib/sensu/transport/base.rb, line 109 def acknowledge(info, &callback) callback.call(info) if callback end
Set the after reconnect callback.
@param callback [Proc] called after reconnecting to the
transport.
@return [Proc] the after reconnect callback.
# File lib/sensu/transport/base.rb, line 41 def after_reconnect(&callback) @after_reconnect = callback end
Set the before reconnect callback.
@param callback [Proc] called before attempting to reconnect
to the transport.
@return [Proc] the before reconnect callback.
# File lib/sensu/transport/base.rb, line 32 def before_reconnect(&callback) @before_reconnect = callback end
Close the transport connection.
# File lib/sensu/transport/base.rb, line 61 def close; end
Transport connection setup.
@param options [Hash, String]
# File lib/sensu/transport/base.rb, line 48 def connect(options={}); end
Indicates if connected to the transport.
@return [TrueClass, FalseClass]
# File lib/sensu/transport/base.rb, line 56 def connected? false end
Set the error callback.
@param callback [Proc] called in the event of a transport
error, the exception object should be passed as a parameter.
@return [Proc] the error callback.
# File lib/sensu/transport/base.rb, line 23 def on_error(&callback) @on_error = callback end
Publish a message to the transport.
@param type [Symbol] the transport pipe type, possible values
are: :direct and :fanout.
@param pipe [String] the transport pipe name. @param message [String] the message to be published to the transport. @param options [Hash] the options to publish the message with. @yield [info] passes publish info to an optional callback/block. @yieldparam info [Hash] contains publish information, which
may contain an error object.
# File lib/sensu/transport/base.rb, line 73 def publish(type, pipe, message, options={}, &callback) info = {:error => nil} callback.call(info) if callback end
Reconnect to the transport.
# File lib/sensu/transport/base.rb, line 51 def reconnect; end
Transport funnel stats, such as message and consumer counts.
@param funnel [String] the transport funnel to get stats for. @param options [Hash] the options to get funnel stats with.
# File lib/sensu/transport/base.rb, line 122 def stats(funnel, options={}, &callback) info = {} callback.call(info) end
Subscribe to a transport pipe and/or funnel.
@param type [Symbol] the transport pipe type, possible values
are: :direct and :fanout.
@param pipe [String] the transport pipe name. @param funnel [String] the transport funnel, which may be
connected to multiple pipes.
@param options [Hash] the options to consume messages with. @yield [info, message] passes message info and content to
the consumer callback/block.
@yieldparam info [Hash] contains message information. @yieldparam message [String] message.
# File lib/sensu/transport/base.rb, line 90 def subscribe(type, pipe, funnel=nil, options={}, &callback) info = {} message = '' callback.call(info, message) end
Unsubscribe from all transport pipes and/or funnels.
@yield [info] passes info to an optional callback/block. @yieldparam info [Hash] contains unsubscribe information.
# File lib/sensu/transport/base.rb, line 100 def unsubscribe(&callback) info = {} callback.call(info) if callback end