Skip to content

Commit

Permalink
fluent-cat: Add --retry-limit to specify the number of retry limit
Browse files Browse the repository at this point in the history
Signed-off-by: Kenji Okimoto <[email protected]>
  • Loading branch information
okkez committed Nov 27, 2018
1 parent a82e9c6 commit 9a6baa2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
format = 'json'
message_key = 'message'
time_as_integer = false
retry_limit = 5

op.on('-p', '--port PORT', "fluent tcp port (default: #{port})", Integer) {|i|
port = i
Expand Down Expand Up @@ -75,6 +76,10 @@
time_as_integer = true
}

op.on('--retry-limit N', "Specify the number of retry limit (default: #{retry_limit})", Integer) {|n|
retry_limit = n
}

singleton_class.module_eval do
define_method(:usage) do |msg|
puts op.to_s
Expand Down Expand Up @@ -132,7 +137,7 @@ def run
end
end

def initialize(tag, connector, time_as_integer: false)
def initialize(tag, connector, time_as_integer: false, retry_limit: 5)
@tag = tag
@connector = connector
@socket = false
Expand All @@ -144,7 +149,7 @@ def initialize(tag, connector, time_as_integer: false)
@pending = []
@pending_limit = 1024 # TODO
@retry_wait = 1
@retry_limit = 5 # TODO
@retry_limit = retry_limit
@time_as_integer = time_as_integer

super()
Expand Down Expand Up @@ -291,7 +296,7 @@ def abort_message(time, record)
}
end

w = Writer.new(tag, connector, time_as_integer: time_as_integer)
w = Writer.new(tag, connector, time_as_integer: time_as_integer, retry_limit: retry_limit)
w.start

case format
Expand Down

0 comments on commit 9a6baa2

Please sign in to comment.