From d57402eb5a5e9e24cb08d1c3a5dcc50f4f8b8dcd Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Tue, 30 Apr 2024 12:31:45 +0900 Subject: [PATCH] Move struct definition outside of constructor Signed-off-by: Daijiro Fukuda --- lib/fluent/plugin/out_http.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/fluent/plugin/out_http.rb b/lib/fluent/plugin/out_http.rb index 78ba4cf88d..09ab90858d 100644 --- a/lib/fluent/plugin/out_http.rb +++ b/lib/fluent/plugin/out_http.rb @@ -37,6 +37,8 @@ class HTTPOutput < Output class RetryableResponse < StandardError; end + CacheEntry = Struct.new(:uri, :conn) + helpers :formatter desc 'The endpoint for HTTP request, e.g. http://example.com/api' @@ -111,7 +113,6 @@ def initialize @cache = [] @cache_id_mutex = Mutex.new - @cache_entry = Struct.new(:uri, :conn) end def close @@ -124,7 +125,7 @@ def close def configure(conf) super - @cache = Array.new(actual_flush_thread_count, @cache_entry.new("", nil)) if @reuse_connections + @cache = Array.new(actual_flush_thread_count, CacheEntry.new("", nil)) if @reuse_connections @cache_id = 0 if @retryable_response_codes.nil? @@ -335,7 +336,7 @@ def make_request_cached(uri, req) else Net::HTTP.start(uri.host, uri.port, @http_opt) end - @cache[id] = @cache_entry.new(uri_str, http) + @cache[id] = CacheEntry.new(uri_str, http) end @cache[id].conn.request(req) end