From 89336da0bcac6bc6be5a736074bc03f1fe80e67e Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Wed, 16 Oct 2024 01:32:08 +1300 Subject: [PATCH] Fix compatibility with `io-stream` changes. --- lib/falcon/command/supervisor.rb | 4 ++-- lib/falcon/service/supervisor.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/falcon/command/supervisor.rb b/lib/falcon/command/supervisor.rb index 1a6a81ae..a1bb1082 100644 --- a/lib/falcon/command/supervisor.rb +++ b/lib/falcon/command/supervisor.rb @@ -40,8 +40,8 @@ class Metrics < Samovar::Command # Send the metrics message to the supervisor and print the results. def call(stream) - stream.puts({please: 'metrics'}.to_json, separator: "\0") - response = JSON.parse(stream.gets("\0"), symbolize_names: true) + stream.puts({please: 'metrics'}.to_json, separator: "\0", chomp: true) + response = JSON.parse(stream.read_until("\0"), symbolize_names: true) $stdout.puts response end diff --git a/lib/falcon/service/supervisor.rb b/lib/falcon/service/supervisor.rb index 4711fc59..9e9ffde6 100644 --- a/lib/falcon/service/supervisor.rb +++ b/lib/falcon/service/supervisor.rb @@ -74,7 +74,7 @@ def setup(container) @bound_endpoint.accept do |peer| stream = ::IO::Stream(peer) - while message = stream.gets("\0") + while message = stream.read_until("\0") response = handle(JSON.parse(message, symbolize_names: true)) stream.puts(response.to_json, separator: "\0") end @@ -101,7 +101,7 @@ def invoke(command) stream.puts(command.to_json, separator: "\0") - response = JSON.parse(stream.gets("\0"), symbolize_names: true) + response = JSON.parse(stream.read_until("\0"), symbolize_names: true) return response end