Module: AgentFIX

Extended by:
AgentFIX, Configuration
Included in:
AgentFIX
Defined in:
lib/agent_fix.rb,
lib/agent_fix/agent.rb,
lib/agent_fix/configuration.rb,
lib/agent_fix/message_cache.rb

Defined Under Namespace

Modules: Configuration Classes: Agent, MessageCache

Constant Summary

Constants included from Configuration

Configuration::REASONABLE_SESSION_DEFAULTS

Instance Method Summary collapse

Methods included from Configuration

cucumber_retries, cucumber_retries=, cucumber_sleep_seconds, cucumber_sleep_seconds=, include_session_level=, include_session_level?, reset_config, session_defaults, session_defaults=

Instance Method Details

#agent_files_loadedObject



21
22
23
# File 'lib/agent_fix.rb', line 21

def agent_files_loaded
  @agent_files_loaded ||=[]
end

#agent_pathObject



9
10
11
# File 'lib/agent_fix.rb', line 9

def agent_path
  "./config/fix_agents.rb"
end

#agentsObject



13
14
15
16
17
18
19
# 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_hashObject



74
75
76
# File 'lib/agent_fix.rb', line 74

def agents_hash
  Hash[agents.map { |a| [a.name.to_sym, a]}]
end

#define_acceptor(name, &blk) ⇒ Object



39
40
41
# File 'lib/agent_fix.rb', line 39

def define_acceptor(name, &blk)
  define_agent(Agent.new(name, :acceptor), &blk)
end

#define_agent(agent) {|agent| ... } ⇒ Object

Yields:

  • (agent)


34
35
36
37
# File 'lib/agent_fix.rb', line 34

def define_agent(agent, &blk)
  yield agent
  agents << agent
end

#define_initiator(name, &blk) ⇒ Object



43
44
45
# File 'lib/agent_fix.rb', line 43

def define_initiator(name, &blk)
  define_agent(Agent.new(name, :initiator), &blk)
end

#hard_resetObject



68
69
70
71
72
# File 'lib/agent_fix.rb', line 68

def hard_reset
  stop
  sleep 0.5
  start
end

#load_agents(path = nil) ⇒ Object



25
26
27
28
29
30
31
32
# 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

#resetObject



64
65
66
# File 'lib/agent_fix.rb', line 64

def reset
  agents.each {|a| a.reset}
end

#startObject

starts all configured agents

Raises:

  • (RuntimeError)


48
49
50
51
52
53
54
# 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 = {}) ⇒ Object

stops all agents. use boolean opt :force=>true to wait for logout completion



58
59
60
61
62
# File 'lib/agent_fix.rb', line 58

def stop opts={}
  opts[:force]||=false

  agents.each {|a| a.stop opts[:force]}
end