Class: DeepTest::DRbBindAllTCPSocket
- Inherits:
-
DRb::DRbTCPSocket
- Object
- DRb::DRbTCPSocket
- DeepTest::DRbBindAllTCPSocket
- Defined in:
- lib/deep_test/extensions/drb_extension.rb
Class Method Summary collapse
-
.open_server(uri, config) ⇒ Object
Open a server listening for connections at
uriusing configurationconfig. - .parse_uri(uri) ⇒ Object
Class Method Details
.open_server(uri, config) ⇒ Object
Open a server listening for connections at uri using configuration config.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/deep_test/extensions/drb_extension.rb', line 17 def self.open_server(uri, config) DeepTest.logger.debug "drubyall open_server with args: #{uri.inspect} #{config.inspect}" uri = 'drubyall://:0' unless uri host, port, opt = parse_uri(uri) if host.size == 0 host = getservername end DeepTest.logger.debug("Listening on port #{port}, all addresses.") soc = TCPServer.open('0.0.0.0', port) port = soc.addr[1] if port == 0 uri = "druby://#{host}:#{port}" self.new(uri, soc, config) rescue Exception => e unless DRb::DRbBadURI === e or DRb::DRbBadScheme === e DeepTest.logger.debug "drubyall open_server exception: #{e.}\n#{e.backtrace.join("\n")}" end raise end |
.parse_uri(uri) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/deep_test/extensions/drb_extension.rb', line 3 def self.parse_uri(uri) if uri =~ /^drubyall:\/\/(.*?):(\d+)(\?(.*))?$/ host = $1 port = $2.to_i option = $4 [host, port, option] else raise(DRb::DRbBadScheme, uri) unless uri =~ /^drubyall:/ raise(DRb::DRbBadURI, 'can\'t parse uri:' + uri) end end |