Module: FFWD::Plugin::JSON
- Includes:
- Logging, FFWD::Plugin
- Defined in:
- lib/ffwd/plugin/json.rb,
lib/ffwd/plugin/json/connection.rb
Defined Under Namespace
Classes: Connection, FrameConnection, LineConnection
Constant Summary collapse
- DEFAULT_HOST =
"localhost"
- DEFAULT_PORT =
19000
- DEFAULT_PROTOCOL =
{"line" => "tcp", "frame" => "udp"}
- DEFAULT_KIND =
"line"
- KINDS =
{"frame" => FrameConnection, "line" => LineConnection}
Class Method Summary collapse
Methods included from Logging
Methods included from FFWD::Plugin
category, discovered, included, load_discovered, load_plugins, loaded, option
Class Method Details
.setup_input(opts) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ffwd/plugin/json.rb', line 84 def self.setup_input opts opts[:host] ||= DEFAULT_HOST opts[:port] ||= DEFAULT_PORT kind = (opts[:kind] || DEFAULT_KIND).to_s unless connection = KINDS[kind] raise "No such protocol kind: #{kind}" end protocol = FFWD.parse_protocol opts[:protocol] || DEFAULT_PROTOCOL[kind] if connection == FrameConnection and protocol != FFWD::UDP log.warning "When using :frame kind, you should use the UDP protocol." + " Not #{protocol.family.to_s.upcase}" end if connection == LineConnection and protocol != FFWD::TCP log.warning "When using :line kind, you should use the TCP protocol. " + "Not #{protocol.family.to_s.upcase}" end protocol.bind opts, log, connection end |