Skip to content

Commit

Permalink
Merge f098359 into bee28e3
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmo0920 committed Jan 31, 2022
2 parents bee28e3 + f098359 commit bf03ef8
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/fluent/plugin/out_opensearch_data_stream.rb
Expand Up @@ -29,32 +29,21 @@ def configure(conf)
@data_stream_names = []
end

host = data_stream_connection

unless @use_placeholder
begin
@data_stream_names = [@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, host)
create_index_template(@data_stream_name, @data_stream_template_name)
create_data_stream(@data_stream_name)
end
rescue => e
raise Fluent::ConfigError, "Failed to create data stream: <#{@data_stream_name}> #{e.message}"
end
end
end

# FIXME: Currently, the first element from hosts is only used and extracted.
def data_stream_connection
if host = get_connection_options[:hosts].first
"#{host[:scheme]}://#{host[:host]}:#{host[:port]}#{host[:path]}"
else
@host
end
end

def validate_data_stream_parameters
{"data_stream_name" => @data_stream_name,
"data_stream_template_name"=> @data_stream_template_name}.each do |parameter, value|
Expand All @@ -80,7 +69,7 @@ def validate_data_stream_parameters
end

def create_index_template(datastream_name, template_name, host = nil)
return if data_stream_exist?(datastream_name) or template_exists?(template_name, host)
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
body = {
"index_patterns" => ["#{datastream_name}*"],
"data_stream" => {},
Expand Down

0 comments on commit bf03ef8

Please sign in to comment.