module AgentFIX
Public Instance Methods
agent_files_loaded()
click to toggle source
# File lib/agent_fix.rb, line 21 def agent_files_loaded @agent_files_loaded ||=[] end
agent_path()
click to toggle source
# File lib/agent_fix.rb, line 9 def agent_path "./config/fix_agents.rb" end
agents()
click to toggle source
# File lib/agent_fix.rb, line 13 def agents return @agents if @agents (@agents=[]).tap do load_agents if agent_files_loaded.empty? end end
agents_hash()
click to toggle source
# File lib/agent_fix.rb, line 74 def agents_hash Hash[agents.map { |a| [a.name.to_sym, a]}] end
define_acceptor(name, &blk)
click to toggle source
# File lib/agent_fix.rb, line 39 def define_acceptor(name, &blk) define_agent(Agent.new(name, :acceptor), &blk) end
define_agent(agent) { |agent| ... }
click to toggle source
# File lib/agent_fix.rb, line 34 def define_agent(agent, &blk) yield agent agents << agent end
define_initiator(name, &blk)
click to toggle source
# File lib/agent_fix.rb, line 43 def define_initiator(name, &blk) define_agent(Agent.new(name, :initiator), &blk) end
hard_reset()
click to toggle source
# File lib/agent_fix.rb, line 68 def hard_reset stop sleep 0.5 start end
load_agents(path=nil)
click to toggle source
# File lib/agent_fix.rb, line 25 def load_agents path=nil path = File.expand_path(path || agent_path, Dir.pwd) return if agent_files_loaded.include? path agent_files_loaded << path load path agents.each {|a| a.init} end
reset()
click to toggle source
# File lib/agent_fix.rb, line 64 def reset agents.each {|a| a.reset} end
start()
click to toggle source
starts all configured agents
# File lib/agent_fix.rb, line 48 def start raise RuntimeError, "No FIX Agents Defined" if agents.empty? agents.each do |a| a.start end end
stop(opts={})
click to toggle source
stops all agents. use boolean opt :force=>true to wait for logout completion
# File lib/agent_fix.rb, line 58 def stop opts={} opts[:force]||=false agents.each {|a| a.stop opts[:force]} end