Skip to content

Commit 9ff164f

Browse files
authored
Merge pull request jorgemanrubia#3 from anarkioteam/quiet-connection-errors
Add adjustable verbosity for server DRb
2 parents fdaaaa8 + 2be1023 commit 9ff164f

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

bin/ibproxy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,30 @@ command :server do |c|
2323
c.option '--ib-port PORT', Integer, "Port for interactive brokers client. #{IbRubyProxy::Server::IbProxyService::DEFAULT_IB_GATEWAY_PORT} by default (Gateway). Default for TWS is whatever"
2424
c.option '--drb-host HOST', String, "Host for the server drb endpoint. #{IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_HOST} by default"
2525
c.option '--drb-port PORT', Integer, "Port for the served drb endpoint. #{IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_PORT} by default"
26+
c.option '--verbose-server BOOL', String, "Bool for server verbosity. #{IbRubyProxy::Server::IbProxyService::DEFAULT_SERVER_VERBOSITY} by default"
2627

2728
c.action do |args, options|
2829
options.default(
2930
ib_host: IbRubyProxy::Server::IbProxyService::DEFAULT_IB_HOST,
3031
ib_port: IbRubyProxy::Server::IbProxyService::DEFAULT_IB_GATEWAY_PORT,
3132
drb_host: IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_HOST,
3233
drb_port: IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_PORT,
34+
verbose_server: IbRubyProxy::Server::IbProxyService::DEFAULT_SERVER_VERBOSITY,
3335
)
3436

3537
ib_host = options.ib_host
3638
ib_port = options.ib_port
3739
drb_host = options.drb_host
3840
drb_port = options.drb_port
41+
verbose_server = options.verbose_server
3942

4043
puts "Starting with ib port #{ib_port} and drb port #{drb_port}..."
4144
IbRubyProxy::Server::IbProxyService.new(
42-
ib_host: ib_host, ib_port: ib_port, drb_host: drb_host, drb_port: drb_port
45+
ib_host: ib_host,
46+
ib_port: ib_port,
47+
drb_host: drb_host,
48+
drb_port: drb_port,
49+
verbose_server: verbose_server
4350
).start
4451
end
4552
end

lib/ib_ruby_proxy/server/ib_proxy_service.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ class IbProxyService
2424
DEFAULT_IB_GATEWAY_PORT = 4002
2525
DEFAULT_DRB_HOST = 'localhost'.freeze
2626
DEFAULT_DRB_PORT = 1992
27+
DEFAULT_SERVER_VERBOSITY = 'true'.freeze
2728

2829
# @param [String] ib_host Hostname for the IB client app (gateway or TWS). Default +localhost+
2930
# @param [Integer] ib_port Port for hte IB client app (gateway or TWS). Default +4002+ (gateway)
3031
# @param [String] drb_host Hostname for the DRB process. Default +localhost+
3132
# @param [Integer] drb_port Port for the . Default +1992+
33+
# @param [String] verbose_server true/false for server verbosity . Default +true+
3234
def initialize(ib_host: DEFAULT_IB_HOST, ib_port: DEFAULT_IB_GATEWAY_PORT,
33-
drb_host: DEFAULT_DRB_HOST, drb_port: DEFAULT_DRB_PORT)
35+
drb_host: DEFAULT_DRB_HOST, drb_port: DEFAULT_DRB_PORT,
36+
verbose_server: DEFAULT_SERVER_VERBOSITY)
3437
@ib_host = ib_host
3538
@ib_port = ib_port
3639
@drb_host = drb_host
3740
@drb_port = drb_port
41+
@verbose_server = { 'true' => true, 'false' => false }.fetch(verbose_server, true)
3842

3943
@wrapper = IbRubyProxy::Server::IbWrapperAdapter.new
4044
@client = wrapper.client
@@ -48,7 +52,7 @@ def initialize(ib_host: DEFAULT_IB_HOST, ib_port: DEFAULT_IB_GATEWAY_PORT,
4852
# Clients of the DRb service will get an {IbClientAdapter} object to interact with the IB api
4953
# @return [void]
5054
def start
51-
DRb.start_service("druby://#{drb_host}:#{drb_port}", ib_client_adapter, verbose: true)
55+
DRb.start_service("druby://#{drb_host}:#{drb_port}", ib_client_adapter, verbose: @verbose_server)
5256
start_ib_message_processing_thread
5357
puts "Ib proxy server started at druby://#{drb_host}:#{drb_port}. Connected to IB at"\
5458
" #{ib_host}:#{ib_port}"

0 commit comments

Comments
 (0)