Skip to content

Commit

Permalink
Move struct definition outside of constructor
Browse files Browse the repository at this point in the history
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
  • Loading branch information
daipom committed Apr 30, 2024
1 parent af18531 commit d57402e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/fluent/plugin/out_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -111,7 +113,6 @@ def initialize

@cache = []
@cache_id_mutex = Mutex.new
@cache_entry = Struct.new(:uri, :conn)
end

def close
Expand All @@ -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?
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d57402e

Please sign in to comment.