module Sqreen::Ecosystem::ModuleApi::MessageProducer
Attributes
tracing_broker[W]
method for ecosystem to inject the config @param [Sqreen::Ecosystem::TracingBroker]
Private Instance Methods
determine_interest(type, hints = {})
click to toggle source
# File lib/sqreen/ecosystem/module_api/message_producer.rb, line 20 def determine_interest(type, hints = {}) @tracing_broker.interested_consumers(type, hints) end
publish(data, interested)
click to toggle source
# File lib/sqreen/ecosystem/module_api/message_producer.rb, line 24 def publish(data, interested) @tracing_broker.publish(data, interested) end
wrap_for_interest(type, gen_hints = nil, &block)
click to toggle source
Convenience wrapper. Wraps a callback, skipping it if there is no interest in the type produced and submitting the return value as a message to the tracing broker
# File lib/sqreen/ecosystem/module_api/message_producer.rb, line 32 def wrap_for_interest(type, gen_hints = nil, &block) raise ArgumentError, 'no block passed' if block.nil? proc do |*args| hints = gen_hints[*args] if gen_hints interested = determine_interest(type, hints || {}) unless interested logger.debug { "No interested consumers in #{type}" } next end res = block[*args] next if res.nil? if res.is_a?(Array) res.each do |d| raise "unexpected return type: #{d.class}" unless d.is_a?(type) @tracing_broker.publish(d, interested) end else raise "unexpected return type: #{res.class}" unless res.is_a?(type) @tracing_broker.publish(res, interested) end end end