Skip to content

Commit

Permalink
Use retry_operate to be recoverable operation
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <cosmo0920.oucc@gmail.com>
  • Loading branch information
cosmo0920 committed Jan 26, 2022
1 parent 0647e15 commit 47b4275
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/fluent/plugin/out_opensearch_data_stream.rb
Expand Up @@ -31,16 +31,16 @@ def configure(conf)

@client = client
unless @use_placeholder
delay = 1
begin
@data_stream_names = [@data_stream_name]
create_index_template(@data_stream_name, @data_stream_template_name, @host)
create_data_stream(@data_stream_name)
retry_operate(@max_retry_putting_template,
@fail_on_putting_template_retry_exceed,
@catch_transport_exception_on_retry) do
create_index_template(@data_stream_name, @data_stream_template_name, @host)
create_data_stream(@data_stream_name)
end
rescue => e
log.info "Failed to create data stream, will retry in #{delay} second(s): <#{@data_stream_name}> #{e.message}"
sleep(delay)
delay *= 2
retry
raise Fluent::ConfigError, "Failed to create data stream: <#{@data_stream_name}> #{e.message}"
end
end
end
Expand Down

0 comments on commit 47b4275

Please sign in to comment.