lib/fluent/plugin/out_cloudsearch.rb in fluent-plugin-cloudsearch-0.0.1 vs lib/fluent/plugin/out_cloudsearch.rb in fluent-plugin-cloudsearch-0.1.0
- old
+ new
@@ -27,19 +27,22 @@
# override config. (config_set_default can't override it)
conf['buffer_chunk_limit'] ||= MAX_SIZE_LIMIT
super
+ unless @endpoint
+ raise ConfigError, "'endpoint' parameter is required"
+ end
if @buffer.buffer_chunk_limit > MAX_SIZE_LIMIT
raise ConfigError, "buffer_chunk_limit must be less than #{MAX_SIZE_LIMIT}"
end
end
def start
super
options = setup_credentials
- options[:endpoint] = @endpoint if @endpoint
+ options[:endpoint] = @endpoint
options[:region] = @region if @region
@client = Aws::CloudSearchDomain::Client.new(options)
end
def shutdown
@@ -62,15 +65,15 @@
elsif record['type'] != 'delete' then
log.warn "type is add or delete #{record.to_s}"
return ''
end
- "#{record.to_json}\n"
+ "#{record.to_json},"
end
def write(chunk)
documents = '['
- documents << chunk.read.split("\n").join(",")
+ documents << chunk.read.chop # chop last ','
documents << ']'
resp = @client.upload_documents(
:documents => documents,
:content_type => "application/json"
)