def custom_request(action, args, expected_agents, filter = {}, &block)
validate_request(action, args)
if filter == {} && !Config.instance.direct_addressing
raise "Attempted to do a filterless custom_request without direct_addressing enabled, preventing unexpected call to all nodes"
end
@stats.reset
custom_filter = Util.empty_filter
custom_options = options.clone
["identity", "fact", "agent", "cf_class", "compound"].each do |ftype|
if filter.include?(ftype)
custom_filter[ftype] = [filter[ftype], custom_filter[ftype]].flatten
end
end
custom_filter["agent"] << @agent unless custom_filter["agent"].include?(@agent)
custom_options[:filter] = custom_filter
@stats.discovered_agents([expected_agents].flatten)
if args[:process_results] == false || @reply_to
return fire_and_forget_request(action, args, custom_filter)
end
if block_given?
call_agent(action, args, custom_options, [expected_agents].flatten) do |r|
block.call(r)
end
else
call_agent(action, args, custom_options, [expected_agents].flatten)
end
end