From 7838445887706279d47e79cb8279b77a40c6cd11 Mon Sep 17 00:00:00 2001 From: Nick Pellant Date: Tue, 14 Apr 2020 18:16:07 +0100 Subject: [PATCH 1/2] Add IbClientAdapter#ib_client_connected? This method returns the status of the client. It can be used like so: ```ruby DRbObject.new_with_uri("druby://localhost:1992").ib_client_connected? ``` This is useful for liveness probes and health checks when running in a production system. --- lib/ib_ruby_proxy/server/ib_client_adapter.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ib_ruby_proxy/server/ib_client_adapter.rb b/lib/ib_ruby_proxy/server/ib_client_adapter.rb index 4b65696..c82b436 100644 --- a/lib/ib_ruby_proxy/server/ib_client_adapter.rb +++ b/lib/ib_ruby_proxy/server/ib_client_adapter.rb @@ -26,6 +26,10 @@ def initialize(ib_client, ib_wrapper_adapter) @ib_wrapper_adapter = ib_wrapper_adapter end + def ib_client_connected? + @ib_client.isConnected + end + # @param [IbRubyProxy::Client::IbCallbacksObserver] ib_callbacks_observer def add_ib_callbacks_observer(ib_callbacks_observer) ib_wrapper_adapter.add_observer(ib_callbacks_observer) From e5ae757ab30f4d530fa03dea99a8538707db351d Mon Sep 17 00:00:00 2001 From: Nick Pellant Date: Tue, 14 Apr 2020 18:19:50 +0100 Subject: [PATCH 2/2] Fix RuboCop offenses --- lib/ib_ruby_proxy/server/ib_proxy_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ib_ruby_proxy/server/ib_proxy_service.rb b/lib/ib_ruby_proxy/server/ib_proxy_service.rb index f03dbee..c12dec0 100644 --- a/lib/ib_ruby_proxy/server/ib_proxy_service.rb +++ b/lib/ib_ruby_proxy/server/ib_proxy_service.rb @@ -20,9 +20,9 @@ module Server # * Starts an IB message-processing thread that will dispatch messages sent to IB client app ( # gateway or TWS) class IbProxyService - DEFAULT_IB_HOST = 'localhost' + DEFAULT_IB_HOST = 'localhost'.freeze DEFAULT_IB_GATEWAY_PORT = 4002 - DEFAULT_DRB_HOST = 'localhost' + DEFAULT_DRB_HOST = 'localhost'.freeze DEFAULT_DRB_PORT = 1992 # @param [String] ib_host Hostname for the IB client app (gateway or TWS). Default +localhost+