From 2e6680d80aa993922e77ddaf4adc88c62262d285 Mon Sep 17 00:00:00 2001 From: William Le Date: Mon, 19 Aug 2024 12:24:18 +0800 Subject: [PATCH 1/3] doc(ws/subscribe): document error on Ruby3 --- lib/orchestrator/status.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/orchestrator/status.rb b/lib/orchestrator/status.rb index 70968e5..0426236 100644 --- a/lib/orchestrator/status.rb +++ b/lib/orchestrator/status.rb @@ -49,6 +49,12 @@ def initialize(thread, controller) # Subscribes to updates from a system module # Modules do not have to exist and updates will be triggered as soon as they do exist + # + # When built with Ruby 3: + # [error] unhandled exception: wrong number of arguments (given 1, expected 0; required keywords: status, callback, on_thread) (performing next tick callback) + # /home/aca-apps/ruby-engine/lib/orchestrator/status.rb:52:in `subscribe' + # /home/aca-apps/ruby-engine/lib/orchestrator/websocket_manager.rb:304:in `block in try_bind' + def subscribe(status:, callback:, on_thread:, sys_name: nil, sys_id: nil, mod: nil, mod_name: nil, mod_id: nil, index: nil) # Build the subscription object (as loosely coupled as we can) sub = Subscription.new(as_sym(sys_name), as_sym(sys_id), as_sym(mod_name), as_sym(mod_id), index.to_i, as_sym(status), callback, on_thread) From 89f127cba3a61a674f92c24832faed3a2b576da5 Mon Sep 17 00:00:00 2001 From: William Le Date: Mon, 19 Aug 2024 13:05:49 +0800 Subject: [PATCH 2/3] fix(ws/subscribe): Ruby3 syntax --- lib/orchestrator/core/system_proxy.rb | 4 ++-- lib/orchestrator/status.rb | 5 ----- lib/orchestrator/websocket_manager.rb | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/orchestrator/core/system_proxy.rb b/lib/orchestrator/core/system_proxy.rb index de2f4c7..d15c991 100644 --- a/lib/orchestrator/core/system_proxy.rb +++ b/lib/orchestrator/core/system_proxy.rb @@ -201,7 +201,7 @@ def subscribe(mod_name, index, status = nil, callback = nil, &block) thread.schedule do begin defer.resolve ( - thread.observer.subscribe(options) + thread.observer.subscribe(*options) ) rescue => e defer.reject(e) @@ -210,7 +210,7 @@ def subscribe(mod_name, index, status = nil, callback = nil, &block) defer.promise.value else - @thread.observer.subscribe(options) + @thread.observer.subscribe(*options) end @origin.add_subscription sub if @origin diff --git a/lib/orchestrator/status.rb b/lib/orchestrator/status.rb index 0426236..f97449c 100644 --- a/lib/orchestrator/status.rb +++ b/lib/orchestrator/status.rb @@ -49,11 +49,6 @@ def initialize(thread, controller) # Subscribes to updates from a system module # Modules do not have to exist and updates will be triggered as soon as they do exist - # - # When built with Ruby 3: - # [error] unhandled exception: wrong number of arguments (given 1, expected 0; required keywords: status, callback, on_thread) (performing next tick callback) - # /home/aca-apps/ruby-engine/lib/orchestrator/status.rb:52:in `subscribe' - # /home/aca-apps/ruby-engine/lib/orchestrator/websocket_manager.rb:304:in `block in try_bind' def subscribe(status:, callback:, on_thread:, sys_name: nil, sys_id: nil, mod: nil, mod_name: nil, mod_id: nil, index: nil) # Build the subscription object (as loosely coupled as we can) diff --git a/lib/orchestrator/websocket_manager.rb b/lib/orchestrator/websocket_manager.rb index 009609a..b3be49b 100644 --- a/lib/orchestrator/websocket_manager.rb +++ b/lib/orchestrator/websocket_manager.rb @@ -301,12 +301,12 @@ def try_bind(id, sys, system, mod_name, index, name, lookup) thread = mod_man.thread thread.schedule do defer.resolve ( - thread.observer.subscribe(options) + thread.observer.subscribe(*options) ) end else @reactor.schedule do - defer.resolve @stattrak.subscribe(options) + defer.resolve @stattrak.subscribe(*options) end end end From e1a1c4bcf8c082e5e0928ca89451cee3fbde55e8 Mon Sep 17 00:00:00 2001 From: William Le Date: Mon, 19 Aug 2024 15:21:29 +0800 Subject: [PATCH 3/3] fix(ws/subscribe): Ruby3 syntax --- lib/orchestrator/core/system_proxy.rb | 4 ++-- lib/orchestrator/websocket_manager.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/orchestrator/core/system_proxy.rb b/lib/orchestrator/core/system_proxy.rb index d15c991..91ce0a3 100644 --- a/lib/orchestrator/core/system_proxy.rb +++ b/lib/orchestrator/core/system_proxy.rb @@ -201,7 +201,7 @@ def subscribe(mod_name, index, status = nil, callback = nil, &block) thread.schedule do begin defer.resolve ( - thread.observer.subscribe(*options) + thread.observer.subscribe(**options) ) rescue => e defer.reject(e) @@ -210,7 +210,7 @@ def subscribe(mod_name, index, status = nil, callback = nil, &block) defer.promise.value else - @thread.observer.subscribe(*options) + @thread.observer.subscribe(**options) end @origin.add_subscription sub if @origin diff --git a/lib/orchestrator/websocket_manager.rb b/lib/orchestrator/websocket_manager.rb index b3be49b..2726e74 100644 --- a/lib/orchestrator/websocket_manager.rb +++ b/lib/orchestrator/websocket_manager.rb @@ -301,12 +301,12 @@ def try_bind(id, sys, system, mod_name, index, name, lookup) thread = mod_man.thread thread.schedule do defer.resolve ( - thread.observer.subscribe(*options) + thread.observer.subscribe(**options) ) end else @reactor.schedule do - defer.resolve @stattrak.subscribe(*options) + defer.resolve @stattrak.subscribe(**options) end end end